Groups | Blog | Home
all groups > flash actionscript > july 2006 >

flash actionscript : Simple Tween Component


Scott Filloon
7/2/2006 1:02:56 AM
I 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

myIP
7/2/2006 3:12:29 PM
How are you using this code as a MovieClip? I used the coded you posted inside
a MC and when I compile it I don?t get any trace outputs. Your problem sounds
like a scope issue but I can?t determine that until I use it as a component.
Scott Filloon
7/4/2006 1:50:57 AM
I've uploaded the FLA file to my web server. It has the Movie Clip that I
wish to convert to a component with a sample mc so you can see how this
works. Test the file and use the buttons or arrow keys to move the test mc.
You will see that it works great as a movie clip in this FLA. Bu then, try
converting it to an SWC and converting it to a component. You will see how
it no longer works after doing so.

Tha location of the FLA is:
http://www.stingerweb.com/tweenComponent/TweenComponentStandalone.fla

Thanks fo any help anyone can provide me with. This isn't a ground breaking
component so anyone is welcome to use it once we get it working properly.

Thanks,

Scott


[quoted text, click to view]

AddThis Social Bookmark Button