I have 2 projects created with Flash Builder 4.6:
- an ActionScript project
- a Mobile Flex project
both of these project load the same external SWF file (created with flash professional CS6) that contains movie clip assets (using the same shared code to load external swf files)
both project extend the movie clips in the swf asset file. for example, in the swf file I have a movie clip called "Test" that contains a single text field. the linkage class is "MyTest" and the text field has an instance name of "txt1".
I have a class called "MyTest" in both project which contains a public "txt1" property and a private "var counter:int", and once the swf is loaded I use the following code to create an instance of the class:
var x:MyTest = new MyTest();
in the actionscript project it works great and x is created correctly, the textfield txt1 is set correctly.
in the flex project however, the txt1 property is null, so the instance is not an instance of the "Test" movie clip from the external swf.
what am I doing wrong? why is it working in the actionscript project and not in the mobile flex project? this is a shared piece of code doing all this work, and I'd hate to rewrite a new one just for the flex project...
thanks.
to make things clearer
this piece of code:
var cls:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("MyTest") as Class;
var x:Object = new cls();
trace(getQualifiedClassName(x));
var y:MyTest = x as MyTest;
will set x to be of type MyTest as defined in the swf (does not have a "counter" property", and y will be null (safe case did not succeed).