Jump to content
Search Community

how create multiple TimelineMax

saitansky test
Moderator Tag

Recommended Posts

kk firstly i want to say thank you for all your work,

 

secondly plz don't look my english it pretty bad :P

 

the code all is in a class.as :

// my var i use in this example
public var tweenContainer:TimelineMax;

// the function create each movieclip and build it
public function constructProduct(productType:Number, trackNumber:Number):void {		
var array1:Array = new Array("0","_product_1","_product2","_product_3","_product_4","_product_5");
var array2:Array = new Array("0","product_1","product_2","product_3","product_4","product_5");

var maClass:Class = getDefinitionByName(array2[productType]) as Class;
var monClip:MovieClip = new maClass();
monClip.buttonMode = true;
monClip.x = 100 + (25*trackNumber);
monClip.y = -(25*trackNumber);
monClip.addEventListener(MouseEvent.MOUSE_DOWN, dragProduct);
monClip.addEventListener(MouseEvent.MOUSE_UP, stopDragProduct);
monClip.name = array1[productType];
this.array3[trackNumber].addChild(monClip);

// my famous time line
tweenContainer = new TimelineMax();
tweenContainer.append( new TweenMax(monClip, 1, {y:(300 - (25*trackNumber)), ease:Bounce.easeOut}) );
tweenContainer.append( new TweenMax(monClip, 5, {x:(850 + (25*trackNumber)), ease:Linear.easeNone}) );
}

//function event we just need the drag function for this exemple

private function getPosition(target:Object):void {
xPos = target.x;
yPos = target.y;
}

public function dragProduct(e:MouseEvent):void {
tweenContainer.pause();

getPosition(e.target);
e.target.startDrag(true);
}

 

all work fine, the animation animate each movieclip, the only problem i have ( and it not related to the timeline itself ) but to how call specific one or (probably more the solution) how build dynamic time line.

 

i want when you click on a product (monClip) the animation stop for this product, now he stop the last timeline call (it normal because they have all the same identifier). also im not obligatory to be a timlinemax, i can do two tweenMax with one with delay, if the solution with simple tweenMax is more easy

 

if in not enough clear i can describe more about what i expect to have in this function.

 

thanks you very much in advance,

Alex Grenier

Link to comment
Share on other sites

I'm not sure I understand your question correctly, but it sounds like you want to uniquely identify each TimelineMax and when a particular monClip is clicked, the associated timeline pauses. If so, you could use a Dictionary as a lookup reference for the event.currentTarget like:

 

var monLookup:Dictionary = new Dictionary();

public function constructProduct(productType:Number, trackNumber:Number):void { 
   ...
   var monClip:MovieClip = new maClass();
   ...
   tweenContainer = new TimelineMax();
   tweenContainer.append(...);
   ...
   monLookup[monClip] = tweenContainer;
}

public function dragProduct(e:MouseEvent):void {
   monLookup[e.currentTarget].pause();
   ...
}

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