wilma
October 20, 2003, 6:41pm
1
hi, does anyone know if there is a piece of code that will count from 0 through 9 and then just keep repeating over and over?
if there is would there be a way of controlling the spped of the count - so it could go really fast or quite slow??
i tried
[AS]onClipEvent (load) {
myValue = 0;
}
onClipEvent (enterFrame) {
if (myValue < 100) {
myValue++;
}
} {[/AS]
but alas i think i’m well off the mark
wilma
system
October 20, 2003, 6:56pm
2
Use the modulo [font=courier new]%[/font] operator.
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary010.html
var val = 0;
function count() {
val = ++val%10;
trace(val);
}
this.onEnterFrame = count;
To control the speed, you can use the [font=courier new]setInterval[/font] function.
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary646.html
var val = 0;
function count() {
val = ++val%10;
trace(val);
}
var interval = setInterval(count, 1000/48);
system
October 20, 2003, 7:02pm
3
that gives me output Kode, but how do i actually get the number on screen to change.
say if i type the number ‘2’ on a layer how do i get that number to change constantly to a value between 0 and 9??
wilma
system
October 20, 2003, 7:12pm
4
Create a text field and you could either assign the variable to it, or assign the value of the variable through its [font=courier new]text[/font] property.
var my_var = 2;
this.createTextField("my_txt", 0, 0, 0, 0, 0);
my_txt.autoSize = true;
my_txt.variable = "my_var";
function count() {
my_var = ++my_var%10;
}
this.onEnterFrame = count;
//
var my_var = 2;
this.createTextField("my_txt", 0, 0, 0, 0, 0);
my_txt.autoSize = true;
function count() {
my_var = ++my_var%10;
my_txt.text = my_var;
}
this.onEnterFrame = count;
system
October 20, 2003, 7:24pm
5
nice one.
presumably i can control the text style by adding code to that?
system
October 20, 2003, 7:26pm
6