Random object position, excluding specific stage area [FMX]

Hey all. Another question from good ol’ WobblyFork here.

In the game I’m overambitiously creating while simultaneously figuring out ActionScript, I want a target to randomly jump out onto the screen at random locations.

However, there is also an area of the screen (where the user’s character stands with their elephant gun) that it would be silly for the target to appear in (being that the target would then be on top of the character and make it look visually screwy).

1. How should I randomize the appearance of the target? (Just the Random math command with some x and y variables, or do I need to get more complex)
2. How should I make sure the object’s randomness stays out of the small area where the character must stand? (The character is static, if that helps)

oh, and lastly, just to pile things on, if I want the target to flicker before it disappears if it’s not shot, and I want other targets to be able to appear while others are still flickering away, do I need to use any kind of complex coding? Would an array be appropriate?

Sigh… I’ll get less ignorant, just give me time :slight_smile:

Anyways, thanks all for all your help :smiley:

  • wobbly

try this:
targetmc._x = Math.random()*500;
targetmc._y = Math.random()*500;
targetmc._x += Math.random()*50;
targetmc._y += Math.random()*50;

500 is the stage width

hope that helps,