actionscript 3 - how to use the text box to change a frame in AS3 -
so making little game. numbers count , when reach number want change frame. e.g. numbers start counting , when reach 10 change frame 20. btw in action-script 3
in document class, create setter function go frame when condition met.
private var _counter:uint = 0; public function counter ():uint { return _counter; } public function set counter (value:uint):void { if (value == _counter) return; _counter = value; if(_counter == 10) gotoandstop(20); }
now use counter
if real variable:
counter += 5; trace(counter); counter = 10;
just clear: should not have counter variable in text field only. textfield way display it. should have real number variable, because textfield
made string
s, not numbers. if want display counter variable in textfield
, in set function well:
public function set counter (value:uint):void { if (value == _counter) return; _counter = value; textfield.text = _counter.tostring(); //display counter in text if(_counter == 10) gotoandstop(20); }
Comments
Post a Comment