当前位置:软件学习 > Flash >>

flash9太阳地球月亮系统

除了背景以外,全部使用as3代码:

var sun:Sprite = new Sprite();
sun.graphics.lineStyle(0,0xFF6600);
sun.graphics.beginFill(0xFF3300);
sun.graphics.drawCircle(0,0,40);
sun.graphics.endFill();

var earth:Sprite = new Sprite();
earth.graphics.lineStyle(0,0x92E9FE);
earth.graphics.beginFill(0x00CCFF);
earth.graphics.drawCircle(0,0,20);
earth.graphics.endFill();

var spot:Shape = new Shape();
spot.graphics.lineStyle(0,0x000000);
spot.graphics.beginFill(0x333333);
spot.graphics.drawCircle(0,0,2);
spot.graphics.endFill();

var moon:Shape = new Shape();
moon.graphics.lineStyle(0,0xFFFFCC);
moon.graphics.beginFill(0xFFFF00);
moon.graphics.drawCircle(0,0,5);
moon.graphics.endFill();

this.addChild(sun);
sun.x = 200;
sun.y = 200;

sun.addChild(spot);
spot.x = 20;
spot.y = 10;

sun.addChild(earth);
earth.x = 120;
earth.y = 0;

earth.addChild(moon);
moon.x = 50;
moon.y = 0;

stage.addEventListener(Event.ENTER_FRAME, orbit);

function orbit(evt:Event):void {
 
 sun.rotation++;
 
 earth.rotation+= 3;
 
 moon.rotation-=5;
 
}

补充:flash教程,Action
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,