How do i get Random pick on screen

Hello Flash Expert,

I want to make a simple quiz program in flash.
i have 4 words,   word 1, word 2, word3, word4.
Now i want flash to pick randomly one of these words and show
them on the stage in dynamic textfield.

Underneath the word i would like another dynamic textfield
where flash will randomly pick a number between 1 and 10 and show this on the screen.
You're help is very appreciated.
stevenvervlietAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
Hi, I'm not using CS4 but how to create a random number,  straight out of the help file

//Returns a pseudo-random number n, where 0 <= n < 1. The number returned is called a "pseudo-random" number because it is, technically, calculated in an undisclosed manner.


function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}


how you'd implement this

mytextfield.text = randRange(1, 10);

to pick a word store your words in an array, use the random number generator to generate a number from 0 to the length of the array minus 1 and the word will be

var selectedWord:String  = yourArray[numberGenerated];

blu
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stevenvervlietAuthor Commented:
Hello Blue-genie,

Thank you very much for you're reply.
Ok, like you say i store my 4 words in an array,
So in the first frame i put in actionscript

my_arr=["word1","word2","word3","word4"];
num=random(4);
whichword=my_arr[num];

Now in Frame 2 i put a dynamic textfiled
but the Variable line is in grey, and when i click on it says

This feature is not supported by actionscript 3.0
To use these feature you must target 2.0 of 1.0

Is there another way to get this done in actionscript 3.0?

Kind regards
Steven

0
blue-genieCommented:
yeah you have to set i manually

ie. mytextfieldname.text = myvaraiblevalue.

ps. how's your experience with CS4 so far?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

stevenvervlietAuthor Commented:
Hello Bleu-Genie,

Well, to be honest the only thing i can say about it, it looks good, better
then the previous versions, if it works better then previous ones, I Don't Know.
I think i'd learn more from you're comment on this, you're a proffesional flash user,
why didn't you upgrade yet to CS4?  Are there bad things about it?

Now i notice using variables is not an option anymore in Actionscript 3.0
When i target action script 2.0 or 1.0, i still can put variables, and my words display
randomly on the screen. I only worry that if i continue like this, i would miss out
on the benefits of using actionscript 3.0 further on in my project.
So if variables are not used anymore in actionscript 3.0, by what have they been replaced?

Kind regards
Steven


0
blue-genieCommented:
you can't specify a variable on a dynamic textfield and it just pops up anymore
variables haven't been replaced, it's just now following good Object Oriented Programming practice :-)
you have to create instance variables etc.


its tedious but like most things once you know how its easy.
i haven't upgraded yet because i haven't been able to convince my boss to buy it yet
:-)
0
stevenvervlietAuthor Commented:
Thanks for you're help Blue-Genie
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.