Copy link to clipboard
Copied
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. |
Copy link to clipboard
Copied
There would be an import line that you may not have shown, something like:
import TypeFX;
That would import the external TypeFX.as file that you showed the code for.
The other thing is that the textfield you're going to add the effects to would need to be a Dynamic textfield, with an instance name of textbox_txt. You do that by selecting the textfield on the stage, and in the properties panel you give it that name.
Copy link to clipboard
Copied
I did all that and the textbox is Dynamic Text. But it still gives me the error code of
Scene 2, Layer 'actions', Frame 2, Line 3, Column 12 | 1120: Access of undefined property textbox2_txt. |
I changed the Scene 2 textbox to textbox2_txt and Scene 1 textbox to textbox_txt. No matter what I do either it doesn't move or it does the flashy back-n-forth.