forked from: forked from: flash on 2012-3-7
forked from forked from: flash on 2012-3-7 (diff: 7)
ActionScript3 source code
/**
* Copyright MMMMMonchi ( http://wonderfl.net/user/MMMMMonchi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xXdi
*/
// forked from MMMMMonchi's forked from: flash on 2012-3-7
// forked from MMMMMonchi's flash on 2012-3-7
package {
import flash.geom.Rectangle;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(frameRate=40,width=465,height=465)]
public class FlashTest extends Sprite {
private var sprite:Sprite;
private var bitmapA:Bitmap;
private var bitmapB:Bitmap;
private var vx:int=5;
private var vy:int=5;
private var vx1:int=5;
private var vy1:int=5;
private var vy2:int=5;
public function FlashTest() {
var bitmapData:BitmapData=new BitmapData(100,100,false,0xffff00);
bitmapA=new Bitmap(bitmapData);
bitmapB=new Bitmap(bitmapData);
sprite=new Sprite();
bitmapData.fillRect(new Rectangle(0,10,10,100),0x000000);
bitmapData.fillRect(new Rectangle(20,10,10,100),0x000000);
bitmapData.fillRect(new Rectangle(40,10,10,100),0x000000);
bitmapData.fillRect(new Rectangle(60,10,10,100),0x000000);
bitmapData.fillRect(new Rectangle(80,10,10,100),0x000000);
bitmapData.floodFill(20,10,0xff00ff);
bitmapData.floodFill(80,10,0x0ff0ff);
sprite.graphics.beginFill(0xffff00);
sprite.graphics.drawCircle(10,10,10);
sprite.graphics.drawCircle(50,10,10);
sprite.graphics.drawCircle(90,10,10);
sprite.graphics.drawCircle(30,10,10);
sprite.graphics.drawCircle(70,10,10);
sprite.graphics.endFill();
addEventListener(Event.ENTER_FRAME,move);
bitmapData.draw(sprite);
addChild(bitmapA);
bitmapB.scaleX=2.0;
bitmapB.scaleY=3.0;
bitmapB.y=150;
addChild(bitmapB);
addChild(sprite);
stage.addEventListener(MouseEvent.MOUSE_DOWN,stop);
stage.addEventListener(MouseEvent.MOUSE_UP,move2);
stage.addEventListener(MouseEvent.CLICK,draw);
}
private function move(e:Event):void{
sprite.x+=vx;
sprite.y+=vy;
bitmapA.y+=vy2;
bitmapB.x+=vx1;
bitmapB.y+=vy1;
if(sprite.x<0||sprite.x>=stage.stageWidth-90)vx=-vx;
if(sprite.y<0||sprite.y>=stage.stageHeight-20)vy=-vy;
if(bitmapB.x<0||bitmapB.x>=stage.stageWidth-200)vx1=-vx1;
if(bitmapB.y<0||bitmapB.y>=stage.stageHeight-300)vy1=-vy1;
if(bitmapA.y<0||bitmapA.y>=stage.stageHeight-100)vy2=-vy2;
}
private function stop(e:MouseEvent):void{
removeEventListener(Event.ENTER_FRAME,move);
}
private function move2(e:Event):void{
addEventListener(Event.ENTER_FRAME,move);
}
private function draw(e:Event):void{
sprite.graphics.lineStyle(3,0x000000);
sprite.graphics.drawCircle(Mouse.x,Mouse.y,30);
}
}
}
