Flash Q simple button function
- Started
- Last post
- 5 Responses
- CyBrainX
I try to use frame scripts whenever possible for buttons:
this.movieClip_mc.another_mc.my... = function () {
trace ("onRelease called");
};but it seems this won't work if my_btn isn't on the timeline yet.
Is this true?
- enjine0
yes
- unfittoprint0
you're trying to add a button event function from a _parent movieclip.
1of2 things:
#1 if you're attaching an mc, methods, properties and instances are not immediatelly accessible [a small interval delay, ie. 100ms, may be necessary].
#2 if the instance doesn't exist immediatelly in the child's timeline you can't, obviously, target it.
personally I prefer to add button events in the same timeline where the mc/button resides.
- davi-t0
Yep, the scope of the movieclip starts when it enters a frame, it also ends when the clip is deleted or when the parent clip is removed.
An option is to put the clip in the first frame and then put it off screen or set the _visible property to false.
Davi-t
- CyBrainX0
Thanks unfittoprint. This makes total sense, but it doesn't seem all that practical to me to put these button scripts on a timeline if it's not in frame 1 of _root.
Just a matter of preference. I'll go back to putting scripts on buttons where they will be easy to find.
- unfittoprint0
Cy, I totally agree.
1 frame action layer is [usually] all I have inside any instance.
And if one can control other instances from that same one layer, the better [wich I think it's your case] => centralized scripting => better debugging.