1 Create a new Flash file with Actionscript 3.
2 The scene will have just one layer and one frame.
3 Change the white background of scene to something else to contrast with the white lines.
4 Draw 3 small shapes - circles, polygons, whatever - and convert to symbol each one to MovieClip mc1, mc2, mc3.
5 Click on every symbol in the scene and name it as mc1, mc2, mc3 in the Properties tab - <instance name>
6 Click somewhere in the scene and in the Properties panel type " rd " in the class textbox.
7 Done with the Flash file.
8 Create new actionscript 3 file and name it " rd ".
9 Copy paste the following code:
package {
// IMPORTS
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.*;
public class rd extends MovieClip {
var xt=1;
var yt=1;
var zt=1;
var a=10;
var b=18;
var c=4/3;
var dt=0.01;
var dx;
var dy;
var dz;
var cnt=0;
public var mc1:MovieClip;
public var mc2:MovieClip;
public var mc3:MovieClip;
var sx:MovieClip = new MovieClip();
public function rd() {
super();
init();
addChild(sx);
}
private function init():void {
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
addEventListeners();
}
private function addEventListeners():void {
addEventListener( Event.ENTER_FRAME, __onEnterFrame );
}
private function __onEnterFrame( e:Event ):void {
if(cnt < 500){
/*
The following code uses the Lorenz equations to
define the position of the next bubble.
*/
dx = a*(yt-xt)*dt;
dy = (xt*(b-zt)-yt)*dt;
dz = (xt*yt-c*zt)*dt;
xt+=dx;
yt+=dy;
zt+=dz;
mc1.x = stage.stageWidth/60*(xt+30);
mc1.y =stage.stageHeight/60*(-zt+60);
sx.graphics.lineTo(mc1.x, mc1.y);
sx.graphics.lineStyle(1, 0xcccccc, 15);
mc2.x += (mc1.x-mc2.x)/30;
mc2.y += (mc1.y-mc2.y)/30;
sx.graphics.lineTo(mc2.x, mc2.y);
sx.graphics.lineStyle(1, 0xcccccc, 15);
mc3.x += (mc2.x-mc3.x)/30;
mc3.y += (mc2.y-mc3.y)/30;
sx.graphics.lineTo(mc3.x, mc3.y);
sx.graphics.lineStyle(1, 0xcccccc, 15);
cnt++;
}
}
}
}
Readmore:wikihow.com/Build-a-Flash-Animation-Using-Actionscript-3
Comments
Post a Comment