I’m trying to cycle between 2 different tween actions in Flex. Here is what I’m trying so far:
In declarations:
<fx:Declarations>
<s:Animate id="goRight"
duration="3000" target="{nShape}" >
<s:SimpleMotionPath property="x" valueFrom="0" valueTo="400" />
</s:Animate>
</fx:Declarations>
Running the animation:
var animate:Boolean = true;
var isLeft:Boolean = true;
while (animate)
{
if (isLeft)
{
goRight.play(null);
while (goRight.isPlaying){};
}
else {
goRight.play(null, true); // play it backwards
while (goRight.isPlaying){};
}
isLeft = !isLeft;
}
The problem is that once I start the animation (by clicking a button), I get a timeout error saying the script has been running for longer than 15 seconds, with no tweening ever occurring. The animation works if I were simply animating it once. Does anyone know how I can get this perpetual cycling of tweens working?
…You have 3 while loop that never breaks….
Flash is not threaded (yet) and it’s an event based language. How about you use events to check the progress or figure when the animation is done (which should dispatch a complete event).
This isn’t Java. This is a visual, threadless, asynchronous, frame based language.