I really think i didnt explain the real problem properly.

i did what u said without any problem. studied all documentation about 
fileReference too.

The point is that, IN ANOTHER POINT OF THE CODE, i wanna send the files.
the on_select is not useful for me. i will not send anything on_select, just 
put a pair of lines of code there.

But later, user will click the button SEND, and send all the files that he 
actually selected (with several browse() actions over several fileReference 
objects)

so when user click SEND i should check for all FileReference Objects, and send 
ONLY the ones that where actually selected.

So i need a fileReference.selected:boolean function or property, but there is 
no function like that. I tried to access to any property from the object, like 
.name but it would crash my app if the file was not selected.

so finally, what i need is something like this:

if (myFileReference.selected()=true) { myFileReference.upload() }

i tried this, but crashes when file is not selected:

if (myFileReference.name.length>0) { myFileReference.upload() }

i guess i could create a myFRselected variable for EVERY fileReference i 
have...but is not really a nice option :/


thnx




----- Mensaje original ----
De: Jon Bradley <[EMAIL PROTECTED]>
Para: [email protected]
Enviado: jueves, 5 de junio, 2008 19:57:18
Asunto: Re: [flexcoders] know if .browse() was executed or not




On Jun 5, 2008, at 1:40 PM, David Pariente wrote:

Im not using a fileReferenceList, but a FileReference. And it seems i can't 
access any property of FileReference unless i have choosen a file. So there is 
no way to know if a file was selected.


Ok.  Then all you need to do is use FileReference instead of FileReferenceList. 
There is not much to change in the code.

Any attempt to get the .name property before the select event is dispatched 
will result in an IllegalOperationErr or (because you can't even look at name 
until Event.SELECT is dispatched).

So, in the onSelectFile method that I posted, .name will then be available - it 
will be null if no file was selected. Additionally, check the documentation on 
browse(). You might be doing something else funky that is wrong - such as 
messing with typelist and not providing descriptions or extension strings. 
There are a few things that would cause the browse() not to return true.

The following should work (not tested).

private var isBrowsingFile: Boolean = false;
private function addFiles():void 
{
myFileReference = new FileReference( );
if (!isBrowsingFile) {

 try
 {
isBrowsingFile  = myFileReference .browse() ;
myFileReference. addEventListener (Event.SELECT, onSelectFile) ;
 }
 catch (error:Error)
 {
isBrowsingFile = false;
 // Handle errors, or add listeners in the try block for errors
 // This is where you would get the IllegalOperationErr or

 }
}
else

{

trace("already browsing for a file");

}
}

// Called when file is selected
private function onSelectFile( event:Event) :void
{
isBrowsingFile = false;
if (myFileReference. name)
{
// whatever you want to do with the selected file
}
else
{
//no file selected
}
}

good luck with it,

jon
    


      ______________________________________________ 
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.

Reply via email to