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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event handler question

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
I've built the preloader to the site I'm designing, and after it finishes I've got a gotoAndStop on the main timeline that jumps to a frame that contains a movieclip which has the instance name 'mainbox'. Inside that movieclip(which is only 1 keyframe long) I have various layers containing various movieclips which load up the homepage content.

One of these movie clips is my navbar. It's contained in a movieclip called 'menu' and each of the buttons are themselves movieclips with instance names of 'home_bt', 'gallery_bt' etc.

I'm trying to address an inline onPress function from within the 'mainbox' movieclip. I've put the actions layer as the first layer in the 'mainbox' movieclip. So to address the gallery button should be: menu.gallery_bt.onPress.

Here's my code:
Code:
stop();
menu.gallery_bt.onPress = function():Void {
	trace("event has been captured");
};

It's not working, and I'm sure there's a very simple reason for that, but being a noob I'm not sure what it is :) If someone could fill me in I'd be grateful.
 
Button has to be present on the same frame you define it's handler.
Trying to set a handler on a button that isn't on stage won't work.
Move your definition to the timeline where that button is present, or put it on the button itself, as we use to do it.

Regards. Affiliate Program - Web Hosting - Web Design
 
Thanks for the help oldnewbie. I'll try moving the actionscript when I get home tonight.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top