Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
laxbuddha

new to TweenLite and AS3. How link multiple mc to the same function

Recommended Posts

Once again... figured it out... I need to stop being so quick to post.  Thanks

Link to post
Share on other sites

If all your clips are inside the same parent, then this is a very easy way to do it:

http://www.snorkl.tv/2010/08/assign-eventlisteners-to-multiple-movie-clips-in-a-single-blow-a-look-at-target-vs-currenttarget/

 

That link has a video and source files.

 

Another way to share the same functions for multiple buttons is to just use a simple loop:

 

 

 

import com.greensock.*;
import com.greensock.easing.*;




//loop through all buttons and assign listeners
for(var i = 1; i <=4; i++){
this["b" + i].addEventListener(MouseEvent.ROLL_OVER, navOver);
this["b" + i].addEventListener(MouseEvent.ROLL_OUT, navOver);
}




//on mouse over do this
function navOver(e:MouseEvent):void{
TweenMax.to(e.target, .8, {tint:0xff0000});
}


//on mouse out do this
function navOut(e:MouseEvent):void{
TweenMax.to(e.target, 2.5, {tint:null});
}

 

This assumes all buttons are named chronologically b1, b2, b3 etc.

I attached a cs5 file that uses the code above

 

Or you can store your button names in an array.

Or you can use OOP to create a class that all buttons share:

http://tv.adobe.com/watch/actionscript-11-with-doug-winnie/adding-advanced-behavior-to-custom-classes-episode-50/

 

 

 

 

 

dynamicButtons_cs5.zip

Link to post
Share on other sites

oops, I should have read that you figured it out;)

Link to post
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.

×