Groups | Blog | Home
all groups > flash actionscript > january 2007 >

flash actionscript : multi events (addlistener(list[i])) how ?


Jamal Soueidan
1/28/2007 10:11:09 PM
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 [B]multi files upload[/B] thing, I'm using
[B]FileReferenceList[/B] object, I have button called (Browse) whenever you
click and choose files a new [B]FileReferenceList[/B] is created and added to
[B]fileList:array[/B]

[PHP]submitBrowse.onPress = function()
{
var i:Number = fileList.length;
fileList[i] = new FileReferenceList();
fileList[i].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[i].addListener(listener[i]);
var list:Array = fileList[i].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
[B](listener.onComplete)[/B] never occer even if I added it like this
[B]fileList[i].addListener(listener[i]);[/B], which I feel is incorrect? [U][I]
Thats my problem and I hope someone can tell me how to fix it :)[/I][/U]

Thanks in advance for your kind help :)

//HW2002
LuigiL
1/29/2007 8:56:27 AM
[quoted text, click to view]

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.
AddThis Social Bookmark Button