A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] _xscale

  1. #1
    Likes To Press Big Red Buttons
    Join Date
    Jun 2007
    Posts
    31

    [F8] _xscale

    I have made it so when you turn left and right on the side scrolling game thing that the sprite turns left and right as well using _xscale= -40/40
    but whenever I turn what happens is it jumps.
    e.g ______0-9______ but instead of going to ______9-0______ the other way round, it goes to __9-0__________ on the other side of the screen. can anyone help? code is:

    if (Key.isDown(Key.Left)){
    this._x -=11
    _xscale =-40
    }
    if (Key.isDown(Key.Right)){
    this._x +=11
    _xscale =40
    }

  2. #2
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Change to capital letters: LEFT, and RIGHT.
    instead of this use a movieclip name: mc.
    Enter movieclip name as mc in properties box.
    Code:
    mc.onEnterFrame=function(){
    if (Key.isDown(Key.LEFT)){
    mc._x -=11;
    mc._xscale =-40;
    }
    if (Key.isDown(Key.RIGHT)){
    mc._x +=11;
    mc._xscale =40;
    }
    }
    Last edited by Eager Beaver; 06-29-2007 at 08:58 AM.
    <signature removed by admin>

  3. #3
    Likes To Press Big Red Buttons
    Join Date
    Jun 2007
    Posts
    31
    I think I should of made it clearer. I put the code on the movie clip andalso have put capital letters etc. but I want to know how to make it flip on the spot, instead of moving and flipping.

  4. #4
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Try this code:
    Code:
    onClipEvent(load){
    scale=40;
    this._xscale=scale;
    }
    onClipEvent(enterFrame){
    if (Key.isDown(Key.LEFT)){
    this._x -=11;
    this._rotation=180;
    }
    if (Key.isDown(Key.RIGHT)){
    this._x +=11;
    this._rotation=0;
    }
    }
    <signature removed by admin>

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    If the character moves when you flip the scale, it's probably that you don't have the center point of the movie clip in the center of the character. You may want to check that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center