0

Short story

The same class is passed to the mxmlc compiler in SWF library as a symbol linkage class and again in a source-path. But the compiler uses the definition from the source-path so creating new instance of that class won't create new instance of the library symbol. How do I tell the compiler to prefer the definition linked to the symbol (the one dfrom SWC)?

Long story

I have my design assets in an FLA file and they are linked to classes (e.g. "com.myproject.view.MyAsset.as"). Then I export those assets to a SWC library and pass it to the compiler. Now when I create an instance of the class (new MyAsset();) it will be a new instance of the library object.

But there are other classes too in the source folder (e.g. "com.myproject.model.*" so I need to pass the source folder to the compiler too. And that is the problem, now the compiler will use the MyAsset.as definition from the source path, not from the SWC where it is assigned to the library object so if I create new instance of MyAsset now it won't duplicate the library object.

How do I tell the compiler to prefer the definition from the SWC?

Thanks

daniel.sedlacek
  • 8,129
  • 9
  • 46
  • 77
  • did you find a solution for this problem? –  Dec 21 '11 at 15:12
  • no. I had to rename the symbols in the FLA to have unique names (e.g. com.myproject.view.MyAsset_design) and use GetDefinitionByName to instantiate the symbols. – daniel.sedlacek Dec 29 '11 at 15:14

1 Answers1

0
I have the same class defined in SWF library and in a source folder. I need to include both the library and the source folder, how do I tell the compiler which one to prefer?

By same class do you mean the classes have the exact same exact code in addition to package structure? If so, I strongly recommend you refactor to avoid duplicate versions of the code. The one in your 'source folder' should take precedence if memory serves me; and it consistent with your experience.

Otherwise, you should rename one set of classes to avoid name conflicts.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • It is the same class. First it is used as Linkage Class for library symbol. That symbol gets exported into SWC. But if that same class is available to the mxmlc compiler in the source-path then it will be used without the linked symbol. – daniel.sedlacek Nov 09 '11 at 12:57
  • IF it's the same class; why does it matter which one is used by the compiler? – JeffryHouser Nov 09 '11 at 13:54
  • If you instantiate the one that has been used as a linkage class for a library symbol (and exported as SWC) you will create new instance of that symbol. – daniel.sedlacek Nov 09 '11 at 14:01