annette
07-02-2004, 05:27 PM
Im trying to use a text effect by tommywizbang in an mc called to the stage by attachMovie.
He has two dynamic text boxes with variables"tf" and "tf_max" and the following script in the first frame of the main timeline:
this.onLoad = function() {
tf = "";
text = "blahblah";
_root.tf_max = text.length;
speed = 6;
};
this.onEnterFrame=function() {
if (_root.tf_max<=1){
output = substring (text,1,-1);
tf = output;
break;
} else {
tfLength =_root.tf_max-speed;
_root.tf_max = tfLength;
output = substring (text, tfLength, speed);
tf = output+tf;
}
};
MovieCliip.prototype.reset = function(){
tf = "";
_root.tf_max = text.length;
};
I cant understand why he has only one variable referenced to the _root but also if I remove the reference to _root for tf_max, his code still works when I test my mc scene. When I test the movie, my attached mc flashes up for a second and then dissappears.
I've tried addressing the 'onLoad' and 'onEnterFrame' actions as _root.holder.mc.onLoad etc (holder is the emty mc that attaches my mc) or as _parent._parent. I've also tried changing the paths to the variables and at one stage tried to set global variables. I'm not sure if this was the right way to go because I thought if a variable was declared in a movie clip you could use it in that movie clip without having to set a path to it. But when get the output window to list variables it dosent list values for variables in the attached mc.
I know this is a basic addressing problem but I've trawled though tutorials and the forums to try and figure out what I'm doing wrong and cant seem to get it to work.
He has two dynamic text boxes with variables"tf" and "tf_max" and the following script in the first frame of the main timeline:
this.onLoad = function() {
tf = "";
text = "blahblah";
_root.tf_max = text.length;
speed = 6;
};
this.onEnterFrame=function() {
if (_root.tf_max<=1){
output = substring (text,1,-1);
tf = output;
break;
} else {
tfLength =_root.tf_max-speed;
_root.tf_max = tfLength;
output = substring (text, tfLength, speed);
tf = output+tf;
}
};
MovieCliip.prototype.reset = function(){
tf = "";
_root.tf_max = text.length;
};
I cant understand why he has only one variable referenced to the _root but also if I remove the reference to _root for tf_max, his code still works when I test my mc scene. When I test the movie, my attached mc flashes up for a second and then dissappears.
I've tried addressing the 'onLoad' and 'onEnterFrame' actions as _root.holder.mc.onLoad etc (holder is the emty mc that attaches my mc) or as _parent._parent. I've also tried changing the paths to the variables and at one stage tried to set global variables. I'm not sure if this was the right way to go because I thought if a variable was declared in a movie clip you could use it in that movie clip without having to set a path to it. But when get the output window to list variables it dosent list values for variables in the attached mc.
I know this is a basic addressing problem but I've trawled though tutorials and the forums to try and figure out what I'm doing wrong and cant seem to get it to work.