1 Reply Latest reply on Jan 29, 2007 12:56 AM by Peter Lorent

    multi events (addlistener(list[i])) how ?

    Jamal_Soueidan
      Hello their,

      I searched the whole Internet for tutorials on how to make multi events ... and couldn't find anything related to that, so I thought their must be someone here can help me out :)

      I'm trying to make multi files upload thing, I'm using FileReferenceList object, I have button called (Browse) whenever you click and choose files a new FileReferenceList is created and added to fileList:array

      [PHP]submitBrowse.onPress = function()
      {
      var i:Number = fileList.length;
      fileList = new FileReferenceList();
      fileList
      .browse(allTypes);
      trace('submit end ' + fileList.length + ":" + i);
      }[/PHP]

      Now I have few events like below.

      [PHP]listener.onComplete = function(file:FileReference):Void {
      trace("onComplete: " + file.name);
      }[/PHP]

      Now when someone click on upload, the code runs as below.

      [PHP]submitRemove.onPress = function()
      {
      trace(fileList.length);
      for(var i=0; i<fileList.length;i++)
      {
      fileList .addListener(listener);
      var list:Array = fileList .fileList;
      var item:FileReference;
      for(var l:Number = 0; l < list.length; l++) {
      item = list[l];
      trace(item.name);
      item.upload("progress.php");
      }

      }
      }[/PHP]

      Now everything seems somehow working but the event (listener.onComplete) never occer even if I added it like this fileList .addListener(listener);, which I feel is incorrect?
      Thats my problem and I hope someone can tell me how to fix it :)


      Thanks in advance for your kind help :)

      //HW2002
        • 1. Re: multi events (addlistener(list[i])) how ?
          Peter Lorent Level 2
          >>I searched the whole Internet for tutorials

          Well, that's a waste of time when you can find the answer in the help files - just hit F1 in Flash and search for 'FileReferenceList'. Now, in the event summary list you will see that a FileReferenceList object doesn't fire an event 'onComplete'. The object that fires the event onComplete is the FileReference object.
          The same documentation shows an example of how to use the FileReferenceList.