A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Can Flasvars be passed to the loaded external swf?

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    Seattle, WA
    Posts
    180

    Can Flasvars be passed to the loaded external swf?

    I am wondering if you know how I can pass flashvars to a child swf. I am loading an external swf into main swf. The loaded swf has to be able to read flashvars from html. Any ideas???
    Thanks.
    Best regards
    Vlad,

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You only need to worry about getting the values into the parent movie.
    Just create a few public variables on the child .swf. Then when it's fully loaded (Event.COMPLETE) have the parent movie assign values to those vars.

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    Seattle, WA
    Posts
    180
    Actually, It was not hard at all. Here what I did:

    Actionscript Code:
    import flash.display.Stage;  
    import flash.display.Sprite;  
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.display.DisplayObject

    var loader2:Loader=new Loader();
    loader2.load(new URLRequest("movie.swf"));
    loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadClip);
    loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
    stage.addChild(loader2);


    if(root.loaderInfo.parameters["xmlfile"] != null){
        txt.text = root.loaderInfo.parameters["xmlfile"];
    }


    function loadHandler(event:Event):void
    {
      var childSwf:Object = event.target.content;
       loadedSwf.txt.text = root.loaderInfo.parameters["xmlfile"]||"";
    }

    As a result, the texfield in the loaded movie.swf shows the value of Flashvar
    Thakn you for te tip.

    I am wondering if you can advice on how to make this value be seen by XMLLoader I created in the movie.swf.

    I use Eventdispatcher class which has static const defined:
    Actionscript Code:
    public static const CONFIG_XML_URL:String = "xml/config.xml";


    public function load():void {

    // Create a new XMLLoader object
    configXMLLoader = new XMLLoader(CONFIG_XML_URL);

    // Add an event listener to be dispatched when xml is parsed.
    configXMLLoader.addEventListener(XMLLoader.XML_LOA DED, onConfigXMLLoaded);

    // Start loading the file
    configXMLLoader.load();

    }


    THe idea is to pass flashvar which will be then a passed to xml loader. It become a little bit complex.

    I need to be able to pass flashvar string to there XMLLoader. Any ideas? Thank you.
    Last edited by vladc77; 05-28-2010 at 03:21 PM.
    Best regards
    Vlad,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center