A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Function question

  1. #1
    Member
    Join Date
    Apr 2008
    Posts
    30

    Function question

    I'm new to actionscript and I'm trying to make a movie clip walk across the stage but it's just standing still. I'm trying to put the command to walk right, across the stage in a function, but when I run the function it just stands still. I'm using flash cs3 actionscript 3.0. here's the script:

    var spRight = new WalkRight();
    spRight.x = 100;
    spRight.y = 200;
    addChild(spRight);


    var walkSpeed:int = 10;
    function walkR():void
    {


    spRight.x += walkSpeed;
    if (spRight.currentFrame == 5)
    {
    spRight.gotoAndStop(1);
    } else
    {
    spRight.gotoAndStop(spRight.currentFrame+1);
    }
    }

    walkR();

    If anyone knows what I'm doing wrong I'd apprectiate any help thanks

  2. #2
    Senior Member Computer Dork's Avatar
    Join Date
    Mar 2001
    Location
    St. Louis
    Posts
    1,026
    You are only running the function once... and you are basically telling it to move 10 pixels to the right. What you'll probably want to do is set up an 'endpoint' where you don't want the mc to move past, hook up a timer to call the function at a set interval that you write until the spRight is at the point you want it to stop.

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