PDA

View Full Version : Targeting Instances within Assets through Classes



exdsmile
May 9th, 2007, 12:20 AM
Ok, Here's the situation:

In my Library there is a movieclip(temp_mc) that I've linked to an AS class(Temp) that extends MovieClip. On the STAGE of that library asset is a TextField I've named dynamTxt.

On the MAIN timeline, I have code to attach the library asset through code only:

import Temp;

var g:Temp = new Temp();
addChild(g);
g.dynamTxt.text = "Display Me";

However, I cant target the textfield within 'g'. I've tried naming a variable in the class definition the same, but it stil doesnt work. How can you target a stage instance within a library asset that's linked to an external class?

eudora
May 11th, 2007, 10:55 AM
Hmm sorry I misread your question

senocular
May 11th, 2007, 11:42 AM
1) you don't use import with Temp. If there's no dot (.) in your import, than its not a valid import.

2) As long as dynamTxt is on frame 1 of Temp, then that code should work. It wont if its on another frame because dynamTxt doesn't yet exist and instances on the timeline only exist on the frames in which they appear on that timeline.