• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

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.
  • 3
  • 3
1 Solution
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];

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


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

yeah you have to set i manually

ie. mytextfieldname.text = myvaraiblevalue.

ps. how's your experience with CS4 so far?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

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
stevenvervlietAuthor Commented:
Thanks for you're help Blue-Genie
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now