TwelvestoneFlash

filereference.addEventListener(Event.SELECT, onSelect);


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
baron ruhstoff
 
2008-09-12

Is there any particular reason why onSelect won't fire even after a file has been selected?

Here's what I'm working with:

    public function uploadFile():void{
        var fileref: FileReference = new FileReference();
        fileref.addEventListener(Event.SELECT, onSelect);
        fileref.browse([new FileFilter("Documents", "*.pdf;*.doc;*.txt;*.rtf")]);
    }

    private function onSelect(e:Event):void{
        trace("well whaddya know?  it worked!");
    }
baron ruhstoff
 
2008-09-12

Came across this in the docs: > if the FileReference object goes out of scope, any upload or download that is not yet completed on that object is canceled upon leaving the scope. Be sure that your FileReference object remains in scope for as long as the upload or download is expected to continue.

So that says it's a scoping issue. Thing is, it still doesn't work:

    var _fileref:FileReference = new FileReference();
    private function uploadFile():void{
        _fileref.addEventListener(Event.SELECT, onSelect);
        _fileref.browse([new FileFilter("Documents", "*.pdf;*.doc;*.txt;*.rtf")]);
    }

    private function onSelect(e:Event = null):void{
        trace("well whaddya know?  it worked!");
    }

:(

baron ruhstoff
 
2008-09-12

All righty... It looks as though a SELECT event only fires when the swf is in a browser. I'm assuming the same holds true for other types.

ass.pain++;

baron ruhstoff
 
2008-09-14

Originally posted by: baron ruhstoff All righty... It looks as though a SELECT event only fires when the swf is in a browser. I'm assuming the same holds true for other types.

ass.pain++;

Contributing further to the wtf quotient is the fact that the problem only occurs on a Mac. On a PC, running standalone through the IDE works fine.

lithium
 
2008-09-14

i think i ran into this issue a while ago. It's got something to do with the FileReference object being garbage collected too early. If you define the object in your applications scope, rather than inside a method it should work. e.g

var fileRef:FileReference;

function browse():void { fileRef = new FileReference(); // other stuff here. }

rather than

function browse():void { var fileRef:FileReference = new FileReference(); // other stuff here. }

hope it helps,

A.

[edit]Looks like you already tried that. Bummer k[/edit]

baron ruhstoff
 
2008-09-15

Thanks anyway! :thumbsoup:

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

filereference.addEventListener(Event.SELECT, onSelect);