lundi 7 décembre 2015

Randomly generating Swfloader

I want to create a view in flex that will display a randomly generated swf. the following code can run, but my swf isnt showing? how to fix this?

<fx:Script>
    <![CDATA[   
        public function random(url:String):String{
            var movieArray:Array = ['swf/maily_you', 'swf/maily_work', 'swf/maily_start'];
            var loader:Loader = new Loader(); 
            var index:int = movieArray.length * Math.random(); 
            var url:String = movieArray[index] + '.swf'; 
            trace("Attempting to load", url); 
            loader.load(new URLRequest(url));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete); 
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderIOError); 
            addChild(loader); 
            function loaderComplete(e:Event):void {     
                trace("Successfully loaded", url);
            } function loaderIOError(e:IOErrorEvent):void {     
                trace("Failed to load", url); 
            }
    ]]>
</fx:Script>
<s:Panel width="100%" height="100%">
    <mx:SWFLoader  width="480" height="320" id="loader1" source="random()"/> 
</s:Panel>




Aucun commentaire:

Enregistrer un commentaire