Error code in Actions Script for Animate
Hello. I'm a Digital Art teacher and we have been using tutorials from another website to create Animate files. Unfortunately one of the tutorials is causing an error for some of my students. Following is the code they are directed to use and how to create an actions frame.
package {
import flash.utils.Timer;
import flash.text.TextField;
import flash.events.TimerEvent;
public class TypeFX {
private var timer:Timer;
private var text:String;
private var pos:int = 0;
private var field:TextField;
public function TypeFX(field:TextField, speed:int = 42, text:String = null) {
// constructor code
this.field = field;
if(text != null)
{
this.text = text;
}
else
{
this.text = field.text;
}
field.text = '';
timer = new Timer(speed, this.text.length);
timer.addEventListener(TimerEvent.TIMER,update);
timer.addEventListener(TimerEvent.TIMER_COMPLETE,kill);
timer.start();
}
private function update(e:TimerEvent):void
{
pos++;
field.text = text.substr(0,pos);
}
private function kill(e:TimerEvent):void
{
timer.removeEventListener(TimerEvent.TIMER,update);
timer.removeEventListener(TimerEvent.TIMER_COMPLETE,kill);
timer.stop();
timer = null;
text = null;
field = null;
}
}
}
On the actions frames they are instructed to put the following:
new TypeFX(textbox_txt);
The error message received is the following:
| Scene 1, Layer 'actions', Frame 1, Line 3, Column 12 | 1120: Access of undefined property textbox_txt. |
