all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

Button nested in Movie Clip does not work


Re: Button nested in Movie Clip does not work Byron Canfield
4/15/2005 10:17:59 PM
flash actionscript:
Don't use "mouseDown" as your event -- that particular event makes no
distinction where the click occurs, only THAT it occurs. Instead, use either
on(press) or on(release).

--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com

Re: Button nested in Movie Clip does not work physix2
4/16/2005 12:00:00 AM
nope... still didn't work.

must all frame labels start with an underscore? that could be the problem.

but i have 3 dif't books (Foundatino Actionscript, OOP with Actionscript,
and Flash MX Advanced Actionscript) and they all say the same thing
almost verbatim:

create a function for the keypress for both the movie clip and it's nested
button and put it in the _root timeline's frame script...

so, this is what i have, now, in the first frame of the main timeline:

movieClip.onRelease = function() {
this.gotoAndStop("start");
}
movieClip.myBtn.onPress = function() {
movieClip.gotoAndStop("text");
}


this is verbatim of the books... even changed all
my instance names to make sure...

nope ... no go.

even did the Flash 5 work around (hitTest)
and nope... no go.

anyone have any ideas what i might be doing wrong?

Button nested in Movie Clip does not work physix2
4/16/2005 12:00:00 AM
Ok.

So, in the _root level, i have a movieclip.

you press on the movieclip and it goes to
frame 2 which starts some animation.
after the animation is done, there are
two buttons that allow you to navigate
along the movieclip's timeline.

but, when i click on ANY of the buttons, in
fact, when i click ANYWHERE on the
screen when testing it, it goes back to
the starting point of the movie clip's timeline.


so, here's my code:

in the root timeline, the code on the movieclip (named "club") is:


onClipEvent (mouseDown) {
this.gotoAndPlay ("2");
}

so then in the movieclip's timeline, there's a stop(); on the first frame,
and the frame 2 starts the animation. it goes until about frame 10, where
there's another stop(); on frame 10.

there are now 2 buttons on the screen. on each button, is the
following code:

on (press) {
club.gotoAndPlay("a");
}

if i take the buttons OUTSIDE of the movieclip and put
them on the main timeline, they work fine.

hell, i can even put the flash object in director and
have a button in director navigate within the
flash movieclip...

but nested inside the movie clip is the problem.

i'm assuming i might need to do something with a
mouse listener?? like maybe, have it set to true
for the movieclip, and then something like the mouse
PRESS starting the movieclip's animation and then
the RELEASE setting the listerner to FALSE... that
way, when there's a mouseclick INSIDE the movieclip,
the movieclip's event handler won't be listening...

does that sound about right??

how do i do that???

i am not that great of a programmer and cannt
understand the gobbledyguck that is the actionscript
help/documentation.

any help you guys can give would be awesomely awesome!


thanks!

Re: Button nested in Movie Clip does not work physix2
4/16/2005 12:00:00 AM
just a reminder, i want the button in the movieclip to control the timeline of the movieclip... not the _root level.

thanks!

:)
Re: Button nested in Movie Clip does not work Byron Canfield
4/16/2005 10:49:02 AM
Well if you used both of those button event handlers, only the one applied
to "movieClip" is going to work because it captures the mouse event before
it can reach the nested button event handler. Also, any button event
handlers applied in this fashion require that the object being targeted
actually exist on the timeline when the function is defined, that is, if you
define the function on the first frame, but "movieClip" doesn't appear on
the timeline until frame 2, there will be no button event handler function
for "movieClip", as you will have applied to the function to something that
doesn't exist, thereby rendering it undefined.

--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com

[quoted text, click to view]

Re: Button nested in Movie Clip does not work physix2
4/18/2005 12:00:00 AM
well.. shouldn't i be able to turn off the listener for the original movie clip's event handler?


i mean, how could anyone make truly intensive programs if you
were limited to 1 level...?
Re: Button nested in Movie Clip does not work physix2
4/18/2005 12:00:00 AM
ok, guys...

here's the file... maybe this will make it easier for you to help.

www.brandonkaye.net/container.fla



the movie clip is in the first frame of the _root timeline.

when you click on it, it goes to frame 2
of it's own timeline.

THAT'S when the button nested INSIDE the movie
clip resides. WHen you click on that, it is SUPPOSED
to jump to frame labelled _text in the timeline
belonging to _root.movieclip.

now, i've included both the FRAME SCRIPTS and
the actual BUTTON SCRIPTS that I used so you
can see both ways that i did it.

this isn't the actual project.. but, because i have
movieclips and buttons and animation nested
within movieclips, i HAVE to be able to access
the event handlers no matter how deep i go
(so far, 3 levels).


thanks.

Re: Button nested in Movie Clip does not work Parul Makwana
4/18/2005 12:00:00 AM
Hi,

Have seen your file .....
The action on your main timeline is this.

movieClip.onRelease = function() {
this.gotoAndStop("_start");
}

Now this action is over written by all the actions(actions on button) tht you
put inside this movieClip.

Remove this code and try this.....

You have a circle in side movieClip. Make this circle as button and out this
action on it.
on(press){
_root.movieClip.gotoAndPlay("_start");
}

Also Remove the code that is on the second frame of movieClip.
Just keep the stop(); action

Now the action on your other button should work.


Re: Button nested in Movie Clip does not work physix2
4/18/2005 12:00:00 AM
thanks for all your help thus far, guys...

your response however, sends me back to my original problem...

when i'm IN the movieclip, ANY keypress is picked
up by the movieclip's event handler... so it executes
whatever i told the keypress to do for the movieclip.

so, i told the movieclip "hey when someone presses you,
go IN YOUR TIMELINE to frame 2."

and when that happens, a button appears. What you
told me to do was exactly what i had did originally. but
when you try and press that button, flash STILL detects
the keypress for the movieclip, and it says "ok, i need
to go to the movieclips timeline and go to frame 2"
which means that when you press the button in the movieclip,
the movieclip's event handler makes it, in essence, seem
like it's doing nothing.

try it.


Re: Button nested in Movie Clip does not work Byron Canfield
4/19/2005 12:10:38 AM
What if you also included, in the event handler for the parent movieclip (in
addition to the go to frame 2), a:

this.enabled = false

And on the first frame of that same movieclip (so that if it returns to
frame 1, it is re-enabled):

this.enabled = true;


--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com

Re: Button nested in Movie Clip does not work physix2
4/20/2005 12:00:00 AM
is that the exact wording that i'd use?

this.enabled=true;

?

i had an idea about doign that with a listener... but i can't seem to get that right.

i'll try this.

thanks!

Re: Button nested in Movie Clip does not work physix2
4/21/2005 12:56:59 AM
nope.


didn't work.


any other suggestions, anyone?

i'm at a loss and about to give up.
Re: Button nested in Movie Clip does not work Byron Canfield
4/21/2005 10:15:03 AM
If it doesn't work, then there must be some information you've left out.

--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com

Re: Button nested in Movie Clip does not work shellshock
4/21/2005 7:07:05 PM
you would need to destroy the event handler for the movie clip after it is used
, you cant have overlapoping hit areas in the same frame the top level will
always hide the one under it. A simpler way is using an invisable button in the
movie clip that is only 1 frame long (Isn't there after first frame) that way
it just isnt there in the folowing frames to get in the way
AddThis Social Bookmark Button