A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS Directions

  1. #1
    It's not 1997 ?! mrgrim333's Avatar
    Join Date
    Feb 2004
    Posts
    254

    Question AS Directions

    Ok, how would I go about making a character face left or right using actionscript?

    I want to use the same frame sequence for both.
    Man, I need a new signature.

  2. #2
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Code:
    onEnterFrame = function() {
    getKeys();
    }
    
    function getKeys() {
    if(Key.isDown(Key.RIGHT)) {
    char._xscale = 100;
    char._x += 5;
    } else if (Key.isDown(Key.LEFT)) {
    char._xscale = -100;
    char._x -= 5;
    }
    }
    That's assuming your animation is facing to the right by default. If it is the reverse, swap "100" and "-100", and also swap "+=" and "-=".
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #3
    It's not 1997 ?! mrgrim333's Avatar
    Join Date
    Feb 2004
    Posts
    254
    That works for the foundation of what I'm trying to do, but as far as fine tuning goes, the transition is a bit rough.
    Man, I need a new signature.

  4. #4
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    You'll need to elaborate. You have a turning animation where the player turns from facing one direction and faces the other? If that's the case, yeah, it's a bit lacking. You really need to be less vague about specifically what you're trying to do before you get to the askin' part.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

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