Hi all.....this will tell you how to change a shape through action scriptong.....
Create two layers:
- "Object"
- "Script"
in the main movie at "Object" layer.....
Draw a shape and convert it to movie clip....name it "object1" and then on the "script" layer.....go to frame 1 and add this action:
| xy = "20";
right = "20"; left = "-30"; |
The next step:
Go inside the Movie Clip Symbol and convert the shape into another Movie clip and name it "object2"...
Inside the "object1" movie clip......create another layer called "script"...then go to frame 1 of "script" and add the following code:-
| s = s - Math.random(500);
if (s > _root.left) { gotoAndPlay(5); } else { gotoAndPlay(1); } |
The next step:
Now go inside the "object2" movie clip symbol......
Create a layer called "script"....
On frame 1 add this action:
| setProperty(this, _xscale, Random(50)+50);
setProperty(this, _yscale, Random(50)+50); ny = Random(50)+50; nx = Random(50)+50; |
Create a blank key frame next to it and add this action:
| setProperty(this, _xscale, this._xscale +( (nx - this._xscale) /8));
setProperty(this, _yscale, this._yscale +( (ny - this._yscale) /8)); |
And create another frame(frame 3 that is) and add this action:
| if ((this._xscale >= (nx-1) and this._xscale <= (nx+1)) and (this._yscale >= (ny-1) and this._yscale <= (ny+1))) {
ny = Random(90)+10; nx = Random(90)+10; } gotoAndPlay(2); |
Remember...on the "object2" symbol.......the object layer must hav 3 frames too(if u dont know how to do that then create two frames (not keyframes) beside it...i tell u again....not keyframes.
And then exit the symbol and go to the main scene and TEST ur movie....
Hope this tutorial was useful.....












