dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Random event help

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    6

    Random event help

    After discussion with domer 1 i can express my problem more clearly

    How to make a MovieClip (or button) be displayed on a stage in one of 3 coordinates (randomly)
    Example
    Coordinate1 (x10;y15)
    Coordinate2 (x50;y50)
    Coordinate1 (x500;y500)

    Coordinates don't change but the movieclip is placed randomly on one of theese coordinates upon loading flash movie itself.

    Help guys
    Last edited by DonoDonato; 11-25-2010 at 05:17 AM.

  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    6
    Guys, could you at least point me to the right direction?

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    I can try to help, though I don't know how much. Can you link your code your using or paste what you have?

    You want to dynamically load your buttons, which i would make as movie clips themselves, and using the attachMovie() function on them, with your "correct" button using the attachMovie() function to load your move clips.

    Do some research on creating variables, arrays, the random() function, dynamic text boxes, and attachMovie().

    Paste your code and I'll try and hash something out for you.

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    6
    A very nice programer (lewi-p) on Kirupa forum sugested i use this script and it works:

    The movieclip instance is set to myMc

    var positions:Array = [[50, 50], [150, 150], [250, 250]];

    var randomIndex:Number = Math.floor(Math.random() * positions.length);

    myMC._x = positions[randomIndex][0];
    myMC._y = positions[randomIndex][1];
    Last edited by DonoDonato; 11-26-2010 at 02:12 AM.

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