Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looping items on a scrolling menu 2

Status
Not open for further replies.

NormRC

Programmer
Dec 5, 2001
2
0
0
GB
Hi
I have just started using action script in flash and have started creating my own menu system. I have got menu buttons scrolling from left to right but i would like them to loop back round to the begining when the menu reaches the last button? Any ideas?

Also It would be great if i could get the menu button to enlarge when its in the centre of the screen (to imply that this is the button about to be selected) I can do it using the mouse over event but I would like it to be triggered automatically. Again any ideas would be gratefully recieved.

Thanks in advance

Norm
 
Here's my version of something similar, the menu items scroll depending on the mouse position and zoom if you click and hold on them:


...it's for a client so I can't post the fla but the scrolling code works on this principle:

speed = 2
for (i=1; i<=clips; i++) {
clip = _root[&quot;menu&quot;+i];
// wrap menus if they leave the screen
if (clip._x<0) {
clip._x += screenSize;
} else if (clip._x>screenSize) {
clip._x -= screenSize;
}
clip._x += speed;
}


Change the variables to suit your movie and it should do the job. The actual code in the example is a bit more complex but this will give the same effect.

To rescale when it approaches the centre try...

clip._xscale=100-(Math.abs(clip._x-275)/5);
clip._yscale=clip._xscale;

...which will gradually shift the scale for the whole journey across the screen or...

if(clip._x>250 && clip._x<300){
clip._xscale+=20;
clip._yscale=clip._xscale;
}


..which will jump size suddenly in the middle of the screen. Both scripts assume that the screen is 550 pixels wide.
 
Wangbar,

That is a cool little script. I am trying to make an image scale larger on mousedown, also. No scrolling or anything. I figure the script needed to do that looks like the one you posted but I can't make it work. I tried making the image a movie clip, named it clip, and pasted the script. What steps am I forgetting?
 
Just attach these clip events directly to the mc you want to resize:


onClipEvent (load) {
default = _xscale;
}
onClipEvent (enterFrame) {
if (Key.isDown(1) && this.hitTest(_root._xmouse, _root._ymouse, false)) {
_xscale++;
_yscale++;
} else if (_xscale>default) {
_xscale--;
_yscale--;
}
}
 
That was exactly what I wanted and it worked perfectly!!!

Thank you
 
nice work wangbar,

I also had made such a menu on a website but yours is much more to the point.
regards, goaganesha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top