Jump to content
Search Community

tweening a movieclip inside an array [as3]

mka1 test
Moderator Tag

Recommended Posts

Hi,

basically i have a movieclip called myGallery, and inside that clip i have an array of movieclips:

var boxes:Array=new Array(mc1, mc2, mc, mc4);

each of these movieclips has a movieclip inside called "patternMask"

 

From the root I want to tween all the "patternMask" clips that are children of the clips inside the array, I've tried:

TweenLite.to(myGallery.boxes.patternMask, 1, {y:140, ease:Circ.easeOut});

 

but it throws up the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock::TweenLite/init()

at com.greensock::TweenLite/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/updateAll()

 

can anyone let me know if there's a solution or if I have to do a workaround please?

Link to comment
Share on other sites

You'd need to loop through the boxes array and create a tween for each one. Kinda like:

 

for (var i:int = 0; i     TweenLite.to(myGallery.boxes[i].patternMask, 1, {y:140, ease:Circ.easeOut});
}

 

Or you could build a separate array ahead of time that contains references to all your patternMask instances and then feed that array to TweenMax's allTo(). If you need to tween those often, that'd be a slightly cleaner way.

Link to comment
Share on other sites

Hi, Im quite new as. but i have successfully follow the script above. the problem i have now is that all the MCs goes to the same position. How can I arrange them side by side with space in between? my code as below:

 

var boxes:Array=new Array(mc1, mc2, mc3);

for (var i:int = 0; i < boxes.length; i++) {
TweenLite.to(boxes[i], 1, {y:100, x:100, ease:Circ.easeOut, delay:1});
}

Link to comment
Share on other sites

It depends how much space you want inbetween and how big they are, but here's an example:

var boxes:Array=new Array(mc1, mc2, mc3);
var xDest:Number = 100;
var gap:Number = 10;

for (var i:int = 0; i    TweenLite.to(boxes[i], 1, {y:100, x:xDest, ease:Circ.easeOut, delay:1});
  xDest += boxes[i].width + gap;
}

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...