PDA

View Full Version : bulkLoader breaks with flv?? Help!!



flashpipe
November 16th, 2009, 01:36 PM
I'm using bulkLoader to load an mp3 and an flv using their simple-example.as

It works fine if I make the SimpleExampleMain the file's class, loads sound and video and plays them both when they're finished. However, if I DON'T make it the class and just use:

var se:SimpleExampleMain=new SimpleExampleMain();it loads both, plays the audio fine, but doesn't show the video?? It says that it's loaded, but it doesn't show anything. NOTHING is different except it's not the file Class...

Any ideas???

Here's the SimpleExampleMain.as:

package{
import br.com.stimuli.loading.BulkLoader;
import br.com.stimuli.loading.BulkProgressEvent;
import flash.events.*;
import flash.display.*;
import flash.media.*;
import flash.net.*;

public class SimpleExampleMain extends MovieClip{
public var loader : BulkLoader;
public var v : Video;
public var counter : int = 0;

// simple example with few features
public function SimpleExampleMain() {
// creates a BulkLoader instance with a name of "main-site", that can be used to retrieve items without having a reference to this instance
loader = new BulkLoader("main-site");
// set level to verbose, for debugging only
loader.logLevel = BulkLoader.LOG_VERBOSE;
// now add items to load
// add a video, and force it to load paused
loader.add("videoPath.flv", {maxTries:6, id:"the-video", pausedAtStart:true});
// of course, options can be combined:
loader.add("audioPath.mp3", {"id":"soundtrack", maxTries:1, priority:100});

// dispatched when ALL the items have been loaded:
loader.addEventListener(BulkLoader.COMPLETE, onAllItemsLoaded);

// dispatched when any item has progress:
loader.addEventListener(BulkLoader.PROGRESS, onAllItemsProgress);

// now start the loading
loader.start();
}

public function onAllItemsLoaded(evt : Event) : void{
trace("every thing is loaded!");
// attach the vĂ*deo:
var video : Video = new Video();
// get the nestream from the bulkloader:
var theNetStream : NetStream = loader.getNetStream("the-video");
trace("theNetStream "+theNetStream);
addChild(video);
video.attachNetStream(theNetStream);
theNetStream.resume();
video.y = 300;
trace("video.y "+video.y);

// get the sound:
var soundtrack : Sound = loader.getSound("soundtrack");
soundtrack.play();

}

// this evt is a "super" progress event, it has all the information you need to
// display progress by many criterias (bytes, items loaded, weight)
public function onAllItemsProgress(evt : BulkProgressEvent) : void{
trace(evt.loadingStatus());
}
}
}

creatify
November 16th, 2009, 03:36 PM
did you add your instance to the stage?

var se:SimpleExampleMain=new SimpleExampleMain();
addChild(se);

flashpipe
November 16th, 2009, 07:32 PM
OMG!! That's it!! Thank you...

So, not sure I understand why it worked as the movie Class but not if called from the movie? I'm guessing it's because the movie acts as it's own "instance"?
But why would it load both and play the audio and just not play the flv?

Not that I need to know, just curious if you knew the details...

Thank you!! Posted to 4 different forums and this is the first reply and it works!!

:)