Image

Imageastrobenji wrote in Imageflashdev 😡frustrated

Listens: De La Soul - Stakes is High

Flash AS help (cross posted sorry for double ups)

G'day people,
I am absolutely desperate for some Flash Action Script help, so if anyone can give me a hand I would be hugely thankful. As my Action script is a little rusty, I'm wondering if someone who is fluent in AS could give me a hand.
I am trying to adjust a submenu in my new folio (you can see the whole thing in its current state at http://benw.sydneystylez.com, the menu I am working on is the one in the 'folio' section.)
Basically, I am changing it to something similar to this style of interaction yet having my menu replacing the "skye" graphic, and having it scroll horizontally, instead of vertically.

I'm going to continue this behind a cut so I can show you all the AS, and if anyone can give me some tips, I will give you my first born child =>



Basically, the original consists of the 'skye' movie clip (that scrolls) with an instance name of 'scroll_this, two buttons (one up, one down) and three key frames of AS in the main time line.

I will go through the AS in the main time line first.

The first frame (frame label 'start') has the following Action script:

dy = 0.0000;
dv = 0.5000;

speed_limit = 5.0;

lower_limit = 500;

upper_limit = -143;

friction = .1;


The second frame (frame label 'loop') has the following Action script:

if (accel == true) { dy += dv; }

if (decel == true) { dy -= dv; }


if (dy > speed_limit) { dy = speed_limit; }

if (dy < -speed_limit) { dy = -speed_limit; }


if (dy > 0) { dy -= friction; }

if (dy < 0) { dy += friction; }


if ( dy > 0 and dy < .1 ) { dy = .1; }

if ( dy > -.1 and dy < 0) { dy = -.1; }


if ( scroll_this._y > lower_limit ) { scroll_this._y = upper_limit; }

if ( scroll_this._y < upper_limit ) { scroll_this._y = lower_limit; }

scroll_this._y += dy;


Finally, the third frame (no frame label) has the following Action Script:

if (accel == true) { dy += dv; }

if (decel == true) { dy -= dv; }


if (dy > speed_limit) { dy = speed_limit; }

if (dy < -speed_limit) { dy = -speed_limit; }


if (dy > 0) { dy -= friction; }

if (dy < 0) { dy += friction; }


if ( dy > 0 and dy < .1 ) { dy = .1; }

if ( dy > -.1 and dy < 0) { dy = -.1; }


if ( scroll_this._y > lower_limit ) { scroll_this._y = upper_limit; }

if ( scroll_this._y < upper_limit ) { scroll_this._y = lower_limit; }

scroll_this._y += dy;

gotoAndPlay("loop");


Now the buttons which pull it all together are as follows.

The Up button, has the following AS:

on (rollOver) {
accel = true;
}
on (rollOut) {
accel = false;
}


The Down button has the following AS:

on (rollOver) {
decel = true;
}
on (rollOut) {
decel = false;
}


So what I have done, is taken this whole layout and all relevant Action script and incorporated it into my folio. I can understand how to change the AS so my movieclip scrolls horizontally, that is no problem. My current result is available here (note I have change the buttons to respond on 'press' and 'release', not 'roll_over' and 'roll_out'.

The problem I am having I think has something to do with the 'upper_limit' and 'lower_limit'. If you notice on my version, the movieclip that scrolls (containing all the buttons) will scroll continuosly until the user releases the mouse button. If you also notice that when the x position of the movieclip reaches a certain position it will jump backwards. What I need it to do, is when the user clicks on the left arrow button (for example) the movieclip will scroll until the far left of the movieclip is on the stage, and then it will slow down and gradually stop scrolling, not jump back and continue scrolling.

I have tweaked the AS until I can't tweak no more, and as my AS is a little rusty (to say the least) I'm not quite sure where to go. If anyone has any suggestions, or they can tweak the AS to achieve the effect I need I would be grateful. Alternatively, if anyone can point me to a tutorial on how to do this, that would be great. I have searched high and dry on all the bigger flash sites (Flashkit, Actionscript.org, Ultrashock etc) but I have only been able to find the tutorial that I have taken the original example from.

Thanks in advance everyone,
Benji