all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

Double click issue on menu navigation


Double click issue on menu navigation Tjisana
7/15/2006 7:29:23 PM
flash actionscript:
I have some buttons on my nav bar that need to remain highlighted once clicked
so users know were they are. The script works well except for the first click.
The mc changes however the button is not highliged. Ont he second click all
goes to normal.

That gives? Any help would be greatly appreciated.

Thanks,


Tjisana


stop();

var num:Number = 2;
_global.link = 0;

//Mouse RollOver function: change colour when mouse passes over button
this.onRollOver = function() {
if(_global.link != num) {
this.gotoAndStop("focus");
}
};

//Mouse or Pointer Rollout & ReleaseOutslide function: go back to original
colour
this.onRollOut = this.onReleaseOutside = function() {
if(_global.link != num) {
this.gotoAndStop("no_focus");
}
};

this.onRelease = function() {
if(_global.link != num) {
_global.link=num;
for(var i=1; i<=6; i++) {
this._parent["space" + i].gotoAndStop("1");
}
this._parent.gotoAndStop("P2");
this.gotoAndStop("focus");
}
};
Re: Double click issue on menu navigation Wolf van Ween
7/15/2006 8:19:06 PM
Re: Double click issue on menu navigation Tjisana
7/16/2006 12:00:00 AM
I set num within only in initialization of the mc. Is that where my problem lies?


Re: Double click issue on menu navigation Tjisana
7/16/2006 12:00:00 AM
In the code fot the button. I didn't think I need to initialize it elsewhere. I was banking on "var num:Number = x" woudl work fine. Am I wrong here?


Re: Double click issue on menu navigation Wolf van Ween
7/16/2006 1:38:52 PM
No, I'm not talking about initialization.
I don't know what's the role of "num", but the
if(_global.link != num)
with a subsequent
_global.link=num;
made me think, that num is supposed to be the number of the button clicked,
and that this is then stored in _global.link.

But now that I write this I realize, you probably set a different num in every
script, and you've shown us only one script here, the one of button 2, right?

Question: what sort of "button" do you have? Because the way your script is
written, it looks like a movieClip. If it isn't (i.e. if it's a Button class
button or a button component, this wouldn't work.

What I would do is to put traces into the event handlers to show which value
_global.link and num have. I smell the problem there.

Anyway, from what I assume now, all the button handlers look exactly the same
except the "P2" line, which really probably should be
this._parent.gotoAndStop("P"+num.toString());
And then I wonder, why you don't put the code above into your
button/movieClip's parent in a loop. Just to simplify later changes (putting
traces in and out, for instance)

If you want to post the whole fla I can have a look at it.

Good luck
Wolf
Re: Double click issue on menu navigation Tjisana
7/16/2006 5:08:18 PM
I see what you're saying. The buttons are really movie clips not actual
buttons. The file is at http://www.saporrestaurant.com/zips/intro.zip.

I'll put some traces in to see what I'm getting.

Thanks for reviewing it.


Tjisana
Re: Double click issue on menu navigation Tjisana
7/16/2006 6:47:59 PM
I found the problem - you were right, I was not initializing my variables in the main timeline. Once i did that, all worked dandy.

Thansk a bundle,


Tjisana
AddThis Social Bookmark Button