A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: random button placement

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Posts
    263

    random button placement

    I have an array of buttons,that I shuffle I am then trying to place them in my button grid randomly.I tried using a for loop but just can't get it right.


    button1 button2 button3 button4
    button5 button6 button7 button8
    button9 button10 button11 button12
    button13 button14 button 15

    I have attached a .fla in flash 8 to help visualize this problem.

    Thanks
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Posts
    263
    Anyone, Please.

    Thanks

  3. #3
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831

    Random Button Placement!

    Hello there,

    I have worked in your FLa and made the buttons to randomize their positions! I have attached the Fla here (Flash 8 format).

    You may check the code and if you are not able to understand it then you may put some traces and try to understand it....I have added my comments on the code:

    Logic I used:
    1. Record _x and _y positions of all the buttons in array
    2. Create a temproray array which will hold numbers from 1 to 15
    3. Randomize this array
    4. As per the randomized array replace all the buttons with the co-ordinates recorded earlier

    Once you see the code and read above description you will understand teh thing!

    Hope this helps!
    Last edited by vinayak.kadam; 05-25-2011 at 08:14 AM.
    As ever,
    Vinayak Kadam

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Posts
    263
    Yes it is what I was looking for.

    Thanks.

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