Monday, March 29, 2010

AS2 class linkage breaks with imported...

I stumbled upon this while trying to customize the tree
component following the example on the LiveDocs, see
http://livedocs.adobe.com/flash/8/main/00004117.html



To see the problem, do the following:



PART 1:

1) create an empty test.fla file

2) put a tree component on the stage

3) convert it to a symbol named TreeNavMenu, export for
Actionscript as TreeNavMenu

4) link it to the AS2 class TreeNavMenu

5) create the TreeNavMenu.as file as per livedocs (see above
link)

6) put a ''trace('initialized');'' in the constructor for
TreeNavMenu

7) publish test.fla and run test.swf and you'll see a
''initialized'' trace line



PART 2:

8) create a library.fla file containing a symbol, say a label
or whatever, e.g. named ''sample''

9) do a linkage/export for runtime sharing on that symbol

10) publish library.swf

11) import that ''sample'' symbol in the test.fla file
containing the tree and put it on stage, i.e. to be clear, mark
that symbol as ''import for runtime sharing'' from library.swf

12) now publish test.fla and run the test.swf again, and
although the imported symbol will show up, no ''initialized'' trace
message for the customized tree will show up.



my code is more complex, but this is what it boils down to.
to me it looks like the AS2 class initialization just does not
happen once I import anything from a runtime libary. The class is
there, but it does not get executed somehow. I tried it manually
via Object.registerClass() etc. but that was not successful either.



So my questions:

1) is this a bug?

2) did I forget something, should I do something else?

3) if none of the above: how can these two things be combined
otherwise?



much appreciated.

Helmut

No comments:

Post a Comment