1

I have imported a swf (not created with Flex, i.e. non-framework) into a Flex application. Once loaded, I would like to access movieclips within that imported swf. Looking at Adobe's docs (http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html), it seems straightforward; however, their examples are between a Flex app and an imported swf (created with Flex).

Like their example, I'm trying to use the SystemManager to access the imported swf's content; however, I receive the following error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@58ca241 to mx.managers.SystemManager.

Is this error occurring because I'm importing a non-framework swf into a framework swf? Thanks in advance for any assistance.

Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:SWFLoader source="assets/test.swf"  id="loader"  creationComplete="swfLoaded()" /> 

<mx:Script>
 <![CDATA[

  import mx.managers.SystemManager;

  [Bindable]
        public var loadedSM:SystemManager;


  private function swfLoaded():void 
  { 
   loadedSM = SystemManager(loader.content);
  } 
 ]]>


</mx:Script>
</mx:Application>
squared
  • 11
  • 2

2 Answers2

0

Was test.swf created with an earlier AS version? According to this swfs published for AS 1.0/2.0 runs in a different AS virtual machine than AS 3.

The parent AVM2 SWF file will not have access to the properties, methods, or objects of the loaded AVM1Movie object.

adamcodes
  • 1,606
  • 13
  • 21
0

You can access them directly, using their instance names.

private function swfLoaded():void {
    var clip1:MovieClip = MovieClip(loader.content.myClip1);
    var clip2:MovieClip = MovieClip(loader.content.myClip2);
    // ...
}
Cory Petosky
  • 12,458
  • 3
  • 39
  • 44
  • I tried the following... (please note that the movieclip/symbol was named firstFloor, and the instance of the movieclip was named "firstFloor_mc", and the movieclip was exported as a Class named firstFloor. – squared May 06 '10 at 20:22
  • 1. var clip1:MovieClip = MovieClip(loader.content.firstFloor); error: 1119: Access of possibly undefined property firstFloor through a reference with static type flash.display:DisplayObject.

    2. var clip1:MovieClip = MovieClip(loader.content.firstFloor_mc);error: 1119: Access of possibly undefined property firstFloor through a reference with static type flash.display:DisplayObject.
    – squared May 06 '10 at 20:22
  • The second option is correct, assuming the clip is on the first frame of the stage. That second error message is the same as the first. Copy/paste error or did you forget to save the file when you tested the second style? :) – Cory Petosky May 06 '10 at 22:03