A Flash Developer Resource Site

1. ## Random numbers.

Hi!

I am making a game in 3DFA.
And I want to work with a dice.
Everything is good and all but I don't exactly know the script for a random number.
I found the functions of Blanius.
This script:
Code:
```function randomRange(Min,Max){
return random(Max-Min+1)+Min;
}```
And how can I get the output into a textbox. What should I insert as the variable?

Can someone help?
Thnx!

Grtz,, Yoer88

2. put that function in your starting script.

Then when you want to get a new random number you call the function like this

die1=root.randomRange(1,6)

die1 will now equal a number between 1 and 6 if you have an editbox with the variable die1 it will show you the number

http://bretlanius.com/flash/die.html

3. Thnx allot!

My game is becoming a version of a well known game. (don't know how they call it in English).
But what I want is when; die1==1 the position of the player (just a circle with gradient) must go forward one position. And when die1==2 it has to go forward 2 positions etc.

So my questions: How can I set the positions (?? position1=element("player").x.y=145.200 ??).
And how can I make sure he counts the value of die1 to the previous values.

I hope it is clear what I mean and I hope you can help me.
Grtz,, Yoer88

4. it depends alot on how you are displaying them, and how you are tracking where they are. I'm guessing that you may need to rethink that part of your game. This is something you needed to plan for when starting the project.

you set the position of an object with myobject.position.x and I think myobject.x works just as well. And substitute y for the x for the other dimension.

You should read up on ARRAYS as I've found that is usually the best way to do this sort of board game thing.

5. I see. Alright I rethink it then.
But can you tell me anyway how to make something so the value of die1 is added to a total?

7. oOw
could of thought of that myself of course..

8. this is easy you just need to add in some editboxes or something, like in your starting script say

die=whatever the die says (create some scriot within die to make this work)
position=0 (position will be the varible)
position1=number.x and number.y
position2=number.x and number.y
(ect for hom many positions you have)

then say
if [thedierolls]{
position+=die
}

if position=1{
element (player)=position1
}

thered be a lot of scripting but this is what i first thought of, it has soem holes but you could fill em in.

9. ## Something I Remember Seeing

Hi,

With regards to random numbers, you'll notice that in the 3DFA viewer, the numbers aren't very random. If you restart the movie, the numbers are the same the second time around.

However, it seems it's OK in the exported movie, so maybe it's not a problem.

Morgan

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap