Just gonna throw this out there, in case it was missed by someone who 
might be able to help.

SWF Loader in Flex App, loads initial swf and local connection works 
perfect to stop / play / pause swf.  As soon as new swf is loaded 
into SWF Loader at runtime...local connection no longer works.  I 
assume it is not the sending local connection as the event listener 
returns status (no errors).  So i guess it might be swf Loader not 
loading swf properly or unloading previous swf...anyway gonna post 
the code so you all can see.  The swf basically has actions layers 
with corresponding functions (stop function etc...)

THANKS!

CODE:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute" initialize="urlloader()">
 <mx:Script>
        <![CDATA[
        //declarations
        import flash.net.*;
        import flash.events.*;  
        import mx.controls.Alert;
        import flash.media.SoundTransform;      
                        
        public var swfState:String = "play";    
        public var lc:LocalConnection = new LocalConnection;    
                                                                
        [Bindable]              
        public var my_xml:XML = new XML();
        
//create loader and request for XML doc
        public function urlloader():void{       
        var xml_loader:URLLoader = new URLLoader;               
        var xml_request:URLRequest = new URLRequest ("playlist.xml");
        xml_loader.load(xml_request);                   
        xml_loader.addEventListener("complete", onComplete);
        lc.allowDomain();                                       
        }                       
//stop and return to frame 1, enable functions
        private function stopandrestart(): void {
        lc.send( "swf8connector", "stopandrestart" );
        stop.enabled=false;
        pause.enabled=false;
        play.enabled = true;
        }                                       
//Toggle pause and play, disable other buttons          
        private function stopOrResume() : void {                
        if( swfState == "play" ) {                              
        pause.label = "Resume";
        lc.send( "swf8connector", "pauseFile" );
        swfState = "pause";
        play.enabled = false;
        stop.enabled = false;
        pause.enabled=true;
        }
        else {
        pause.label = "Pause";
        lc.send( "swf8connector", "resumeFile" );
        swfState = "play";
        play.enabled = true;
        stop.enabled = true;
        pause.enabled=true;
        }
        }                       
//start playback enable functions
        private function playFile() : void {
        lc.send ( "swf8connector", "playFile" );
        stop.enabled=true;
        pause.enabled=true;
        play.enabled=false;
        }                       
//Read XML doc and load course contents
        public function onComplete(event:Event): void{
        var loader:URLLoader = URLLoader(event.target);         
        my_xml = new XML(loader.data);                          
        };                                      
//unload swf currently loaded
        public function vidunload(): void {             
        swf.source = "";
        swf.enabled=false;
        swf.autoLoad=true;
        stop.enabled = false;
        pause.enabled = false;
        play.enabled = false;                                   
        }
                        
//load selected in list
        public function loadselected():void {
        var temp:String = list.selectedItem.toString(); 
        vidunload();
        swf.source = temp + ".swf";
        stop.enabled = true;
        pause.enabled= true;
        play.enabled= false;                            
        }       
        ]]>
</mx:Script>
<mx:ApplicationControlBar x="10" y="10" height="194" width="130" 
cornerRadius="19" fillAlphas="[0.26, 0.19]" fillColors="[#0080ff, 
#ffffff]">

<mx:List id="list" alpha="0.0" borderStyle="none" height="150" 
dataProvider="[EMAIL PROTECTED]" labelField="@name" 
selectable="true" width="111" allowMultipleSelection="false" 
textRollOverColor="#0080C0"  click="loadselected()" 
textAlign="left"></mx:List>

</mx:ApplicationControlBar>
<mx:Panel x="148" y="10" width="783" height="693" layout="absolute">
<mx:SWFLoader id="swf" autoLoad="true" source="star_flash.swf" x="10" 
y="10" width="751" height="633"/>
<mx:ApplicationControlBar width="234">
<mx:Button id="play" label="Play" click="playFile()" width="48"/>
<mx:Button id="stop" label="Stop" click="stopandrestart()" 
width="48"/>
<mx:Button id="pause" label="Pause" click="stopOrResume()" 
width="69"/>
<mx:HSlider id="vslide" width="71" height="20"/>
</mx:ApplicationControlBar>
</mx:Panel>
</mx:Application>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to