This small flex app will (source included at the end) crash my browser 
everytime, can 
some1 help me finding the source of this problem?

You can remove the Application.application.parameters.cancionPath with a path 
to a mp3 
file and in Safari when closing the browser or navigating to another page you 
will get a 
STREAM ERROR message and the browser will crash, on Firefox, nothing will 
happend but 
it will run very slowly the webapp, and on IE a prompt window will ask you for 
a flash 
debugger.

Can some1 help me with this? Its driving me insane, It has to be a bug in Flash 
Player.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
width="100" height="100" 
        applicationComplete="initApp();" themeColor="haloGreen" 
backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, 
#FFFFFF]">
        
        <mx:Script>
                <![CDATA[
                        
                        import flash.media.Sound;
                        import flash.media.SoundChannel;
                        import flash.net.URLRequest;

                        
                        // Declarar las variables
                        private var cancion:Sound;
                        private var canal:SoundChannel;
                        private var cancionPosicion:int;
                        private var cancionEstaSonando:Boolean;
                        private var request:URLRequest;
                        
                        private function initApp():void {
                                                                
                                request = new 
URLRequest(Application.application.parameters.cancionPath);
                                
                                // Si ocurre algun error aqui, deshabilitar el 
boton
                                try {
                                        cancion = new Sound(request)
                                }
                                catch (error:Error) {
                                        btnPlay.enabled = false;
                                }

                                canal = new SoundChannel();
                                cancionPosicion = 0;
                                cancionEstaSonando = false;     

                        }
                        
                        private function resumir():void {
                                                
                                // Reproducir mp3
                                canal = cancion.play(cancionPosicion);
                                
                                // Cambiar el label del boton
                                btnPlay.label = "Pausar";
                                
                                // Marcar la cancion como sonando
                                cancionEstaSonando = true;
                                
                        }
                        
                        private function pausar():void {
                                
                                // Guardar la posicion de la cancion antes de 
pausarla
                                cancionPosicion = canal.position;
                                
                                // Parar la cancion
                                canal.stop();
                                
                                // Cambiar el label del boton
                                btnPlay.label = "Reproducir";
                                
                                // Marcar la cancion como no sonando
                                cancionEstaSonando = false;
                                
                        }
                        
                        private function reproducir(e:MouseEvent):void {
                                
                                if (cancionEstaSonando) {
                                        pausar();
                                } else {
                                        resumir();
                                }
                                
                        }
                        
                ]]>
        </mx:Script>
        
        <mx:Button label="Reproducir" id="btnPlay" horizontalCenter="0" 
verticalCenter="-
1" click="reproducir(event)"/>
        
</mx:Application>

Reply via email to