A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [F8] Character problems

  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    84

    [F8] Character problems

    How do i make my character change its form when up or down is pressed. Like i press up, he becomes another sprite and so on.

  2. #2
    Member
    Join Date
    Jun 2007
    Posts
    84
    Somebody Answer Already

  3. #3
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Easy tex, sometimes it takes longer than half an hour, we're all busy too.

    Besides your question is a little vague. What do you by change its form. You'll need to use key listeners to pay attention to the keyboard and fire off a function when the up key is pressed. but what that function is, how are we to know?

    _b

  4. #4
    Member
    Join Date
    Jun 2007
    Posts
    84
    ummm I'm kinda of an actionscript newbie so...... All i need to know is how to to make him like...That he changes his direction, looks the other way. But instead of rotating i want to draw him in that other direction. So how do i display that?

  5. #5
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    put another drawing on the second frame of his clip. put a stop() action on both frames so that it doesn't flicker back and forth. add a key listener to toggle the current frame.

    So... lets say the character's clip is called 'char'. Facing left drawing is frame one, facing right drawing is frame 2. So far so good.

    This code on the time line will listen for keyboard in put and switch the frames if the up arrow key is pressed:

    var listen:Object = new Object();
    listen.onKeyDown = function(){
    if(Key.isDown(Key.UP)){
    var targetFrame = (_root.char._currentFrame == 1)? 2 : 1;
    _root.char.gotoAndStop(targetFrame);
    }
    }
    Key.addListener(listen);

    All set.

  6. #6
    Member
    Join Date
    Jun 2007
    Posts
    84
    wow thanx. But will this work if i already have another frame for his legs moving?
    In that case i must make them switch between 1:3 not 1:2 right?

  7. #7
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    try nesting body parts in sub clips.

    so char.legs can be doing whatever they're doing, and you can use the same principle above to control char.head, or char.chest, or whatever.

  8. #8
    Member
    Join Date
    Jun 2007
    Posts
    84
    OK I put the code you said and it worked but as long as i am pressing up it keeps switching between the two frames... Why dont i just upload it and u show me how it's done?

  9. #9
    Member
    Join Date
    Jun 2007
    Posts
    84
    Nevermind, I figured out how it works. Thanx alot

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