Search code examples
adobeflashflash-cs5flash-ide

How do I pass parameters to a SWF launched from the IDE?


A SWF can access parameters set in HTML via loaderInfo.parameters. How do I set this in a .fla project so that they are set when I run the SWF with ctrl-enter ?


Solution

  • You can't do that from the IDE, but for testing, could have a local parameters object you can substitute if loaderInfo.parameters is empty:

    package 
    {
    
        import flash.display.MovieClip
    
        public class TestMain extends MovieClip
        {
    
            public function TestMain ()
            {
                var params:Object = root.loaderInfo.parameters;
                var length : int = 0;
                for (var str:String in params)
                {
                    length++;
                }
                if (length == 0) params = {test:"Test", test2:"Test2"};
                for (var str : String in params) {
                    trace (str +" : "+params[str]);
                }
            }
    
        }
    
    }