i have a object and it normaly facest this way --> i dont know how to make it so when you press the left arrow it flips it to face this way <-- and still be right side up please help
stick this code in the object:
onClipEvent (keyUp) {
if (Key.getCode() == Key.LEFT) {
this._xscale = -this._xscale;
}
}
with this code, every time you hit the left key, it’ll flip directions.
try this code:
[AS]myMovieClip.onEnterFrame = function() {
this._xscale = Key.isDown(Key.LEFT) ? -100 : Key.isDown(Key.RIGHT) ? 100 : this._xscale;
};[/AS]
it checks if the left oar right key is down and if it is it changes the movie clips x scale to -100 if i’s the left key and to 100 if it’s the right key. if no key is pressed, the xscale remains the same. to flip an object, just change the xscale to -100
dang it. someone always gets to it before i do
more help is better than no help
you can always multply by -1 too.
this._xscale *= -1;
yeah but if you press the left key twice it will flip twice…
thanks guys im sort of new to flash so i dont know but is there a way so if i press left again it dosent flip again like it will still face left
[AS]myMC.onEnterFrame = function () {
if (Key.isDown(Key.LEFT)) {
this._xscale = -100;
}
}[/AS]
Originally posted by zylum
myMovieClip.onEnterFrame = function() {
this._xscale = Key.isDown(Key.LEFT) ? -100 : Key.isDown(Key.RIGHT) ? 100 : this._xscale;
};
myMovieClip.onKeyDown = function() {
this._xscale = (Key.isDown(39)-Key.isDown(37))*100;
};
Key.addListener(myMovieClip);
ignore me… i just wanted to post something stupid.
hey, that’s pretty nifty. now we’re getting into boolean:)
you know… expanding the horizon.