instance class from swc inside a movieclip

1k views Asked by At

i'm trying to use compiled assets and code from a swc. Inside a new fla I select the swc to be included when exporting. When create the instance in the timeline of the code works and I can see assets that are inside the swc and trace a propertie from the same object. The problem is only when doing the same inside a movieclip, can't reach the assets (movieclip) but I can still trace properties from the class.

I've uploaded the working files: master.fla is the one that creates the swc. template.fla is where I test the swc.

files (This are cs4 .fla + .swc + .as)

EDIT: How to reproduce the problem I had:

.1 create a new master.fla and make it compile a swc.

.2 In master.fla timeline create a Textfield, give it the instance name of "tfield" and make a MovieClip from it.

.3 Create a TextBox.as class and define a public variable "tfield" (this will pickup the TextField asset you have inside your movie).

.4 In library link the newly created MovieClip to the TextBox class.

.5 Export and you should be seeing a instance of the TextBox class.

using the swc:

.1 Create a new fla and make it use the master.swc as source

.2 open first frame in timeline and write the following code:

var tf : TextBox = new TextBox();
addChild(tf)

This should work as expected, creating a instance of the TextBox and you should see the TextField inside.

.3 comment the previous code and write the same code but this time inside a MovieClip and drop it to the timeline. Although the code works the "tfield" is not accessible. Nor you can see it.

SOLUTION: As pointed out by Daniel just give a linkage id to the MovieClip that contains the code (DON'T give the TextBox class id, just make it create a new class like "lalala").

Thank you Daniel!

2

There are 2 answers

2
Daniel On BEST ANSWER

add a linkage id to tf in template

3
www0z0k On

fixed
added TextField initialization to TextBox.as (to avoid null reference when tracing tfield.text) and renamed tf: TextBox to tb:TextBox to make name different from tf on the stage