I’m loading Mp3 files with the greensock loadermax MP3Loaders and then using push(event.target.content) to store them in the array, notesArray. When I trace(notesArray); I get :
[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound],[object Sound]
so event.target.content is a sound object that contains the mp3?
But when i trace(notesArray[0]); I get:
undefined
Why? how can i access each sound object/ mp3 as an index of the array? what am i doing wrong?
here is the code:
package {
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
public class NoteLoader {
private var queue:LoaderMax;
public var notesArray:Array = [];
public var note2_A;
public var note2_A_S;
public var note2_B;
public var note2_C;
public var note2_C_S;
public var note2_D;
public var note2_D_S;
public var note2_E;
public var note2_F;
public var note2_F_S;
public var note2_G;
public var note2_G_S;
public function NoteLoader() {
queue = new LoaderMax({name:"mainQueue", onComplete:completeHandler});
queue.append(note2_A = new MP3Loader("2_A.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_A_S = new MP3Loader("2_A#.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_B = new MP3Loader("2_B.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_C = new MP3Loader("2_C.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_C_S = new MP3Loader("2_C#.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_D = new MP3Loader("2_D.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_D_S = new MP3Loader("2_D#.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_E = new MP3Loader("2_E.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_F = new MP3Loader("2_F.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_F_S = new MP3Loader("2_F#.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_G = new MP3Loader("2_G.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.append(note2_G_S = new MP3Loader("2_G#.mp3", {autoPlay:false,estimatedBytes:25000 }) );
queue.prependURLs("Notes/");
queue.load();
}
function completeHandler(event:LoaderEvent):void {
notesArray.push(event.target.content);
// trace(notesArray[0]); undefined????????
}
}
}
Thanks!