-
Senior Member
[F8] random update
I have a button when pressed gives random words from an Array. My idea was that every time I press the button two new random words appear in the dynamic textbox but it doesn´t. I have a button which remove the words but when press the random-word-button again, the same words as before appear again.
Something basic is missing I guess.
------
words = new Array;
words =["jaså","evert","olle","affär","bostad","julknapp "];
var val1 = words [Math.round(Math.random()*6)];
var val2 = words [Math.round(Math.random()*6)];
_root.ord1 = ""; //dynamic textbox
_root.ord2 = ""; //dynamic textbox
_root.knapp.onPress = function(){
_root.ord1 = val1;
_root.ord2 = val2;
}
////
_root.knapp2.onPress = function(){
_root.ord1 = "";
_root.ord2 = "";
}
Mattias Gordon
illustrator/ animator
-
Maybe try something like this...
Code:
words = new Array();
words = ["jaså", "evert", "olle", "affär", "bostad", "julknapp"];
_root.ord1 = "";
//dynamic textbox
_root.ord2 = "";
//dynamic textbox
_root.knapp.onPress = function() {
_root.ord1 = words[Math.round(Math.random()*5)];
_root.ord2 = words[Math.round(Math.random()*5)];
};
////
_root.knapp2.onPress = function() {
_root.ord1 = "";
_root.ord2 = "";
};
Last edited by dawsonk; 12-12-2006 at 05:20 PM.
-
Senior Member
well
Code:
number = random(100);
will generate a random number between 0 -100 then you could use the number as a variable identifier something like var 1 = myword.
-
Senior Member
Yes of course, I had the random variable outside the onPress-function so it would only update when the film loaded. thanks.
Mattias Gordon
illustrator/ animator
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|