AS3 - Passing values to child swf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrayjr
    New Member
    • Nov 2007
    • 15

    AS3 - Passing values to child swf

    Good morning, I've ran into a problem where I need to pass a value from my main swf to a external swf that I load. I've looked everywhere with no luck. Hope to find someone here that may know. What I am trying to do is pass the value of textColor to my Weather.swf. The textColor is a dynamic value that the user selects from the main swf. I'm still quite new to how AS3 handles different things. =(

    Code:
    [Frame1]
    
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.events.Event;
    
    var textColor:uint = 0x00FF00;
    
    //Creates empty movie clip 
    var Wmc:MovieClip = new MovieClip();
    	
    // Load Weather
    var WeatherLoader:Loader = new Loader();
    var WeatherRequest:URLRequest = new URLRequest("Weather.swf");
    WeatherLoader.load(WeatherRequest);
    
    // MC Populated
    Wmc.addChild(WeatherLoader);
    
    [Frame2]
    
    // Format Wmc
    Wmc.x = 562;
    Wmc.y = 62.5;
    Wmc.width = 900;
    Wmc.height = 550;
    Wmc.name = "WMC_Loader";
    addChild(Wmc); // Display the Wmc
    Any information would be great, thanks.

    -John
  • bnashenas1984
    Contributor
    • Sep 2007
    • 257

    #2
    Hi
    I'm not sure if this example can help you or not.

    Lets say we have 2 swf files

    Number 1: main.swf
    Number 2: loadedFile.swf

    first you load loadedFile.swf .and add it to main.swf and then set the instance name to "loadedFileName "

    Now we want to pass a variable called "Something" to loadedFile.swf

    in main.swf we write
    Code:
    loadedFileName.Something = "here comes the value of your variable";

    and now if you write the code below you will see the value of your variable in the output box
    Code:
    trace(this.Something);

    Good luck

    Comment

    Working...