dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: ? about functions

  1. #1
    Junior Member
    Join Date
    Mar 2004
    Posts
    5

    ? about functions

    Someone gave me this code to make my movie "pop" move to a predefined location. It works great. My problem is that on the "pop" movie it is draggable so after I activate this function, when I drag "pop" movie. It bounces back to -64.5 How do I tell the function to stop working.



    targXpos = -64.5;

    pop.onEnterFrame = function() {
    pop._x -= (pop._x-targxpos)/10;
    };


    Thanks for the help

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    code:

    delete pop.onEnterFrame;



    is all you need I believe

  3. #3
    Junior Member
    Join Date
    Mar 2004
    Posts
    5

    Thank You

    Thank you for the help, that worked perfectly.
    Thanks

  4. #4
    Junior Member
    Join Date
    Mar 2004
    Posts
    5

    Another Question

    Once my tartXpos is reached how do I trigger another set of code to start.

    Say I reach my targXpos = -64.5;
    I want to tell another movie smt.gotoAndPlay(5);





    targXpos = -64.5;

    pop.onEnterFrame = function() {
    pop._x -= (pop._x-targxpos)/10;
    };



  5. #5
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    code:

    if(pop._x <= -64.5) {
    smt.gotoAndPlay(5);
    }


    ?

    or is it more complicated than that?

  6. #6
    Junior Member
    Join Date
    Mar 2004
    Posts
    5

    Stupid Question

    That would probably work, I just dont know where to put the code, I tried many places, but I just cant seem to find the right place. Were Do I put the code?

    Thank you very much for all your help

    ActionScript:--------------------------------------------------------------------------------if(pop._x <= -64.5) {
    smt.gotoAndPlay(5);
    }

    --------------------------------------------------------------------------------

  7. #7
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    i'm guessing you're looking for this, ease it in, then play smt
    code:

    targXpos = -64.5;
    pop.onEnterFrame = function() {
    this._x -= (this._x-targXpos)/10;
    if(this._x <= (targXpos + 2)) {
    delete this.onEnterFrame;
    smt.gotoAndPlay(5);
    }
    }



    the problem with your original easing and check is it will never actually reach -64.5. will come to -64.9999999, so to make this work practically i've added (targXpos + 2), which can be tweaked to your needs.
    Last edited by chi-styler; 03-29-2004 at 04:19 PM.

  8. #8
    Junior Member
    Join Date
    Mar 2004
    Posts
    5

    Thank You Very Much

    Thank you very much the addition of the +2 and the delete this.onEnterFrame; works great. I greatly appriciate all the help.


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