evan
07-15-2008, 10:03 PM
This is not a question directly related to managing text so much as any object that is placed progamatically
by using
var hello_mc:Movieclip = new Hello_mc();
addChild (hello_mc);
hello_mc.x=100;
hello_mc.y=100;
"hello_mc" can be called from the library if it's linked with actionscript etc.
I can even call it with an event assigned to a button or a set of conditions -pretty basic.
but...
let's say I have assigned values to it before it's in memeory
as with this code:
hello_mc.mytext.border=true;
hello_mc.mytext.background=true;
var format:TextFormat = new TextFormat();
format.color= 0x000000;
hello_mc.mytext.setTextFormat(format);
//this function changes the text color to blue
//
blue_btn.addEventListener(MouseEvent.CLICK,bluetext);
function bluetext(e:MouseEvent):void{
var format:TextFormat = new TextFormat();
format.color= 0x3612CB;
hello_mc.mytext.setTextFormat(format);
}
in this case hello_mc includes mytext
if it is placed on the stage, then all is good.
but if I don't have it on the stage and I in fact want to use have it appear with an event handler,
then I would get this error:
1120: Access of undefined property hello_mc.mytext
not surprising.
The way I have been dealing with this is by creating an instance or hello_mc off the visible stage like at x,y -100 or so.
I was wondering if there was a more efficient way of doing it ie putting it into the memory without displaying it.
an array maybe?
The end result I am looking for is to start with ablank screen and a button,
call a movie clip, and what is inside them respectively, assign default properties and
with other buttons or I would like to change their properties.
the trouble is that if they don't exist in memory yet then you can't assign defaults. -UNLESS the defaults are conditional to the objects being placed onto the stage.
by using
var hello_mc:Movieclip = new Hello_mc();
addChild (hello_mc);
hello_mc.x=100;
hello_mc.y=100;
"hello_mc" can be called from the library if it's linked with actionscript etc.
I can even call it with an event assigned to a button or a set of conditions -pretty basic.
but...
let's say I have assigned values to it before it's in memeory
as with this code:
hello_mc.mytext.border=true;
hello_mc.mytext.background=true;
var format:TextFormat = new TextFormat();
format.color= 0x000000;
hello_mc.mytext.setTextFormat(format);
//this function changes the text color to blue
//
blue_btn.addEventListener(MouseEvent.CLICK,bluetext);
function bluetext(e:MouseEvent):void{
var format:TextFormat = new TextFormat();
format.color= 0x3612CB;
hello_mc.mytext.setTextFormat(format);
}
in this case hello_mc includes mytext
if it is placed on the stage, then all is good.
but if I don't have it on the stage and I in fact want to use have it appear with an event handler,
then I would get this error:
1120: Access of undefined property hello_mc.mytext
not surprising.
The way I have been dealing with this is by creating an instance or hello_mc off the visible stage like at x,y -100 or so.
I was wondering if there was a more efficient way of doing it ie putting it into the memory without displaying it.
an array maybe?
The end result I am looking for is to start with ablank screen and a button,
call a movie clip, and what is inside them respectively, assign default properties and
with other buttons or I would like to change their properties.
the trouble is that if they don't exist in memory yet then you can't assign defaults. -UNLESS the defaults are conditional to the objects being placed onto the stage.