Flip Horizontal a Movie

  • masster
  • Newbie
  • Newbie
  • masster
  • Posts: 6

Post 3+ Months Ago

Hi,

Is it possible to flip horizontal an instance of a movie by Action Script?

That would solve me a lot of issues.

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Code: [ Select ]
clipInstanceName._xscale *= -1


clipInstanceName being the instance name assigned to your movieclip symbol.

_xscale being the property of a clip that resizes it's width according to a percentage (default is obviously 100%)

*= -1 takes the current _xscale value (again, default is 100) and multiplies it by 1 (thus created -100), which then flips the clip horizontally.
  • masster
  • Newbie
  • Newbie
  • masster
  • Posts: 6

Post 3+ Months Ago

Cool!

:oops: So simple, yet so powerful... :)
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

that's the beauty of actionScript :)
  • partyjan
  • Student
  • Student
  • partyjan
  • Posts: 69
  • Loc: Norway

Post 3+ Months Ago

I have an animation of a fish that will swim back and forward. And when I type left I want hime to flip horizontal. And with this code it did, but the problem is that it does flip horizontal everytime I press the left key.

I want "the fish" to flip ones, and flip again when I flip right and then he may flip again when I THEN PRESS LEFT...

hope you somebody understands my problem. Thanks!


KeyListener1.onKeyDown = function () {
if (Key.isDown(Key.LEFT)){
Xhastighet--;
break;
fisk._xscale *= -1;
}
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

Code: [ Select ]
KeyListener1.onKeyDown = function ()
{
  if (Key.isDown(Key.LEFT))
 {
   Xhastighet--;
   break;
   if (fisk._xscale < 0)
       fisk._xscale *= -1;
}
  1. KeyListener1.onKeyDown = function ()
  2. {
  3.   if (Key.isDown(Key.LEFT))
  4.  {
  5.    Xhastighet--;
  6.    break;
  7.    if (fisk._xscale < 0)
  8.        fisk._xscale *= -1;
  9. }

if default the fish is with his head toward left, then leave this code as it is.
if is hea toward right then the condition will be:
Code: [ Select ]
if (fisk._xscale > 0)
fisk._xscale *= -1;
  1. if (fisk._xscale > 0)
  2. fisk._xscale *= -1;
  • partyjan
  • Student
  • Student
  • partyjan
  • Posts: 69
  • Loc: Norway

Post 3+ Months Ago

I used that code on

(Key.isDown(Key.RIGHT))

too, and it work prfectly as I wanted:)

thanks!
  • pns
  • Born
  • Born
  • pns
  • Posts: 1

Post 3+ Months Ago

็Hi,
I'm a newbie and know very little about AS, so I get confused what 'KeyLintener1' and 'Xhastighet--' refer to. Could you be so kind as to give additional explanation, please?
Looking forward to you kind help.
High regards,
PNS
  • noordhoeka
  • Born
  • Born
  • noordhoeka
  • Posts: 1

Post 3+ Months Ago

Hi
I have the same type of issue, except I have my movie clip following a mouse rather than using keys.

The fish is facing right, how would I get the fish to face left when the mouse is to the left of the fish?

onClipEvent (enterFrame) {
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/5);
_root.xMove = Math.round(_root.xChange/5);
this._y += _root.yMove;
this._x += _root.xMove;
}

thanks
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

mmm, you guys should learn how to use what you know, extend it and use your logic to apply it for your current situation.
In your case is basically the same.
Code: [ Select ]
// if mouse in left side (xMouse < this.x)
if (_root.xMove < 0)
{
 if (this._xscale < 0) // if not already flipped
  this._xscale *= -1;
}
else // if mouse in right side (xMouse > this.x)
{
 if (this._xscale > 0) // if not already flipped
  this._xscale *= -1;
}
  1. // if mouse in left side (xMouse < this.x)
  2. if (_root.xMove < 0)
  3. {
  4.  if (this._xscale < 0) // if not already flipped
  5.   this._xscale *= -1;
  6. }
  7. else // if mouse in right side (xMouse > this.x)
  8. {
  9.  if (this._xscale > 0) // if not already flipped
  10.   this._xscale *= -1;
  11. }

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.