Jump to content
Search Community

-Dexter-

Members
  • Posts

    4
  • Joined

  • Last visited

-Dexter-'s Achievements

0

Reputation

  1. Many thanks for this! It is exactly what I needed.
  2. I'm sorry about the nonsense in my previous post. I was experimenting with tweens and then suddenly decided to try TimelineMax and ended up with some mixture of different commands. The following code shows what I'm after (I hope). import com.greensock.*; import com.greensock.easing.*; var square:MovieClip = new MovieClip(); addChild(square); square.graphics.lineStyle(3,0x00ff00); square.graphics.beginFill(0x0000FF); square.graphics.drawRect(0,0,100,100); square.graphics.endFill(); square.x = stage.stageWidth/2-square.width/2; square.y = stage.stageHeight/2-square.height/2; square.addEventListener( Event.ENTER_FRAME, movesquare ); var tweenLeft:TweenMax = new TweenMax(square, 2, {x:0, paused:true}); function movesquare(e:Event):void { if (mouseX < 20) tweenLeft.play(); else { tweenLeft.kill(); square.x = mouseX; } } Basically I want to use a tween when mouseX becomes less than 20 pixels from the left edge of the stage. I also want the tween to do three things: 1. play and stop once when mouseX < 20 2. stop playing (if currently tweening) and follow the mouse cursor if mouseX becomes >= 20. 3. play again when mouseX < 20 The above code will play the tween just once (the first time mouseX becomes less than 20). I also tried invalidate() instead of kill() and restart() instead of play() but it still doesn't work the way I want it. Even if it did is it a good idea to call "tweenLeft.kill();" 24 times per second? Should I try something that runs just once when I need it instead?
  3. Sorry, I should have explained that first. Ok here goes. I have a row of thumbnail images which use the ENTER_FRAME event to move to the left or to the right depending on mouseX. I wanted to stop this movement when the beginning/end is reached using tweens: var myTimeline:TimelineMax = new TimelineMax(); myTimeline.append(new TweenMax(thumbnailBar, 0.2, {x:0, ease:Quad.easeOut, paused:true, overwrite:0})); myTimeline.addLabel("smoothLeftScroll", 0); myTimeline.append(new TweenMax(thumbnailBar, 0.2, {x:(thumbnailArea.x - thumbnailBar.width + thumbnailArea.width), ease:Quad.easeOut, paused:true, overwrite:0})); myTimeline.addLabel("smoothRightScroll", 0.2); function thumbGallery(e:Event):void { /* some code here */ if (thumbnailBar.x > 5.7 * prevDiff && prevDiff < 0) // beginning reached. prevDiff < 0 means thumbnailBar moves to the left. { myTimeline.gotoAndStop("smoothLeftScroll"); myTimeline.tweenTo("smoothRightScroll"); } else if (thumbnailArea.x - thumbnailBar.width + thumbnailArea.width - thumbnailBar.x > -5.7 * prevDiff && prevDiff > 0) // end reached { myTimeline.gotoAndPlay("smoothRightScroll"); } else { thumbnailBar.x -= prevDiff; } var a:Array = myTimeline.getActive(); for (var i:Number = 0; i < a.length; i++) { trace(a[i].target + " is tweening"); } } I'm guessing this does not run properly because "myTimeline" is called multiple times. "TweenMax(thumbnailBar, 0.2, {x:0, ease:Quad.easeOut, paused:true, overwrite:0})" doesn't seem to help either. So my idea was to use "getActive()" and call "myTimeline" only when there are no tweens running already.
  4. Hi could anyone shed some light on how to use the "getActive()" method? I'm trying to do something like this (got it from another topic) but it doesn't return anything.. var a:Array = myTimeline.getActive(); for (var i:Number = 0; i <= a.length; i++) { trace(a[i].target + " is tweening"); } Saying that I'm new to TweenLite/Max would be banal, so I'll add that I'm new to Flash, AS and programming as well Thanks for any input
×
×
  • Create New...