Jump to content
Search Community

Recommended Posts

mydeadpixel
Posted

Hello, I might be a right n00b here but why can't I get this to work, and am I going the right way about this? When I take out the itemAnim.pause(); it works fine. Long and short of it I'm I'm making a basic game where I've got about 14 items that I want going off at different times and each item have hoverover features and other on click commands etc. Here is the code stripped down...

 

var itemArray:Array=new Array(item1,item2);
for (var i:int = 0; i < itemArray.length; i++) {
itemArray[i].addEventListener(MouseEvent.CLICK, addClick);
}
var item1Anim:TimelineLite = new TimelineLite();
item1Anim.insertMultiple([new TweenLite(item1, 5, {y:"800", ease:Linear.easeNone})], 0, TweenAlign.START);
var item2Anim:TimelineLite = new TimelineLite();
item2Anim.insertMultiple([new TweenLite(item2, 5, {y:"800", ease:Linear.easeNone})], 2, TweenAlign.START);
function addClick(event:MouseEvent):void {
var lastclicked = event.target.name;
var itemAnim = lastclicked + "Anim";
trace (itemAnim);
itemAnim.pause(); //this is the bugger that throws out the code...
}

 

Thanks for any help

 

Kind regards

 

Gary

 

test.fla.zip

mydeadpixel
Posted

the above code works perfectly when I use individual statements to pause..

 

item1Anim.pause();
item2Anim.pause();

 

but I'm trying to minimise my code. Ta :-)

Posted

try changing

 

var itemAnim = lastclicked + "Anim";

 

to

 

var itemAnim:TimelineLite = this[lastclicked + "Anim"];

mydeadpixel
Posted

Perfection!

 

Cheers buddy. :-)

 

G

  • Like 1

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