A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [CS3] Random Positioning

  1. #1

    [CS3] Random Positioning

    Is there a simple way to randomly position buttons on a stage. I have a 1024x768 project and would like to insert several (i.e. 3 or 4) "Easter eggs" (buttons with a blank first frame) that randomly position themselves every time the file is accessed. Is there a simple way to do this? TIA.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    you'll need a function to return random numbers for the _x and _y position. Check the Math.random() method. Function in example in that link.

    gparis

  3. #3
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    yourButton.x = stage.stageWidth * Math.random();
    yourButton.y = stage.stageHeight * Math.random();



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    PlenaryCreation, AS3 answers should be posted in the AS3 forum, unless the user specifies he's using AS3, which would anyway, put him in the wrong forum
    gparis

  5. #5
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Sorry, but he didn't specify anything just CS3 It could have simply been AS 3.0 too. My bad. But the idea is the same in AS 2.0 too, just change the syntax to the correct AS 2.0 syntax. Sorry again.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


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