4 Replies Latest reply on Mar 19, 2007 6:50 AM by neil manuell

    AS3 swf loaded as AVM1Movie

    neil manuell
      I have an as3 proj in flex.
      I have a custom class Screen which is complied into a swf (by flex)
      I'm loading this file via a Loader..., then passing data up to it on INIT.
      fine that works great for the first time, second time, then on the third time nothing.
      when I trace for the type of the Loader.content, the first two times it traces [Screen,Object] as expected but on the third time it traces [AVM1Movie, Object].
      what's this about?? is it some security thing??

      the relevent code is below - the path resolves in all cases to the same path (..../SimpleScreen.swf)

      // ActionScript file
      package gs.ctl
      { //__________________________________________________
      //
      // imports
      //__________________________________________________
      //
      import flash.display.DisplayObjectContainer;
      import flash.display.Loader;
      import flash.events.Event;
      import flash.events.EventDispatcher;
      import flash.net.URLRequest;
      import flash.system.ApplicationDomain;
      import flash.system.LoaderContext;

      import gs.mdl.LoadXmlUnicode;
      import gs.vw.Screen;

      import mx.utils.StringUtil;

      import utils.LogEvent;



      public class Navigator extends EventDispatcher implements INavigator{

      private var _currentScreenLoader:Loader
      private var _currentScreen:Screen
      private var _currentScreenXml:XML
      private var _screenSetXml:XML
      private var _rootScreen:DisplayObjectContainer
      private var _pathUserRoot:String
      private var _pathData:String
      private var _pathAssets:String
      private var _URLscreenSet:String
      private var _legalScreenItems:XMLList


      private function _changeScreen():void{

      var URLReq:URLRequest = new URLRequest(_pathUserRoot+"\\"+_pathAssets+"\\"+_currentScreenXml.url);
      var context:LoaderContext = new LoaderContext();
      context.applicationDomain = ApplicationDomain.currentDomain;
      _currentScreenLoader=new Loader();

      _currentScreenLoader.contentLoaderInfo.addEventListener (Event.INIT, _initHandler)
      _currentScreenLoader.load(URLReq, context);

      }

      private function _initHandler(event:Event):void{
      if(_rootScreen.numChildren==2)_rootScreen.removeChildAt(0)

      trace("type = "+_currentScreenLoader.content)

      _currentScreen=Screen(_currentScreenLoader.content);
      _rootScreen.addChild(_currentScreen)
      _currentScreen.setData(screenXml, _legalScreenItems, _pathUserRoot+"\\"+_pathAssets+"\\");
      _currentScreenLoader.unload();
      }
      }
      }