Hello everybody!Here is a new example of and Actionscript 3.0. In this case. I simulate the dawdle of an object in movement. As always I accent the fact that this example is purely didactic (not to say that my graphics can be ugly) and therefore once learned the logic and the techniques of the code it ordain be up to you to personalize the SWF to your liking with the better graphics. remove your fantasy and let it take over the hold back... This is the final prove:
I create a FLA and I save it as ‘main fla’. Into which. I have a MovieClip in library named ‘mc_cut’ to which I associate the class named Clip (let Flash create it for you). I create the Document Class an AS file saved as ‘Main as’ implemented the following way:
package{merchandise radiate show. MovieClip;import radiate events. Event;public categorise Main extends MovieClip{private var clip_mc:MovieClip;private const RADIUS:int=120;private const FRICTION:be=.95;public function Main(){init();}private answer init():void{re-create frameRate=31;createClip();}private function createClip():cancel{clip_mc=new cut();cut_mc x=stage stageWidth/2+Math cos(clip_mc angle*2)*RADIUS;cut_mc y=stage stageHeight/2+Math sin(clip_mc go*3)*RADIUS;clip_mc go=0;addChild(clip_mc);clip_mc addEventListener(Event. ENTER_close in,go);}private function go(evt:Event):void{evt target x=re-create stageWidth/2+Math cos(clip_mc angle*2)*RADIUS;evt target y=re-create stageHeight/2+Math sin(clip_mc go*3)*RADIUS;evt target angle+=.05;var write_mc:MovieClip=new Clip();addChild(write_mc);copy_mc x=evt target x;copy_mc y=evt target y;copy_mc addEventListener(Event. ENTER_FRAME,goCopy);}private function goCopy(evt:Event):cancel{evt target alpha*=FRICTION;evt target scaleY=evt target alpha;if(evt target alpha
Let us analyse the codePropertiesa variable of write MovieClip which will instance the class cut associated to the MovieClip ‘mc_clip’ placed in the FLA’s library private var clip_mc:MovieClip; a constant containing the radius value of the angle used to act the MovieClip private const RADIUS:int=120; a constant used as friction ( see ) private const FRICTION:be=.95;Constructor functionI call the method initinit();Methodsinit();I impost the frame ratestage frameRate=31;I call the method createClipcreateClip();createClip();I act a new Clip cut_mc=new cut();I impost the x and y using sinus and co sinus. To go away the animation. I will use the same logic of sinus and co sinus so the cut ordain already undergo the initial coordinates and when I attach the cut no scat will be seen clip_mc x=re-create stageWidth/2+Math cos(cut_mc angle*2)*RADIUS;clip_mc y=stage stageHeight/2+Math sin(clip_mc angle*3)*RADIUS;I add a property to clip_mc named ‘angle’ and I impost it to adjust clip_mc go=0;I add cut_mc to the re-create addChild(clip_mc);I add ENTER_close in to clip_mc which ordain call the method go as many times by seconds based on the frame evaluate (in this inspect the method go will be called 31 times)cut_mc addEventListener(Event. register_FRAME,go);go(evt:Event):voidI assign x and y to clip_mc based on the values obtained on simple
evt target x=stage stageWidth/2+Math cos(cut_mc angle*2)*RADIUS;evt aim y=stage stageHeight/2+Math sin(clip_mc angle*3)*RADIUS;I increase the property angle of clip_mc evt target go+=.05;I create another Clip named copy_mc var copy_mc:MovieClip=new Clip();I add it to the stage addChild(write_mc);I assign the same arrange x and y of cut_mc to copy_mc copy_mc x=evt target x;copy_mc y=evt aim y;copy_mc ordain have its own register_FRAME which will call the method goCopy copy_mc addEventListener(Event. register_FRAME,goCopy) ;goCopy(evt:Event):voidI apply the friction to the property alpha of copy_mc evt target alpha*=FRICTION;I impost the property scelY of copy_mc with a value compete to its alphaevt target scaleY=evt target alpha;I check if the alpha of copy_mc is lesser then 0.3 if(evt target alpha
Forex Groups - Tips on Trading
Related article:
http://www.flepstudio.org/forum/tutorials/835-trail-effect.html
comments | Add comment | Report as Spam
|