Need help with key problem

basically what i want is to make one picture change to another picture when the enter key is pressed. then i want it to change back when the enter key is released. don’t want to use a mouse click to do this so a button isn’t what i need. can anyone help?

thanks in advance:q:

Alrighty, You will have to make a movie clip symbol.

And inside that symbol is two frames, both with a stop() action on them.

In frame one is the original image, and in frame two will be the image you want to get to when the enter button is pressed.

Now you will return to the _root timeline and right click on your movie clip, then open the actions panel.

Apply these actions

onClipEvent (enterFrame) {
	if (Key.isDown(Key.ENTER)) {
		this.gotoAndStop(2);
	} else {
		this.gotoAndStop(1);
	}
}

This will check if the key that is being pressed down is the enter button, then it will gotoAndStop at frame 2, which will be your image when the button is pressed. The else statement states that if the enter button is not pressed, or any other button is being pressed, the movie clip will say on Frame 1, the original image.

be aware that ENTER in the flash authoring environment, when previewing a movie means Play (see the control menu). To see how it would accurately play, open the swf outside of flash to test

It works in preview mode too.

it all depends on how your movie is set up. The ENTER is recognized, but if you are stopped on a single frame in _root where this clip exists, using ENTER will make _root play, and unless that clip continues to exist outside of that frame for the following frames which are now being played in _root, you’ll lose it.

I wasnt trying to prove you wrong lost :slight_smile: it was just a precaution

Yeah uh huh, sure you weren’t trying to prove me wrong :wink:

*Originally posted by lostinbeta *
**Yeah uh huh, sure you weren’t trying to prove me wrong :wink: **

^ that is wrong though…

WRONG WRONG WRONG!

:beam:

lol :chinaman: (<~that smiley is more disturbing than your footer)

:wink:

hate to break you two up :wink:
but how about if i want the enter key to also play a mp3 sound to go along with the action? how would i set that up? thanks again

You can do it through AS, but that always messes with preloaders, so to save trouble…

Import the sound into Flash.

Go into your movie clip, click on frame 2, then drag an instance of your sound from the library onto the stage.

That way every time that frame is entered the sound will play.

Sure its not the best of ways, but it’s the easiest and it works :wink:

PS: And maybe a stopAllSounds() action on the first frame too.

Senocular will protest my method so… you will no doubt have two methods (most likely his will be through AS).

I completely agree

easy, effective and great

:!: :!: :!:

:geek:

::faints::

Are you just saying that to shut me up???

I learn a lot when you prove me wrong ya know, so I never get mad, I just like to challenge it for the hell of it :wink:

no seriously

its the best way, given the situation, to accomplish the task.

it prevents any need to link the file which would cause it to be exported early in the movie (possibly messing with preloaders as you pointed out) and runs completely fine without the need of any potentially confusing code. Afterall the gotoAndStop example wasnt exactly brain surgery which would lead us to believe that diseased013 is a novice in terms of AS coding which makes the ease of this method more than favorable.

And luckily, depsite the posibility of a repetitious nuisance via keyboard key itteration (and therefor frame itteration) the nature of the 2 framed clip and gotoAndStop prevents that from occuring.

I actually applaud lostinbeta because I probably would have suggested something scripted :wink:

WOOOOOOOWWWW!!!

It actually means a lot that you agree with me here. I still consider myself a novice in Flash (approx 7 months, 6 with AS) and tend to go about doing things the hard way (in case you haven’t noticed), but I think I am catching on.

One day I aspire to be a strong coder, but that day is far away, I can tell.

*Originally posted by lostinbeta *
I still consider myself a novice in Flash

thats such BS :wink: you know you’re definitely one of the more knowledgeable people in this forum (at least I think so)

Well yeah, but there are mostly newbies in this forum too though, so it is easier to be more knowledgable :wink:

I still think I am ahead of some other people that have been using Flash for the same amount of time, but there are also people that know much more than I in the same amount of time.

I guess it depends on the speed you learn at, I am a fast learner, but take my time experimenting with what I learn before I move on.

But whatever, the problem here has been solved :wink:

hmm. that didn’t work. here’s the deal. what i’m working on is basically a game. i have background music that IS playing so stopAllSounds on frame 1 will stop the music from playing. placing the effect sound on frame 2 didn’t change anything. it still doesn’t play when enter is pressed. any ideas what could be wrong?

whooooaaa. heh nevermind. we figured it out. needed to put it on a new layer. alright new question. how can i change the title bar in the player to read something other than “Flash Player 6.0”?

and for the record. i’m not a “newbie” :slight_smile: just haven’t messed with flash since like version 3

alright we have the sound going…but we can’t stop the sound from overlapping when you hold down the Enter key, and using stopAllSounds, as said earlier, will stop the music. any ideas

Glad you got it to work.

I don’t know how to manipulate anything with the standalone player, I never use it (for presentations at least), so I never tried it.

And last but not least, no one said you were a newbie, I stated that the board was filled with newbies (since this is a tutorial site for starters in Flash and all) and Senocular stated that you might have been a novice (step up from newbie) with AS. And being you said you haven’t messed with Flash much since version 3, I think I am going to assume the same thing since the AS scheme has changed incredibly with MX since version 3.