A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: action script help

  1. #1
    Bamboozled snoop_doug's Avatar
    Join Date
    Apr 2001
    Posts
    1,278
    hi, a while ago i was given some action script that will make the alpha of a MC decrease the further away you move your mouse from it, the script is here and works fine

    onClipEvent (load) {
    w = 550/2;
    // the movie width /2
    h = 400/2;
    // the movie height /2
    maxdist = Math.sqrt((w*w)+(h*h));
    // the maximum distance that the mouse can be
    step = 100/maxdist;
    // the constant that defines the alpha stepping
    }
    onClipEvent (enterFrame) {
    // Calculate the distance of the mouse:
    x = Math.abs(this._x-_root._xmouse);
    y = Math.abs(this._y-_root._ymouse);
    dist = Math.sqrt((x*x)+(y*y));
    // Apply the alpha change:
    this._alpha = 100-(dist*step);
    }

    what i want to do is edit the script (i have no experience with action scripting) so that i can manipulate how much the alpha increases or decreases when u move your mouse away or near to the MC, if someone could tell me which bits to change in the script and what it does it would be greatfully received

  2. #2
    Ambassador of Style
    Join Date
    Feb 2001
    Posts
    597

    100

    It's based on the size of the movie. Dpending on how you want the alpha to change - you need to play with the step variable:

    step = 100/maxdist;

    And the actual alpha equation:

    this._alpha = 100-(dist*step);

    The mouse position in relation to the button is multiplied by 100 divided by the maximum distance allowed. The resulting number is taken out of 100 - giving you your alpha percentage!

    Good luck!

    -A02

  3. #3
    Bamboozled snoop_doug's Avatar
    Join Date
    Apr 2001
    Posts
    1,278
    thank you....i think

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