|
-
How would i do this is AS3?
Hi,
I have some old code that i would like to re-use in and AS3 project, it was written in AS2. To be honest im not totally up with AS3...
This is the code i have from the AS2 project. Basically it just takes each frame from an array and matches it to a particular frame in a lipsync movie clip...
Thanks in advance..
Andy
onClipEvent(load) {
//amplitude array created by FlashAmp using a scale of 50 and a rate of 12 fps
//no smoothing (see additional example below)
amplitude=[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 3, 3, 2, 1, 2, 2, 1, 2, 2, 2, 3];
}
onClipEvent(enterframe) {
//set x and y scale of speaker to full size plus value from array.
//array value is determined by the playback head position in main timeline.
//this._xscale = 85 + amplitude[_root._currentFrame-1]
//this._yscale = 85 + amplitude[_root._currentFrame-1]
//that is, frame 7 - 1 = index 6, (6th place in zero-based array, value of 39).
myFrame = amplitude[_root._currentframe-1] + 1;
this.gotoAndStop(myFrame);
}
-
It's kind of weird code but I think I see what it's trying to do...Try dropping this into the first frame inside the clip. Also, be aware that this will break if your root timeline goes past 24 (or how many are in that array) frames.
PHP Code:
var amplitude:Array = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 3, 3, 2, 1, 2, 2, 1, 2, 2, 2, 3];
addEventListener(Event.ENTER_FRAME, function(e:Event):void{
gotoAndStop( amplitude[root.currentFrame - 1] + 1 );
});
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|