Jump to content
Search Community

TimelineMax as2 - determine object type

Hippiesvin test
Moderator Tag

Recommended Posts

Hi Greensock

 

Is there any way to determine the type of object and/or what specific object just completed it's tween using TimelineMax?

I'm doing a project where a mobilephone CPU has to run a normal widescreen and I want to test-tweak the animating mc._quality- and tf.antialias -settings while they are animating to tune my animations.

 

var arr:Array = [tf1, tf2, mc1, tf3, mc2]; // textFields and MovieClips

var TM:TimelineMax = new TimelineMax();
TM.insertMultiple( TweenMax.allTo(arr, 0.3, {autoAlpha:100,  ease:Quad.easeIn, onStart:lowFi, onStartParams:[this], onComplete:hiFi, onCompleteParams:[this]}, 0.1), 0);

function lowFi(o:Object) {
// determine what kind of object (textfield, movieclip) & what specific object starts to animate
}
function hiFi(o:Object) {
// determine what kind of object (textfield, movieclip) & what specific object just completed
}

Link to comment
Share on other sites

There are several solutions:

 

1) This is how I'd do it: create a TweenPlugin that manages all of this for you automatically. Kinda like the CacheAsBitmapPlugin or StageQualityPlugin. This would probably perform better, keep your code more concise, and it would work in reverse too. There are some notes about how to create your own TweenPlugins in the TweenPlugin ASDocs at the top.

 

2) Loop through the results of the TweenMax.allTo() and define the onCompleteParams with the target, like:

 

var tweens:TweenMax.allTo(arr, 1, {x:100, onComplete:completeHandler});
for (var i:int = 0; i     tweens[i].vars.onCompleteParams = [tweens[i].target];
}

 

Callbacks always perform better than listeners (for those AS3 folks out there) (see #3)

 

3) If you were using the AS3 version, you could use listeners instead of callbacks because the TweenEvent that gets passed to the handler will have a "target" property that points to the tween. Like this:

TweenMax.allTo(arr, 1, {onStartListener:startHandler, onCompleteListener:completeHandler});
function startHandler(event:TweenEvent):void {
   if (event.target.target is TextField) {
       ...
   } else if (...) {
       ...
   }
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...