Skip to main content
Inspiring
July 19, 2010
Question

Tweening MC in from side to a length of stage.stageWidth - (set amount)

  • July 19, 2010
  • 1 reply
  • 394 views

Hi forum,

The title basically explains what I wish to do.

I'm after a way to implement a similar style of navigation as the blue strip that enters from the right hand side of the stage on this website:

http://www.steffenjahn.com/publish/html/index.html

I'm fairly sure it will revolve around the use of a stage.stageWidth listener on an mc and then subtracting a certain amount to ensure it doesn't span the entire width..

However, I'm struggling to implement it myself.

Any help you can provide would be fantastic, whether that's useful tutorials or pieces of as3.

Thanks a lot.

This topic has been closed for replies.

1 reply

July 19, 2010

As a simple example say you wanted the bar to slide in from stage left (x = 0) and end 50 pixels from the right.

First you need to set the width of your bar, which will depend on what you're doing - but for a simple shape you might do:

var edgeBuffer:int = 50;

myBar.width = stage.stageWidth - edgeBuffer;

Then you would move it so it's off stage - assuming an upper left reg point:

myBar.x = -myBar.width;

Then you can tween it on stage - I use TweenLite so:

TweenLite.to(myBar, 2, {x:0});

will slide the bar to x = 0 in 2 seconds.

DC_12341Author
Inspiring
July 19, 2010

Thank you very much for your time.

I'll have a play with the code you provided and get back to you!

Thanks again!