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

flash actionscript

group:

Clip Event help targeting two movies


Clip Event help targeting two movies cgulotta
10/26/2005 10:23:14 PM
flash actionscript: I have two movie clips that I want to target separately on keystrokes. I was
able to target one with the below script. HOw do I add the second one.

onClipEvent(enterFrame){
if(Key.isDown(Key.ENTER)){
_root.myMCinstance.nextFrame()
}
}

I want the second movie clip to be triggered on the Spacebar key. Once I
complete this process I want to be able to ENTER and play movie clip 1 and hit
SPACE and play movie clip 2. Any help would be appreciated. I'm new to Flash
so
any instruction will help!

Thanks --chr
Re: Clip Event help targeting two movies kglad
10/26/2005 11:31:56 PM
onClipEvent(enterFrame){
if(Key.isDown(Key.ENTER)){
_root.myMCinstance.nextFrame()
} else if(Key.isDown(Key.SPACE)){
_root.myMCinstance2.nextFrame()
}
Re: Clip Event help targeting two movies cgulotta
10/26/2005 11:47:53 PM
I guess I should have figured that out but now here's where I am confused.
Once I have these two movie clips and I place them on the stage, I don't
necessarily want them to be visible until the key is pressed. Previously when
I had one movie clip with this action assigned, I attached the script to the
movie clip. Should I attach it to a separate actions layer in the main stage?
I'll play with this until I figure it out but i'm still a bit confused as to
why they are both visible.

--thanks christina
Re: Clip Event help targeting two movies kglad
10/27/2005 12:00:00 AM
a movieclip doesn't have to be _visible for it's clipevent to continue. the
movieclip just has to continue to exist. that code should only be attached to
one movieclip:


onClipEvent(enterFrame){
if(Key.isDown(Key.ENTER)){
_root.myMCinstance.nextFrame()
_root.myMCinstance._visible=1;
_root.myMCinstance2._visible=0;
} else if(Key.isDown(Key.SPACE)){
_root.myMCinstance2.nextFrame()
_root.myMCinstance._visible=0;
_root.myMCinstance2._visible=1;
}
}


Re: Clip Event help targeting two movies cgulotta
10/27/2005 12:00:00 AM
I entered my script just as you mentioned. Here is my dilemma. I'm simulating
a web search for a TV series. I have a desktop background image that is static
in the timeline. when i test the movie i want to click the enter key and see
the first webpage and then click space and the second site appears. Right now
when I test the movie the first site is the first image visible and then the
spacebar triggers the desktop image to appear. Does this extra image
complicate things? Your help so far has been excellent and I'm definitely
learning more each time but there are not enough hours in the day for my boss's
constant changes.

Re: Clip Event help targeting two movies kglad
10/27/2005 12:00:00 AM
when your swf starts you want your desktop to be visible but not myMCinstance
and not myMCinstance2? if so, use:

onClipEvent(load){
_root.myMCinstance._visible=0;
_root.myMCinstance2._visible=0;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.ENTER)){
_root.myMCinstance.nextFrame()
_root.myMCinstance._visible=1;
_root.myMCinstance2._visible=0;
} else if(Key.isDown(Key.SPACE)){
_root.myMCinstance2.nextFrame()
_root.myMCinstance._visible=0;
_root.myMCinstance2._visible=1;
}
}
Re: Clip Event help targeting two movies cgulotta
10/28/2005 6:16:59 PM
Thank you for your help. This was the magic formula.

IT's also helped me go a little further since I now understand. Everyone is happy!

AddThis Social Bookmark Button