import flash.display.Sprite;
import flash.events.Event;
var spr:Sprite=new Sprite();
spr.graphics.beginFill(0xFF00FF,1);
spr.graphics.drawRect(100,100,200,200);
spr.graphics.endFill()
spr.name="sara";
spr.addEventListener(MouseEvent.CLICK,sarafun);
addChild(spr)
function sarafun(event:MouseEvent){
trace(event.target.name);
}
Explanation:
Sprite:
Derived from DisplayObject Class..
Lightweight..
Similar to movieclip but contains single frame or no timeline..
var spr:Sprite=new Sprite();
this is to create dynamic sprite..
Note:Similar to create empty movleclip
spr.graphics.beginFill(0xFF00FF,1);
spr.graphics.drawRect(100,100,200,200);
spr.graphics.endFill()
here how to create drawing objects...
Many ways like drawCircle(),drawEllipse()..,
spr.addEventListener(MouseEvent.CLICK,sarafun);
here we are adding listener...to object...more like
Note:
onpress=onrelease=MouseEvent.CLICK
onmousedown=MouseEvent.MOUSE_DOWN
onmouseup=MouseEvent.MOUSE_UP
soon..
addChild(spr);
here we are adding sprite to the display list...
Note:there is no need to specify depth since it manages itself
3 comments:
this site is dyanmic
thankyou for your effort~!
I would have used the Motion Tween instead of copying frames
Post a Comment