RSS
email

Drawing Dynamic object in flash cs3:



Code:

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

Bookmark and Share

3 comments:

Unknown said...

this site is dyanmic

Anonymous said...

thankyou for your effort~!

Unknown said...

I would have used the Motion Tween instead of copying frames

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.