Boa tarde,

Estou a ter um comportamento muito estranho na minha aplicação.

Criei um componente de upload, com todos os eventlisteners a que tem
direito, mas se, ao abrir a janela de escolha de ficheiro, eu fizer
"cancelar", a janela de origem, aliás, todo o flex, fica bloqueado. A janela
que abriu o fileref desaparece e a aplicação fica em freeze.

Já alguém teve uma experiência semelhante? É demasiado bizarro, nem faço
ideia a que deitar a eventual culpa.
No código abaixo, criei um botão para abrir o filereference apenas para
verificar eventuais erros, mas a situação mantém-se.

Fiz debug, mas não existem problemas. O módulo de upload é o seguinte
(parece longo mas é básico):

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml";
                layout="absolute"
                showCloseButton="true" close="fechar()"
                width="400"
                height="188"
                title="Upload de Ficheiro"
                 >
    <mx:states>
        <mx:State name="fim">
            <mx:RemoveChild target="{pb}"/>
            <mx:RemoveChild target="{fich}"/>
            <mx:AddChild position="lastChild">
                <mx:Label y="76" text="Ficheiro enviado com sucesso."
fontSize="14" horizontalCenter="0" color="#0BED06" fontWeight="normal"/>
            </mx:AddChild>
            <mx:AddChild position="lastChild">
                <mx:Button click="fechar()" y="116" label="Fechar"
horizontalCenter="0" color="#FF0000" height="20"/>
            </mx:AddChild>
        </mx:State>
    </mx:states>

    <mx:Metadata>
       [ Event( name="fimUpload", type="eventos.GenEvent") ]
     </mx:Metadata>
    <mx:Script>
        <![CDATA[
            import eventos.GenEvent;
            import mx.controls.Alert;
            import modelo.AModel;
            import mx.managers.PopUpManager;
            import mx.managers.PopUpManagerChildList;

            [Bindable]
            public var phpFile:String;

            public var tipo:uint;

            private var fr:FileReference;

            [Bindable]
            private var smodelo:AModel=AModel.instance;

            private var imageTypes:FileFilter = new FileFilter("Images
(*.jpg, *.jpeg,)", "*.jpg;*.jpeg");
            private var allTypes:Array = new Array(imageTypes);

            private function init():void
            {

                currentState='';
                fr=new FileReference();

                fr.addEventListener(Event.OPEN, onOpen);
                fr.addEventListener(Event.COMPLETE, onComplete);
                fr.addEventListener(Event.SELECT, onSelect);
                fr.addEventListener(Event.CANCEL, onCancel);
                fr.addEventListener(ProgressEvent.PROGRESS, onProgress);

                fr.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                fr.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityErrorHandler);

                browse();

            }

            private function onOpen(e:Event):void
            {
                pb.label="%3%%";
            }

            private function browse():void
            {
                fr.browse(allTypes);
            }

            private function onComplete(e:Event):void
            {
                currentState='fim';

                var dados:Object = new Object();
                dados.tipo = tipo;
                var myEventObj:GenEvent = new GenEvent("fimUpload",dados );
                dispatchEvent( myEventObj );

            }

            private function onSelect(e:Event):void
            {

                fich.text = fr.name;
                var request:URLRequest=new URLRequest(phpFile);
                fr.upload(request);
                //pb.visible = true;
            }
            private function onCancel(e:Event):void
            {

                //fechar();

            }

            private function onProgress(e:ProgressEvent):void
            {
                pb.setProgress(e.bytesLoaded, e.bytesTotal);
            }

            private function ioErrorHandler(event:IOErrorEvent):void
            {

                Alert.show("IO Error in uploading file.", "Error");
                fr.cancel();
                clearUpload();

            }

            private function
securityErrorHandler(event:SecurityErrorEvent):void
            {
                Alert.show("security Error in uploading file.", "Error");
                fr.cancel();
                clearUpload();

            }


            private function clearUpload():void
            {

                fr.removeEventListener(Event.OPEN, onOpen);
                fr.removeEventListener(Event.COMPLETE, onComplete);
                fr.removeEventListener(Event.SELECT, onSelect);
                fr.removeEventListener(Event.CANCEL, fechar);
                fr.removeEventListener(ProgressEvent.PROGRESS, onProgress);

                fr.removeEventListener(IOErrorEvent.IO_ERROR,
ioErrorHandler);
                fr.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityErrorHandler);
                fr.cancel();

            }



        private function fechar():void
        {

            PopUpManager.removePopUp(this);

        }


        ]]>
    </mx:Script>
    <mx:Label y="40" text="PHP: {phpFile}" horizontalCenter="0"
color="#B31414" fontSize="14"/>
    <mx:Label id="fich" text="" enabled="true" width="100%" y="63"/>
        <mx:ProgressBar width="100%" id="pb" mode="manual" y="84"/>
        <mx:Button click="init()" x="10" y="10" label="Button"/>



</mx:TitleWindow>

--~--~---------~--~----~------------~-------~--~----~
Recebeu esta mensagem porque está inscrito em Grupo "Mailing List da Comunidade 
Portuguesa de Rich Internet Applications - www.riapt.org" do Grupos Google.
 Para enviar mensagens para este grupo, envie um email para 
[email protected]
 Para anular a inscrição neste grupo, envie um email para 
[email protected]
 Para mais opções, visite este grupo em 
http://groups.google.com/group/riapt?hl=pt-PT
-~----------~----~----~----~------~----~------~--~---

Responder a