Ignore:
Timestamp:
08/18/08 03:12:05 (5 years ago)
Author:
jeroen
Message:

changed SWF loading a little, added plugiins to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/as3/com/jeroenwijering/player/SWFLoader.as

    r57 r60  
    2626        /** Base directory for the plugins. **/ 
    2727        private var basedir:String = 'http://plugins.longtailvideo.com/'; 
    28         /** Amount of plugins still to load. **/ 
    29         private var amount:Number; 
    3028 
    3129 
     
    3735        public function SWFLoader(ply:MovieClip):void { 
    3836                player = ply; 
    39                 amount = 0; 
    4037        }; 
    4138 
     
    4441        * Load a list of SWF plugins. 
    4542        * 
    46         * @prm pgi              A commaseparated list with plugins.  
     43        * @prm pgi      A commaseparated list with plugins. 
    4744        **/ 
    4845        public function loadPlugins(pgi:String=null):void { 
    4946                if(pgi) { 
    5047                        var arr = pgi.split(','); 
    51                         amount = arr.length; 
    5248                        for(var i in arr) { loadSWF(arr[i],false); } 
    53                 } else {  
    54                         dispatchEvent(new Event(Event.COMPLETE)); 
    5549                } 
    5650        };  
     
    6761                } else { 
    6862                        skin = player['player']; 
    69                         dispatchEvent(new Event(Event.INIT)); 
     63                        dispatchEvent(new Event(Event.COMPLETE)); 
    7064                } 
    7165        }; 
     
    7973                        ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,skinError); 
    8074                        ldr.contentLoaderInfo.addEventListener(Event.INIT,skinHandler); 
    81                 } else {  
     75                } else { 
    8276                        skin.addChild(ldr); 
    8377                        ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,pluginError); 
    8478                        ldr.contentLoaderInfo.addEventListener(Event.INIT,pluginHandler); 
    8579                } 
    86                 if(player.loaderInfo.url.indexOf('http://') == 0) { 
     80                if(player.loaderInfo.url.indexOf('http') == 0) { 
    8781                        var ctx = new LoaderContext(true,ApplicationDomain.currentDomain,SecurityDomain.currentDomain); 
    8882                        if(skn) {  
     
    9791 
    9892 
    99         /** SWF loading failed; use default skin. **/ 
     93        /** SWF loading failed. **/ 
    10094        private function pluginError(evt:IOErrorEvent):void { 
    101                 amount--; 
    102                 if (amount == 0) { 
    103                         dispatchEvent(new Event(Event.COMPLETE)); 
    104                 } 
     95                player.view.sendEvent('trace',' plugin: '+evt.toString()); 
    10596        }; 
    10697 
     
    10899        /** Plugin loading completed; add to stage and populate. **/ 
    109100        private function pluginHandler(evt:Event):void { 
    110                 var clp = evt.target.content; 
    111                 player.addPlugin(clp); 
    112                 amount--; 
    113                 if (amount == 0) { 
    114                         dispatchEvent(new Event(Event.COMPLETE)); 
     101                var plg = evt.target.content; 
     102                try {  
     103                        plg.initializePlugin(player.view); 
     104                } catch(err:Error) {  
     105                        player.view.sendEvent('trace',' plugin: '+err.message); 
    115106                } 
    116107        }; 
     
    120111        private function skinError(evt:IOErrorEvent=null):void { 
    121112                skin = player['player']; 
    122                 dispatchEvent(new Event(Event.INIT)); 
     113                dispatchEvent(new Event(Event.COMPLETE)); 
    123114        }; 
    124115 
     
    131122                        Draw.clear(player); 
    132123                        player.addChild(skin); 
    133                         dispatchEvent(new Event(Event.INIT)); 
     124                        dispatchEvent(new Event(Event.COMPLETE)); 
    134125                } else { 
    135126                        skinError(); 
Note: See TracChangeset for help on using the changeset viewer.