mydeadpixel Posted May 11, 2012 Posted May 11, 2012 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 May 11, 2012 Author Posted May 11, 2012 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
Carl Posted May 11, 2012 Posted May 11, 2012 try changing var itemAnim = lastclicked + "Anim"; to var itemAnim:TimelineLite = this[lastclicked + "Anim"];
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now