
It should be pretty straightforward, but I’m certainly open to clarifying anything people want. NextFrame = anim.currentFrame + framesToAdvance Here is the code: var desiredrate:int = parseInt(newrate.text) Ĭhangeratebutton.addEventListener(MouseEvent.CLICK, changerate) įrameIncrement = desiredrate/ameRate Īnim.addEventListener(Event.ENTER_FRAME, checkTime) Īnim.removeEventListener(Event.ENTER_FRAME, checkTime) įramesToAdvance = Math.floor(accumulatedPortion + frameIncrement) ĪccumulatedPortion = (accumulatedPortion + frameIncrement) - framesToAdvance Lastly, if we reach the end of the movie, move the playhead back to the start but add in any frames we should skip based on the frame increment and any accumulated frame amount. I have made lots of progress lately, but I have come across a new problem. We add that accumulation into the computation for advancing the playhead. I am making a side-scrolling platformer game in Flash (Actionscript 3.0). When we get control in a frame, advance the playhead by the whole number of frames we should advance, but accumulate the decimal portion in another value which accumulates ( accumulatedPortion). If it’s different, compute the number of frames we need to advance ( frameIncrement), knowing that we will be given control on each frame based on the SWF’s frame rate. The idea is very simple: if the clip is set to run at the same rate as the stage, just use play(). The animation is in a MovieClip on the stage, and the instance name is anim.

I created a Button with the name changeratebutton, which reset the processing based on the user’s input.

I noticed over at StackOverflow, people were suggesting using the Timer class, but I think an ENTER_FRAME solution is better, especially for trying to make the MovieClip run faster than the frame rate of the real SWF.įor this code, I used Flash CS5 and created a TextInput instance with the name “ newrate“. ActionScript 3.0 adalah restrukturisasi mendasar bahasa, begitu banyak sehingga sama sekali berbeda menggunakan mesin virtual.

This is pretty easy to do, but I figured others might want example code, so I’m posting it here. ActionScript 3.0 Pada bulan Juni 2006, ActionScript 3.0 debutnya dengan Adobe Flex 2.0 dan pemain yang sesuai, Flash Player 9. I needed to make a MovieClip run potentially at different frame rates.
