PDA

View Full Version : need a little help about movement


monolite
08-06-2005, 12:03 PM
Hey there
I've a little problem with some movement on a onRollOver action
I created a mc(should act as a button) with dynamic txt on it
When i move my mous over it, the txt should move from the left side of the mc to the right side.
I'm very new to AS but this is what i have.

dyntxt.html = true;
dyntxt.htmlText = "<font color=\"#ffffff\">bla</font>";
dyntxt._x = 20;
dyntxt._y = 0;
bgButton.onRollOver = function () {
if (dyntxt._x<170) {
dyntxt._x +=10;
}
};

This is what happens
When i move my mouse over the button dyntxt._x increases by 10 and then stops. When i move my mous over it again, it increases again by 10.
That until 170 is reached.
But what i want is, when i move my mouse over the button dyntxt._x should increase by 10 until 170 is reached.

I hope you get what i mean
Some help would be appreciated

Thanx
monolite

Dylan Marvin
08-06-2005, 02:59 PM
Think of "onRollOver" like "onClipEvent(load)", that is, the script only plays once. Once "onRollOver" returns positive, the button (or movie clip) won't check for another roll over until you roll out first.

Several ways to get around this. What you could do is put your text in a movie clip within your button, and when you roll over, you send a variable like "textclipname.scroller = true" to the nested clip. Then put your above code within an "onClipEvent(enterFrame)" on that nested clip, and put it under something like "if(scroller){", or "if(scroller == true){" ...etc...

monolite
08-06-2005, 10:50 PM
Thanx for your reply Dylan Marvin.
I went busy for quite some time and i figured it out.
I did it on a different way as you explained it, but it works :)

here's how i did it.
distance = bgButton._width-dyntxt._width;
moveinfunction = function (mover) {
if (mover._x<distance) {
mover._x += 5;
} else {
clearInterval(moveint);
}
};
hitBtn.onRollOver = function() {
moveint = setInterval(moveinfunction, 5, dyntxt);
moveinfunction(dyntxt);