I'm almost there with this one. I have an animated walking character called mcPlayer. Inside of it's timeline I have frame labels at various animated states "walkingLeft","walkingRight" and "Idle". The walking animations are of him walking in one spot. I want to be able to use buttons to move the character with actionscript to various targets on the stage and have the corresponding animation play as it moves.
I have tried different commands on the mcPlayer timeline,like, putting a stop(); at the beginning of each anima. I have tried putting a gotoandplay(); at the end of each anima so it will go to the beginning and loop.I would like to use the timeline as little as possible.
How do I Have the animation play continuously while the tween is in motion?
I am not savvy using onUpdate or it's params . The code below was suggested to me to try. I'm not clear with the Error I keep getting around the undefined property "loopFrame". I'm thinking I am supposed to have a label on the "mcPLayer" timeline called loop?
btnRight.addEventListener(MouseEvent.CLICK, moveRight); btnLeft.addEventListener(MouseEvent.CLICK, moveLeft); function moveRight(Evt:MouseEvent):void{ // lastframe should be replaced with whatever the frame the walk right animation ends on. TweenLite.to(mcPlayer, 2, {x:450, onUpdate:updateHandler, onUpdateParams:['walkingRight', lastFrame], onComplete:idleHandler); mcPlayer.gotoAndPlay("walkingRight"); } function moveLeft(Evt:MouseEvent):void{ // lastframe should be replaced with whatever the frame the walk left animation ends on. TweenLite.to(mcPlayer, 2, {x:10, onUpdate:updateHandler, onUpdateParams:['walkingLeft', lastFrame], onComplete:idleHandler); mcPlayer.gotoAndPlay("walkingLeft"); } function updateHandler(loopLabel:String, lastFrame:int):void { if (mcPlayer.currentFrame == lastFrame) { mcPlayer.gotoAndPlay(loopLabel); } } function idleHandler():void { mcPlayer.gotoAndPlay("idle"); // this is also where you'd do anything else you need to do when it stops. }
I need to read up on using properties like "onUpdate". Something other than just the line in the documentation. if you could point me in the right direction that would be cool!Thanks.