Ok I make a button and coded it with onRelease and keypress.
The button works fine on its release, but the onKeyPress for <Enter> will not work. WTF?
I've read rumors that onKeyPress coding doesnt work in actionscript 2.0. Is that true?
Printable View
Ok I make a button and coded it with onRelease and keypress.
The button works fine on its release, but the onKeyPress for <Enter> will not work. WTF?
I've read rumors that onKeyPress coding doesnt work in actionscript 2.0. Is that true?
onKeyPress may not, but onKeyDown sure does!
Here's what I did:
I made a circle on my stage & converted to a movie clip & gave it the Instance Name - circ
Then I made a new layer & typed this code into frame 1 (on the main timeline) :
So, clicking on it with the mouse will expand it's _xscale to 200%, & pressing SpaceBar will shrink it back to 100%. I used SpaceBar instead of Enter because when viewing in Flash's preview player "Enter" has other functions & wouldn't do what I wanted it to do, though if viewing in an HTML page "Enter" would be fine, so you can swap the word "SPACE" with the word "ENTER".Code:circ.onPress = function () {
this._xscale = 200;
}
var keyLis:Object = new Object();
keyLis.onKeyDown = function () {
if (Key.getCode() == Key.SPACE) {
circ._xscale = 100;
}
}
Key.addListener(keyLis);
Why the expanding and contracting?
I'm sorry I'm pretty new to actionscript.
No worries :) - you didn't specify what action the button performed, so I just chose one at random. In place of those _xscale actions, put whatever action you want to perform, for example :
Code:circ.onPress = function () {
getURL('http://www.flashkit.com/');
}
var keyLis:Object = new Object();
keyLis.onKeyDown = function () {
if (Key.getCode() == Key.SPACE) {
getURL('http://www.google.com/');
}
}
Key.addListener(keyLis);
Oh geez! That makes so much sense!
I probably would have been able to figure that out if my head wasn't stuck in my computer.
Thank you very much:)
Very welcome :)
Head stuck in computer, eh? Do you need me to call an ambulance?
:P
No the end of the day is almost here.
That should be the cure.
Ok nevermind. The end is never coming.
So I have a movie that that loads in one scene via netConnection. When I move to another scene in the movie the audio keeps playing.
Should I use some sort of clipEvent to solve this?
I heard long ago that Scenes were bad, so I never used them, & thus I don't have any experience with their nuances.
stopAllSounds(); may work, but you could also close the netStream by using :
yourStream.close();
Scenes are bad. Terrible. You can correctly code for buttons and scene changes, and Flash just picks what scene it find suitable.
I'm not quite savvy enough to put this whole movie in one scene. I'm working on it.
Your replies are so speedy. Thanks so much.
Did either of those options work for killing the sound?
If you wanted to send me your .fla, I might be able to help you get it all into one scene.
"Best Practices" says that code should be in a central location. Here's a quote I found a while back from Bill Perry of Macromedia:
Quote:
“I throw a flash movie away if I don’t find the actions layer. Instead, actions in this file have been written in bits in more than 20 places!”