Skip to main content
todoSolo
Participant
November 15, 2009
Question

At wit's end / dynamic scrolling nav

  • November 15, 2009
  • 1 reply
  • 385 views

Hey guys,

I'm pretty new and tooooootally frustrated over what should be pretty simple. I have a super-wide nav that I'd like users to be able to explore--I've seen this a thousand times--the user hovers the mouse over the right side of the screen and the nav pans right; same for left side, more buttons appear, etc. Between enterFrame animation and Timer events and scrollRect and what not, I'm at a total loss.

Not asking for full script of course -- just point me in the right direction. I feel like there must be an easy solution I'm overlooking.

Thanks!!

todoSolo

This topic has been closed for replies.

1 reply

November 16, 2009

what do you have so far?

todoSolo
todoSoloAuthor
Participant
November 16, 2009

Well, I've tried a few different things. I have a long box that's much wider than the stage that I'm trying to move left and right. To do that, I have two invisible buttons over the left and righthand extremities. I tried creating a loop like this, which works to move the box but doesn't work as an animation. I assume this is because it's running the full loop before updating the screen?


var movingBox_mc:mcLongbox = new mcLongbox();

movingBox_mc.x = -200;
movingBox_mc.y = 300;

addChild(movingBox_mc);

shiftLeft_btn.addEventListener(MouseEvent.MOUSE_OVER, scrollLeft);

function scrollLeft(event:MouseEvent):void
{
    if(movingBox_mc.x < 0)
    {
        for(var i = movingBox_mc.x; i < 1; i++)
        {
            movingBox_mc.x = +1;
        }

    }
    else
    {
    }
}

I've also been trying the scrollRect thing, but without much luck, so I've no code to show for that. Keep deleting it. Same for enterFrame animaiton. Grr. Is scrollRect even a good idea here?

Thanks!!

November 16, 2009

forget about the loop.. the loop happens without regard to the enterframe.

anything that takes place in a loop will complete inside the frame.

try more just for your own test as onEnterFrame(e:Event){

if(movingBox_mc.x < 0){

movingBox_mc.x++

}

}

as far as the scrollRect, that works but depends on how you wish to use it.

movingBox.scrollRect= new Rectangle(0,0,movingBox_mc.width,movingBox_mc.height)

try more just for your own test as onEnterFrame(e:Event){

movingBox.scrollRect.x--

}

when using scroll rect moving the x forwards shifts your viewable contents to the left, and x backwards shifts viewables to the right

the problem you might find yoruself in later which we all have for this type of movement, is do you wish to have acceleration involved or is your motion a constant +=5 left  +=5 right.

but that is how you use the scroll rect,

remember not to use a while or for loop.. the only thing you will see is the end result of the loop during the enterFrame