A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Function across frames

  1. #1
    Senior Member
    Join Date
    Sep 2002
    Posts
    160

    Function across frames

    Is there a way to make a function work across frames. What I mean is let's say I have a function that I want to make the screen scroll, but I need it to move every frame (_x--). Can I do that with a function???

  2. #2
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    If you had an object on the stage named say, BOX, you could put the following code on BOX:

    onClipEvent(enterFrame){
    this._x+=1;
    }

    This would make the object BOX move 1 pixel a frame. If your movie is set to 30 fps your BOX would have moved 30 pixels after a second.

    The same thing could be done by setting a function on Frame 1 (of a 1 frame movie) with BOX sitting on the stage:

    box.onEnterFrame=function (){
    this._x+=1;
    }

    Or you could also just make a function on Frame 1, that BOX (or any object) could call to move it:

    function moveMe(thisObj){
    thisObj._x+=1;
    }

    then on the object you would put the following code:

    onClipEvent(enterFrame){
    _parent.moveMe(this);
    }


    Maybe this answers your question?
    Antibody
    "Our deepest fear is not that we are inadequate.
    Our deepest fear is that we are powerful beyond measure." - N. Mandela

  3. #3
    Senior Member
    Join Date
    Sep 2002
    Posts
    160
    That's a good idea. I was trying to scroll my whole movie (_root). But maybe the way to go is to put my "screen" into a seperate MC and scroll that. I'll play around with it. Thanks!

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