as3, flash fl tween transitions freezing
I have a bunch of different tweens going on in different movie clips but it seems that sometimes the tweens will freeze halfway through during my transitions.
This guy is having the same problem and his question was answered but I'm not too sure exactly what they meant when they told him what to do: http://www.actionscript.org/forums/showthread.php3?t=222606
Do I have to import my tween classes at the very beginning of my site in the root then referenc开发者_StackOverflow社区e those in every movie clip as opposed to importing the classes in each movieclip separately?
Here is an example of a tween inside one of my movieclips:
// Import classes
import fl.transitions.Tween;
import fl.transitions.easing.*;
// Bring in elements with tweening
var bandY:Tween = new Tween(band, "y", Strong.easeOut, 533, 259, 3, true);
var boxY:Tween = new Tween(box, "y", None.easeOut, -122, 0, 1, true);
var signY:Tween = new Tween(sign, "y", Regular.easeOut, 551, 224, 1.5, true);
var signX:Tween = new Tween(sign, "x", Regular.easeOut, -17, 82, 1.5, true);
var dragonMaskWidth:Tween = new Tween(dragonMask, "width", Regular.easeOut, 30, 500, 3, true);
What the post meant in the forum you referenced was that they OP should try creating non-local variables for the tweens. SO, instead of doing this
function onClick(e:MouseEvent):void
{
nextPage = e.currentTarget.mcTarget;
var theTween:Tween = new Tween(currentPage,"alpha",Strong.easeOut,1,0,1,true);
theTween.addEventListener(TweenEvent.MOTION_FINISH, onTween);
}
They were saying to try this:
var theTween:Tween;
function onClick(e:MouseEvent):void
{
nextPage = e.currentTarget.mcTarget;
theTween = new Tween(currentPage,"alpha",Strong.easeOut,1,0,1,true);
theTween.addEventListener(TweenEvent.MOTION_FINISH, onTween);
}
By doing this, the scope of the variable "theTween" is not local to the onClick event handler function, but rather it is in the same scope as the function itself.
My biggest recommendation would be to try using a different tweening library, there are TONS out there. The built-in library for Tweening in flash leaves a lot to be desired IMHO. I would take a look at one or more of these:
TweenLite
Tweener
GTween
AS3 Animation System
There are many more... just take a look
Actually, I figured out what the other guy was saying. I have to move tween variables outside of functions, makes sense. It was hard to see the difference in their code at first. Also realized that this was bad example code to use because there's no functions.
精彩评论