Actionscript 3 切换场景时出现问题,flvplayback场景在完全加载时自动加载,无法启动

Actionscript 3 切换场景时出现问题,flvplayback场景在完全加载时自动加载,无法启动,actionscript-3,flash,Actionscript 3,Flash,这是我的代码: stop(); import flash.events.Event; import fl.video.*; var files:Array; var shuffledFiles:Array; loaderInfo.addEventListener(Event.COMPLETE,ready); function ready(event:Event):void{ loaderInfo.removeEventListener(Event.COMPLETE,ready);

这是我的代码:

stop();
import flash.events.Event;
import fl.video.*;

var files:Array;
var shuffledFiles:Array;

loaderInfo.addEventListener(Event.COMPLETE,ready);

function ready(event:Event):void{
    loaderInfo.removeEventListener(Event.COMPLETE,ready);
    //swf rescale setup
    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.addEventListener(Event.RESIZE,stageResized);
    //get FlashVars - a string converted into an Array by spliting it on the , character
    //if the files FlashVar is setup correctly use the data, else use default values
    if(loaderInfo.parameters.files != undefined) files = loaderInfo.parameters.files.indexOf(',') > 0 ? loaderInfo.parameters.files.split(",") : [loaderInfo.parameters.files];
    else files = [ "movie1.flv", "movie2.flv", "movie3.flv" ];
    shuffledFiles = shuffleArray(files);
    //play the 1st video
    videoPlayer.source = shuffledFiles[0];
    shuffledFiles.shift();

    //see when the video finished playing
    videoPlayer.addEventListener(Event.COMPLETE,videoFinished);
}
function videoFinished(event:Event):void{
    if(shuffledFiles.length == 0) shuffledFiles = shuffleArray(files);//all files played, repeat process
    videoPlayer.source = shuffledFiles[0];//play the first video in the random list
    videoPlayer.play();
    trace('playing',shuffledFiles[0]);

    shuffledFiles.shift();//remove the first video from the random list (e.g. [2,0,1].shift() becomes [0,1])
}
function stageResized(event:Event):void{
    videoPlayer.width = stage.stageWidth;
    videoPlayer.height = stage.stageHeight;
}
function shuffleArray(source:Array,clone:Boolean = true):Array {
    var output:Array = [];
    var input:Array = clone ? [].concat(source) : source;//clone ? preserve orignal items by making a copy for shuffling, or not
    while(input.length) output.push(input.splice(int(Math.random() * input.length-1),1)[0]);
    return output;
}

function fl_ClickToGoToScene():void
{
    MovieClip(this.root).gotoAndPlay(2, "Scene 2");
}

function fl_ClickToGoToScene2():void
{
    MovieClip(this.root).gotoAndPlay(1, "Scene 1");
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
function myKeyDown(e:KeyboardEvent):void{
//trace("Key Pressed: " + String.fromCharCode(e.charCode) + " (character code: " + e.charCode + ")");
checkkeydown(String.fromCharCode(e.charCode));
}

function checkkeydown(keypress:String):void{
    //trace(keypress);
    if(keypress == "z"){
        fl_ClickToGoToScene();
    }
    else if(keypress == "x"){
        fl_ClickToGoToScene2();
    }
}
我试图做到: 2.游戏场景。 第一个场景,闪现自动播放的视频并永远重复,(动作脚本) 第二个场景,flash播放一段短蒙太奇(时间线)

问题: 当我运行代码时,第一个场景播放得很好, 当我切换到第二幕时,它也能播放得很好, 但当我重新切换到场景1时,flyplayback没有运行。 我可以毫无问题地重新切换到场景2

我不知道问题出在哪里。我完全不知道。提前打电话

编辑

首先我要停止();在代码顶部,因为它将在第一部电影结束后播放场景2。 然后我得到了trace('playing',shuffledFiles[0])的输出

播放电影1.flv

播放电影3.flv

播放电影2.flv

播放电影1.flv

TypeError:错误#1009:无法访问空对象引用的属性或方法。 在佛罗里达州praperkahwinan_::MainTimeline/videoFinished() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() 在fl.video::FLVPlayback/ at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() 在fl.video::VideoPlayer/ 在fl.video::VideoPlayer/

在第五个循环上按“z”时出错

这里链接到源文件


im不包括电影文件。您需要将3 flv movie、movie1.flv、movie2.flv、movie3.flv与源文件放在同一文件夹中。

确定洗牌方法中出错,无法正确克隆

试试看:

function shuffleArray(source:Array):Array {
    var output:Array = [];
    var input:Array = [].concat(source);
    while(input.length) output.push(input.splice(int(Math.random() * input.length-1),1)[0]);
    return output;
}

首先我要添加stop();在代码顶部,因为它将在没有它的情况下进入场景2。输出正在播放movie1.flv playing movie3.flv playing movie2.flv playing movie1.flv我能给你我的源文件吗?我对“x”按钮有问题。它确实返回到场景2,但为空..签出最新编辑,复制粘贴错误堆栈(如果有)没有错误,但是,在我按z键并按x键返回到场景1后,它不会播放。跟踪什么('playing',shuffledFiles[0]);返回?