A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to do this??

  1. #1
    Enter the Flash Dragon Prototype3X's Avatar
    Join Date
    Jul 2002
    Location
    In my Mind
    Posts
    1,107

    How to do this??

    How can I make the link buttons like on this site: http://www.greyscale.net

    You see how the buttons are all moving around a stuff. Can someone help me out on this.

    Any advice, code examples or tutorial would sure be appreciated!

  2. #2
    Junior Member
    Join Date
    Jan 2002
    Location
    Maine
    Posts
    19
    To get the random movement of a point (or any movieclip) you need to use a random number generator to increment the x and y positions. Check out the following code (attach to a movieclip):

    onClipEvent (enterframe) {
    this.yRand = 2 - Math.random()4;
    this.xRand = 2 - Math.random()4;
    this._y += this.yRand;
    this._x += this.xRand;
    }

    Note: yRand and xRand will be between -2 and 2 which will ensure that the movieclip may move in any direction.

    To get the rollover expanding effect you'd need to add a hitest or rollover operation and a bunch more actionscript with quite a few if statemnets. I don't have time to go into it now, but I may be able to get back to you later if you still need help.


    Rock on!
    Shane

  3. #3
    Enter the Flash Dragon Prototype3X's Avatar
    Join Date
    Jul 2002
    Location
    In my Mind
    Posts
    1,107
    Thanks Shane for the reply and the code.

    One question, do I put the button inside the movieclip?

  4. #4
    Junior Member
    Join Date
    Jan 2002
    Location
    Maine
    Posts
    19
    No need for a button inside the movieclip because you can just use the movieclip itself as the button. I've figured out the full code for you - just copy the code below and with your movieclip selected, paste the code in the actions panel. You may want to play with some of the values to get the exact effect that you want, but this is pretty darn close. ENJOY!

    onClipEvent (enterFrame) {
    if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
    if (this._xscale<400) {
    this._xscale += 10;
    this._yscale += 10;
    }
    } else {
    if (this._xscale>100) {
    this._xscale -= 10;
    this._yscale -= 10;
    }
    yRand = 2 - Math.random()*4;
    xRand = 2 - Math.random()*4;
    this._y += this.yRand;
    this._x += this.xRand;
    }
    }
    on (release) {
    //enter whatever action you want
    }

  5. #5
    Enter the Flash Dragon Prototype3X's Avatar
    Join Date
    Jul 2002
    Location
    In my Mind
    Posts
    1,107
    Cool... thanks Shane, I try it out and get back to you!

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