A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: AS re-sizing.... Need Help!!

  1. #1
    -Web Boy
    Join Date
    Jul 2001
    Location
    Olympia, Wash.
    Posts
    65

    AS re-sizing.... Need Help!!

    I have a movie clip that I would like to scale up, then down with easing, as if it were "breathing".

    But, I'd like to do it in ActionScript.

    Right now, I have this:

    The MC, called "MC" is on the main stage, with no actions.

    Inside MC, I have it split into 3 "sections", each starting with a named frame,:

    grow, shrink, and normal.

    on the "grow" frame, I have:
    code:

    targetXsize = MC.ScaleDest;
    targetYsize = MC.ScaleDest;

    Xdiff = (MC.ScaleDest-MC._xscale);
    Ydiff = (MC.ScaleDest-MC._yscale);


    with MC's actions:
    code:
    onClipEvent(load){
    ScaleDest = 100 + 10;
    }

    onClipEvent(enterFrame){
    if (_xscale < ScaleDest || _yscale < ScaleDest) {
    _xscale += Math.ceil(ScaleDest-_xscale)*.2;
    _yscale += Math.ceil(ScaleDest-_yscale)*.2;
    currScale = _xscale;
    }
    }



    And it does it a little different for the Shrink and Normal frames.

    I'm guessing there's an easier way to do this, with Actionscript

    Can anyone help out here?
    Last edited by phallex; 11-04-2003 at 07:36 PM.

  2. #2
    Senior Member
    Join Date
    Jun 2003
    Location
    Kent, WA
    Posts
    536
    Actually, I think what you're trying to do is called elasticity.

    code:

    MC._xscale = MC._yscale = 110;
    MC.onEnterFrame = function() {
    var accel = (100-this._xscale)*.1;
    this.veloc += accel;
    this._xscale = this._yscale += this.veloc;
    };



    This will spring forever around an _xscale of 100, with a minimum value of 90 and a maximum of 110.

  3. #3
    -Web Boy
    Join Date
    Jul 2001
    Location
    Olympia, Wash.
    Posts
    65
    Cool!

    Using THIS code, I got it to shrink, but that's all it does.
    code:
    onClipEvent(enterFrame){ 
    _xscale = _yscale = 110;
    accel = (100-_xscale)*.1;
    veloc += accel;
    _xscale = _yscale += veloc;
    }



    How can I get it to
    shrink>slowly stop shrinking>stop>grow>slowly stop growing>stop -- then repeat the whole process again (all in ActionScript)??


    ANYONE PLEASE HELP!!
    Last edited by phallex; 11-04-2003 at 07:35 PM.

  4. #4
    Senior Member
    Join Date
    Jun 2003
    Location
    Kent, WA
    Posts
    536
    You almost converted it to Flash 5 format correctly, except for one thing. It'll work like this:

    code:

    onClipEvent (load) {
    _xscale = _yscale=110;
    }
    onClipEvent (enterFrame) {
    accel = (100-_xscale)*.1;
    veloc += accel;
    _xscale = _yscale += veloc;
    }


  5. #5
    -Web Boy
    Join Date
    Jul 2001
    Location
    Olympia, Wash.
    Posts
    65
    Yes!!

    Excellent.... That works.


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