Simple Tween Component
Newsgroup_User Jul 1, 2006 10:57 PMI have been working on (what should be) a VERY simple
component/compiled
clip. The component will allow for setting actionscripted tweening for
movie clips. It's so basic that I opted not to even use a class and it uses
all internal actionscript. The problem is, when I drag it on the stage as a
movie clip, it works beautifully. But as soon as I export it as an SWC file
and use it from the Components panel, it doesn't work.
It basically only sets a function to call in order to make an mc tween. It
uses the mx.transitions for the easing. I've set a trace action that shows
all the parameters.
When used as a movie clip, it traces the following:
Instance Name: _level0.tc, Tween Type: _x, Ease Type: [type Function],
Starting: 148, Ending Point: 348, Time: 1
The Ease Type is a variable called "ease" and it's set with the
mx.transitions (ex: mx.transitions.easing.Regular.easeInOut). This works as
a movie clip.
After I export it as a SWC the it traces the following:
Instance Name: _level0.tc, Tween Type: _x, Ease Type: undefined, Starting:
148, Ending Point: 348, Time: 1
Ease Type is now "undefined"
Here is the code inside the mc:
************************************************************************************
stop();
//Importing transitions and easings
import mx.transitions.*;
import mx.transitions.easing.*;
//Begin actions for component
//Loading the transitions
loadTweens = new mx.transitions.Tween();
//Function to assign the actions to the MC
_global[functionName] = function(){
//This is where the problem occurs
//It is set from a paramenter variable called easeType and based on the
the mx.transitions are set
//If statement to determine the easing of the MC
if(easeType == "Regular.easeIn"){
ease = mx.transitions.easing.Regular.easeIn;
}else if(easeType == "Regular.easeOut"){
ease = mx.transitions.easing.Regular.easeOut;
}else if(easeType == "Regular.easeInOut"){
ease = mx.transitions.easing.Regular.easeInOut;
}else if(easeType == "Strong.easeIn"){
ease = mx.transitions.easing.Strong.easeIn;
}else if(easeType == "Strong.easeOut"){
ease = mx.transitions.easing.Strong.easeOut;
}else if(easeType == "Strong.easeInOut"){
ease = mx.transitions.easing.Strong.easeInOut;
}else if(easeType == "Back.easeIn"){
ease = mx.transitions.easing.Back.easeIn;
}else if(easeType == "Back.easeOut"){
ease = mx.transitions.easing.Back.easeOut;
}else if(easeType == "Back.easeInOut"){
ease = mx.transitions.easing.Back.easeInOut;
}else if(easeType == "Bounce.easeIn"){
ease = mx.transitions.easing.Bounce.easeIn;
}else if(easeType == "Bounce.easeOut"){
ease = mx.transitions.easing.Bounce.easeOut;
}else if(easeType == "Bounce.easeInOut"){
ease = mx.transitions.easing.Bounce.easeInOut;
}else if(easeType == "Elastic.easeIn"){
ease = mx.transitions.easing.Elastic.easeIn;
}else if(easeType == "Elastic.easeOut"){
ease = mx.transitions.easing.Elastic.easeOut;
}else if(easeType == "Elastic.easeInOut"){
ease = mx.transitions.easing.Elastic.easeInOut;
}else if(easeType == "None"){
ease = mx.transitions.easing.None.easeNone;
}
//Determines the direction of the tween
if(tweenType == "_x"){
starting = _parent[symbolInstance]._x;
}else if(tweenType == "_y"){
starting = _parent[symbolInstance]._y;
}else if(tweenType == "_xscale"){
starting = _parent[symbolInstance]._xscale;
}else if(tweenType == "_yscale"){
starting = _parent[symbolInstance]._yscale;
}
//Ending Point of the MC
endingPoint = starting + ending;
trace("Instance Name: "+_parent[symbolInstance]+", Tween Type: "+
tweenType+", Ease Type: "+ease+", Starting: "+starting+", Ending Point:
"+endingPoint+", Time: "+time);//time = 2;
trace(easeType);
functionTween = new mx.transitions.Tween(_parent[symbolInstance],
tweenType, ease, starting, endingPoint, time, true);
}
************************************************************************************
Thanks for any help with this.
Scott
clip. The component will allow for setting actionscripted tweening for
movie clips. It's so basic that I opted not to even use a class and it uses
all internal actionscript. The problem is, when I drag it on the stage as a
movie clip, it works beautifully. But as soon as I export it as an SWC file
and use it from the Components panel, it doesn't work.
It basically only sets a function to call in order to make an mc tween. It
uses the mx.transitions for the easing. I've set a trace action that shows
all the parameters.
When used as a movie clip, it traces the following:
Instance Name: _level0.tc, Tween Type: _x, Ease Type: [type Function],
Starting: 148, Ending Point: 348, Time: 1
The Ease Type is a variable called "ease" and it's set with the
mx.transitions (ex: mx.transitions.easing.Regular.easeInOut). This works as
a movie clip.
After I export it as a SWC the it traces the following:
Instance Name: _level0.tc, Tween Type: _x, Ease Type: undefined, Starting:
148, Ending Point: 348, Time: 1
Ease Type is now "undefined"
Here is the code inside the mc:
************************************************************************************
stop();
//Importing transitions and easings
import mx.transitions.*;
import mx.transitions.easing.*;
//Begin actions for component
//Loading the transitions
loadTweens = new mx.transitions.Tween();
//Function to assign the actions to the MC
_global[functionName] = function(){
//This is where the problem occurs
//It is set from a paramenter variable called easeType and based on the
the mx.transitions are set
//If statement to determine the easing of the MC
if(easeType == "Regular.easeIn"){
ease = mx.transitions.easing.Regular.easeIn;
}else if(easeType == "Regular.easeOut"){
ease = mx.transitions.easing.Regular.easeOut;
}else if(easeType == "Regular.easeInOut"){
ease = mx.transitions.easing.Regular.easeInOut;
}else if(easeType == "Strong.easeIn"){
ease = mx.transitions.easing.Strong.easeIn;
}else if(easeType == "Strong.easeOut"){
ease = mx.transitions.easing.Strong.easeOut;
}else if(easeType == "Strong.easeInOut"){
ease = mx.transitions.easing.Strong.easeInOut;
}else if(easeType == "Back.easeIn"){
ease = mx.transitions.easing.Back.easeIn;
}else if(easeType == "Back.easeOut"){
ease = mx.transitions.easing.Back.easeOut;
}else if(easeType == "Back.easeInOut"){
ease = mx.transitions.easing.Back.easeInOut;
}else if(easeType == "Bounce.easeIn"){
ease = mx.transitions.easing.Bounce.easeIn;
}else if(easeType == "Bounce.easeOut"){
ease = mx.transitions.easing.Bounce.easeOut;
}else if(easeType == "Bounce.easeInOut"){
ease = mx.transitions.easing.Bounce.easeInOut;
}else if(easeType == "Elastic.easeIn"){
ease = mx.transitions.easing.Elastic.easeIn;
}else if(easeType == "Elastic.easeOut"){
ease = mx.transitions.easing.Elastic.easeOut;
}else if(easeType == "Elastic.easeInOut"){
ease = mx.transitions.easing.Elastic.easeInOut;
}else if(easeType == "None"){
ease = mx.transitions.easing.None.easeNone;
}
//Determines the direction of the tween
if(tweenType == "_x"){
starting = _parent[symbolInstance]._x;
}else if(tweenType == "_y"){
starting = _parent[symbolInstance]._y;
}else if(tweenType == "_xscale"){
starting = _parent[symbolInstance]._xscale;
}else if(tweenType == "_yscale"){
starting = _parent[symbolInstance]._yscale;
}
//Ending Point of the MC
endingPoint = starting + ending;
trace("Instance Name: "+_parent[symbolInstance]+", Tween Type: "+
tweenType+", Ease Type: "+ease+", Starting: "+starting+", Ending Point:
"+endingPoint+", Time: "+time);//time = 2;
trace(easeType);
functionTween = new mx.transitions.Tween(_parent[symbolInstance],
tweenType, ease, starting, endingPoint, time, true);
}
************************************************************************************
Thanks for any help with this.
Scott