A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Making a button dissapear and reappear in random places

  1. #1
    Member
    Join Date
    Jan 2005
    Posts
    60

    Making a button dissapear and reappear in random places

    How would I go about doing this?

    That is something like...
    If I click a button, it reappears somewhere else.

    EDIT: I was just thinking... couldn't the code be something similar to... (the code setup will be wrong because I am very inexperenced with actionscript, been using it for like 2-3 days).

    on{release}
    button.visible=false
    duplicatemovieclip(I don't know this command yet) at random x and y coordinates

    Help please.
    Last edited by [username here]; 01-28-2005 at 10:24 PM.

  2. #2
    Member
    Join Date
    Jan 2005
    Posts
    60
    File attachment.
    Attached Files Attached Files

  3. #3
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Give your button an instance name (I used btn here) then in the frame that contains the button add the actionscript,

    code:

    btn.onPress = function() {
    this._x = Math.round(Math.random() * (500 - this._width));
    this._y = Math.round(Math.random() * (400 - this._height));
    };



    where 500 is the width of your stage and 400 is the height of your statge. This assumes that the button was created with its registration point at its top left corner (so positioning the button at the point (0, 0) would place the button with its top left corner exactly on at the top left corner of your movie)

  4. #4
    Member
    Join Date
    Jan 2005
    Posts
    60
    Hmm... it seems not to work... Though I still have a question... HOW did you do this....

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    File attached...
    Attached Files Attached Files

  6. #6
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I notice from another thread you say you use flash 5. here's a flash 5 version.

    in this file the button is contained inside a movie clip. when the button is pressed it moves the clip around.
    Attached Files Attached Files

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