I am using getDefinitionByName to access objects from an embedded SWF in my Flex code. The code is as follows:
[Embed(source='assets/crate.swf', symbol='Item1')] private var Item1:Class; [Embed(source='assets/crate.swf', symbol='Item2')] private var Item2:Class; [Embed(source='assets/crate.swf', symbol='Item3')] private var Item3:Class; . . . . var cls:Class = getDefinition("Item1") as Class;
But this gives me Error that: ReferenceError: Error #1065: Variable Item1 is not defined.
What is that I am doing wrong here?
I don't think you can access private APIs like this. Try making it public.
Gordon Smith, Adobe
The embedded swf has a different applicationdomain than your main SWF. It defaults to being in a child applicationDomain. GetDefinitionByName only works for the current applicationDomain.
You would need to add code to the embedded SWF to call getDefinitionByName in that SWFs context.