Jump to content
Search Community

tpann

Members
  • Posts

    2
  • Joined

  • Last visited

tpann's Achievements

1

Reputation

  1. Very astute observations. The error was indeed in my other code and did not involve TweenMax. Go figure. Thank you for your thoughtful response.
  2. Hello, New to GSAP and new to this forum. This question has probably been answered many times but I don't know the appropriate key words to use to ask the question so I have not found a solution. I have a rather large Flash app (large and proprietary to my job so I can't post it here) in ActionScript 3 that uses a TweenMax.to statement. The tween is not working as I prefer. The app works like this: There is a "window" (just a visual box) that rectangular objects get added to over time. As they're added, they stack, with new ones going to the bottom of the stack. Once the stack gets too big for all objects to display in the window, the stack is supposed to tween upward to display the bottom object. I have reproduced the basic functionality in a simpler set of code so you can see how it works: import flash.display.Shape; import flash.display.Sprite; import flash.events.MouseEvent; import com.greensock.*; import com.greensock.easing.*; var boxArray:Array = new Array(); var windowHeight:Number = 300; var window:Sprite = new Sprite(); window.graphics.lineStyle(1); window.graphics.drawRect(0, 0, 400, 300); addChild(window); window.x = 100 window.y = 200; var stack:Sprite = new Sprite(); window.addChild(stack); button.addEventListener(MouseEvent.CLICK, addBox); function addBox(m:MouseEvent):void { var box:Shape = new Shape(); box.graphics.beginFill(Math.random()*0xFFFFFF); box.graphics.drawRect(0, 0, 200, 40); stack.addChild(box); box.x = 10; if (boxArray.length == 0) { box.y = 10; } else { box.y = boxArray[boxArray.length-1].y + boxArray[boxArray.length-1].height + 10; } boxArray.push(box); // if the new box is below the bottom of the window, tween upward to bring it into view if (stack.y + stack.height > windowHeight) { TweenMax.to(stack, 0.5, {y:-stack.height + windowHeight - 10}); } } [The only thing you have to do beyond pasting this into the Flash IDE is add a button to the stage and call it "button."] I was hoping this little example would have the same problem that I'm having in my bigger application but as luck would have it this works perfectly. However this enables me to explain my problem better: In my application, whenever a new object is added to the stack, the TweenMax.to statement moves the stack to stack.y = 0, meaning it jumps instantaneously all the way back down to y=0 AND THEN tweens all the way back up to the correct position. Of course this is not what I want -- I want it to look like the above example. I have tried casting the y parameter as a String but I get the same behavior. Can anyone provide some insight into what I might change to make my bigger application work like the one I've posted here? Thank you, Tim
×
×
  • Create New...