跳到框架

时间:2016-08-13 08:27:00

标签: actionscript-3 flash movieclip flash-cs6

我正在开发Air桌面应用程序。在某个时候,当用户按下一个按钮时,它会跳转到一个特定的帧,问题是在进入那个帧之后,虽然从一开始就读取了那个帧的舞台上的一些Movieclips,但是没有读取它们。

发生以下错误。

  

错误#1009:无法访问null对象的属性或方法   参考

我不知道为什么他不能阅读已经在舞台上的内容,我猜这是与图层排列有关的事情。我注意到有时虽然我发现它不符合逻辑,但它应该读取同一帧中的ALL,只要它停在它上面,对吧?

该项目如下:
1)在开始时介绍一个介绍,然后进入课程的第一帧 2)在第一帧,用户选择5个按钮中的一个进行点击,根据每个按钮进入不同的框架 3)当用户处于任何帧时,如果他点击后退按钮,它应返回到主框架,此按钮命令为gotoAndStop(1),并且某些条件removeChild()从代码生成的任何对象中清除阶段取决于调用函数的框架。
4)单击此后退按钮时出现问题,前5个按钮中的一个或多个按钮突然消失,并且出现错误 - 由于某种未知原因 - 程序无法读取任何错误更多,它无法读取任何事件并产生上述错误。 我的代码如下:

var myLettersLoader:URLLoader= new URLLoader();
mainMenu.addEventListener(MouseEvent.CLICK,gotomainMenu);
letters.addEventListener(MouseEvent.CLICK,showLetters);
lessons.addEventListener(MouseEvent.CLICK,showLessons);
revision.addEventListener(MouseEvent.CLICK,showRevision);
myLettersLoader.load(new URLRequest("data/letters/letters.xml"));
myLettersLoader.addEventListener(Event.COMPLETE,loadXML);
function showLetters(e:MouseEvent)
{

    //gotoAndStop(2)
    //aaaaa.alpha=1;
    //aaaaa.visible=true;
    Tweener.addTween(e.currentTarget, {width:originalWidth,height:originalHeight, time:0.25, transition:"linear"});
    myPlace.visible = true;
    myPlace2.visible = false;
    myPlace3.visible = false;
    jewels.visible = false;
    mainContainer.visible=false;
    close.visible=false;
    studentBook.visible = false;
    mainButton = e.currentTarget.name;
    Tweener.addTween(myPlace, {alpha:1, transition:"linear"});
    lettersContainer.visible=true;

    Tweener.addTween(letterContainerText, {alpha:1, transition:"linear"});

    for (var i=1; i<29; i++)
    {

        var letter = "L" + i;

        myPlace[letter].id = i;
        myPlace[letter].alpha = 1;
        myPlace[letter].addEventListener(MouseEvent.CLICK,gotoLetterFrame);
        myPlace[letter].buttonMode = true;
    }
}
function showLessons(e:MouseEvent)
{
    Tweener.addTween(e.currentTarget, {width:originalWidth,height:originalHeight, time:0.25, transition:"linear"});
    myPlace.visible= false;
    myPlace2.visible = true;
    myPlace3.visible = false;
    jewels.visible = false;
    mainContainer.visible=false;
    close.visible=false;
    studentBook.visible = false;
    lettersContainer.visible=true;
    mainButton = e.currentTarget.name;
    Tweener.addTween(myPlace2, {alpha:1, transition:"linear"});
    studentBook.alpha = 0;
    for (var i=0; i<5; i++)
    {
        var lesson = "Lesson" + i;
        myPlace2[lesson].id = i;
        myPlace2[lesson].alpha = 1;
        myPlace2[lesson].addEventListener(MouseEvent.CLICK,gotolessonFrame);
        myPlace2[lesson].buttonMode = true;
    }
}

//=======================Revision functions==================================
function showRevision(e:MouseEvent)
{
    Tweener.addTween(e.currentTarget, {width:originalWidth,height:originalHeight, time:0.25, transition:"linear"});
    myPlace.visible= false;
    myPlace2.visible = false;
    myPlace3.visible = true;
    jewels.visible = false;
    mainContainer.visible=false;
    close.visible=false;
    studentBook.visible = false;
    lettersContainer.visible=true;
    mainButton = e.currentTarget.name;
    Tweener.addTween(myPlace3, {alpha:1, transition:"linear"});
    studentBook.alpha = 0;
    for (var i=0; i<7; i++)
    {
        var revision = "Revision" + i;
        myPlace3[revision].id = i;
        myPlace3[revision].alpha = 1;
        myPlace3[revision].addEventListener(MouseEvent.CLICK,gotoRevisionFrame);
        myPlace3[revision].buttonMode = true;
    }
}
//========================================================
function gotoLetterFrame(e:MouseEvent)
{
    reloadButton.visible=true;
    mainMenu.visible=true;
    myClose.visible=true;
    reloadButton.visible=true;
    myNext.visible=true;

    currentTarget=(e.currentTarget.id-1);
    currentName = arrOfLetters[currentTarget];
    xmlListOfClass=new XMLList(myxml.letter.(@id==currentName).children());
    gotoAndStop(xmlListOfClass[counter].localName());
    abc.visible=abcd.visible=true;
    mainMenu.buttonMode=true;
}
function gotolessonFrame(e:MouseEvent)
{
    reloadButton.visible=true;
    mainMenu.visible=true;
    myClose.visible=true;
    reloadButton.visible=true;
    myNext.visible=true;
    currentTarget=(e.currentTarget.id);
    xmlListOfClass = new XMLList(lessonsArr[currentTarget].lesson.children());
    gotoAndStop(xmlListOfClass[counter].localName());
    abc.visible=abcd.visible=true;
    mainMenu.buttonMode=true;
}
function gotoRevisionFrame(e:MouseEvent)
{
    reloadButton.visible=true;
    mainMenu.visible=true;
    myClose.visible=true;
    reloadButton.visible=true;
    myNext.visible=true;
    currentTarget=(e.currentTarget.id);
    myRevisionLoader.load(new URLRequest("data/revisions/"+currentTarget+"/revision.xml"));
    myRevisionLoader.addEventListener(Event.COMPLETE,loadRevisionXML);
}
//=====================================
function loadLessonXML(e:Event)
{
    lessonsArr[xx] = new XML(e.target.data);
    xx++;
}
//==============================For revision==================================
function loadRevisionXML(e:Event)
{
    revisionArr = new XML(e.target.data);
    xmlListOfClass = new XMLList(revisionArr.revision.children());
    gotoAndStop(xmlListOfClass[counter].localName());
    abc.visible=abcd.visible=true;
    mainMenu.buttonMode=true;
}
function loadXML(e:Event)
{
    myxml = new XML(e.target.data);
}
//====================================
function gotomainMenu(e:MouseEvent)
{
    gotoAndPlay(1);
}

此代码位于第一帧,第二帧位于按钮mainButton 是返回第1帧的按钮 返回第1帧时,按钮lessonslettersrevision会消失,或者其中一个按钮有时没有逻辑原因

0 个答案:

没有答案