PDA

View Full Version : Navigating to an array located in scene 2


mawilliams47
04-29-2008, 05:03 PM
New to Actionscript, an on going learning experince!

I have two scenes

Button on the first scene.
When click on the button, i would like it to navigate to scene 2 and call the array.

At the moment, it goes to scene 2 but only play the first video within the array.

Please please help before i headbutt the wall again! :confused:

my code so far

Scene 1 - actionscript

stop();

Stage.scaleMode = "noscale";

debt_btn.onRelease = function (){
gotoAndStop("Scene 2", 1);
this._target.mDisplay.stop();
this._target.mDisplay.activeVideoPlayerIndex = 0;
this._target.mDisplay.visibleVideoPlayerIndex = 0;
this._target.mDisplay.play();
};

filters_btn.onRelease = function (){
gotoAndStop("Scene 2", 1);
this._target.mDisplay.stop();
this._target.mDisplay.activeVideoPlayerIndex = 1;
this._target.mDisplay.visibleVideoPlayerIndex = 1;
this._target.mDisplay.play();
trace("has this worked")
};

scene 2 - actionscript


// Set Videos Behavior

// Create a videos object to hold a video
// playlist and event handler functions...
var videos:Object = new Object();

// Set up to 7 video feeds in a single component
videos.list = new Array();
videos.list[0] = "sourcing and filters.flv";
videos.list[1] = "debt cal.flv";
videos.list[2] = "";
videos.list[3] = "";
videos.list[4] = "";
videos.list[5] = "";
videos.list[6] = "";
videos.loop = false;
videos.length = 1;
videos.loaded = false;

// Path to FLVPlayback components
var m = this.mDisplay;

// Set the path of the first video feed
m.contentPath = videos.list[0];

// Set a 'ready' event handler to load the videos
videos.ready = function( evt:Object ):Void
{
if(!this.loaded){
this.loaded = true;
for( var n=1; n<this.list.length; n++ ){
if( videos.list[n].indexOf(".flv") != -1 ){
m.activeVideoPlayerIndex = n;
m.contentPath = videos.list[n];
this.length++;
}
}
m.activeVideoPlayerIndex = 0;
}
}
m.addEventListener("ready",videos);

// Set a 'complete' event handler to load the next video
videos.complete = function( evt:Object ):Void
{
var nextIndex = Number(evt.vp)+1;
if( nextIndex == this.length){
if( this.loop ){
nextIndex = 0;
}else{
return;
}
}
m.activeVideoPlayerIndex = nextIndex;
m.visibleVideoPlayerIndex = nextIndex;
m.play();
}
m.addEventListener("complete",videos);

// End Set Videos Behavior


Thank you for looking and your reply! :)

ushka
04-30-2008, 06:26 PM
This line:

var nextIndex = Number(evt.vp)+1

looks wrong. Try adding a trace statement to make sure "nextIndex" is actually the right index for the next video...

add:

trace(nextIndex);

after you declare the nextIndex var.

Also, you may want to put a few traces in your videos.complete function to see what's going on... if it has to be done in a browser and you can't trace, let me know and I'll show you a work around for this...