actionscript 3 - Flash allocation scheme, bug or feature? -


having following code:

var loadingsoundtitle:string; var loadingsound:sound = new sound(); function loadfile(str:string) {     loadingsound = new sound(); //(1)     loadingsoundtitle = str;     try     {         loadingsound.load(new urlrequest(loadingsoundtitle));     }     catch(err:error)     {         trace(err.message);     } } 

doesn't work if line marked (1) there, if comment out line, able load 1 single file, before stops working.

using actionscript 3.0 under cs5

edit: i'm new flash!

loadingsound.addeventlistener(event.complete, function(e:event) {     list.additem({label:loadingsoundtitle, data:loadingsound});     process.value = 0; //for nice little processbar got :) }); 

there's lot that's missing here. think see problem though. firstly, as3 livedocs tell sound object instance can load 1 , 1 external mp3, it's no surprise removing line marked //(1) work, 1 time.

the other problem see here when do include line marked //(1), you're never calling loadingsound.addeventlistener(event.complete, oncompletehandler) or like. might adding old sound object (if are, isn't depicted here), you're not adding new one. no way new sound report it's finished loading there's no way play after it's done because never know when it's done.

instead of repeatedly loading sound on , over, better way handle load sound 1 time , play needed.

edit:

now see listener code, i'm positive that's problem.

  1. it's not inside function call after creating new sound object. have add new listener every new object instance create.
  2. it's using anonymous, unbound function.

you'd have add function every time create new sound, not first time.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -