• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Flash MX 2004 - event listener and buttons howto?

Schrodinger

Golden Member
I have two layers: 'actions' and 'display' both 1 frame long

On the 'display' layer I have a button component, buttonFooBar
In the 'action' layer actionscript, I added:

lo = new Object();
lo.click = function(evt){
trace("TESTING 1 2 3...");
}
buttonFooBar.addEventListener("click", lo);

And it doesnt output when I click! (I open the output dialog when I run the movie)


same goes for:

function click(evt){
trace("TESTING 1 2 3...");
}
buttonFooBar.addEventListener("click", this);


I don't know what I'm doing wrong. I tried even doing _root. and root. before the button name.addEventListener

Any ideas? Its probably something simple and stupid but I can't see it for the life of me.

Keep in mind this code to add the event listener is in the 'actions' layer and the button is on another ('display')


thanks for lookin 🙂
 
i dont see anything wrong with your code...are you absolutely sure you named the button that same in the properties panel?
The first one you did is the proper way to get a button component (using a listener oject). If you look in the help under button component and "click" event thats your code prettymuch.
The layer thing shouldnt have any effect...so long as the code is in the actions layer and not on the button it should work.
 
Yep I made sure, deleted the code and copy/pasted exactly as was too!

really weird

perhaps I should try another button type or would that matter? (im using component button)



I realize the problem is me and not Flash. Just trying to figure out WHERE though.

My eyes are sore (I've been busy all week, tired as heck) and I can't -see- anything visibly wrong. I even tried to change it from click to release.
 
By the way, the add listener code is in the "action" script box for the first layer (named:actions)

not in the 'display' layer nor in the buttons action script box.


Must it be set in another spot? I thought the button was globally accessible from the other layer's action script..
 
Back
Top