0

这是我第一次使用 ActionScript 编写网站。该网站的构建方式非常简单,有五个主要页面,它们通过静态导航栏上的按钮连接(第一页,主页,没有相应的按钮)。其中两个页面(故事和人物)正确淡入,没有问题。但其他两页(世界和附加)不淡入,他们只是跳转到页面,我得到这个错误:

 TypeError: Error #1009: Cannot access a property or method of a null object reference.  
    at fl.transitions::Tween/setPosition()  
    at fl.transitions::Tween/set position()  
    at fl.transitions::Tween()  
    at Gowang_fla::MainTimeline/frame85()  
    at flash.display::Sprite/constructChildren()  
    at flash.display::Sprite()  
    at flash.display::MovieClip()  
    at flash.display::MovieClip/gotoAndStop()  
    at Gowang_fla::MainTimeline/clickExtras()

我被告知要检查并确保我所有的命名都是正确的,据我所知,这一切都是正确的。影片剪辑的标记方式与代码中引用它们的方式相同,但只有四分之二的工作。当我对另外两个使用相同的代码和命名约定时,为什么只有 twop 起作用?

如果有人可以提供帮助,我将不胜感激。

~这里是 .FLA:

〜这是我在与我要淡入淡出的页面相对应的每个框架标签上使用的代码:

var storyTween:Tween = new Tween(story_mc, "alpha", Regular.easeOut , 0, 1, 2, true);
var worldTween:Tween = new Tween(world_mc, "alpha", Regular.easeOut , 0, 1, 2, true);  
var topTween:Tween = new Tween(top_mc, "alpha", Regular.easeOut , 0, 1, 2, true);
var extrasTween:Tween = new Tween(extras_mc, "alpha", Regular.easeOut , 0, 1, 2, true);      

〜这是网站的完整代码:

stop();

//Fade Effect

import fl.transitions.Tween;
import fl.transitions.easing.*;

var homeTween:Tween = new Tween(home_mc, "alpha", Regular.easeOut , 0, 1, 2, true);

//Buttons

story_btn.addEventListener(MouseEvent.CLICK, clickStory);
world_btn.addEventListener(MouseEvent.CLICK, clickWorld);
characters_btn.addEventListener(MouseEvent.CLICK, clickCharacters);
extras_btn.addEventListener(MouseEvent.CLICK, clickExtras);

home_mc.storyH_btn.addEventListener(MouseEvent.CLICK, clickStoryH);
home_mc.worldH_btn.addEventListener(MouseEvent.CLICK, clickWorldH);
home_mc.charactersH_btn.addEventListener(MouseEvent.CLICK, clickCharactersH);
home_mc.extrasH_btn.addEventListener(MouseEvent.CLICK, clickExtrasH);

top_mc.gowang_btn.addEventListener(MouseEvent.CLICK, clickGowang);
top_mc.ayame_btn.addEventListener(MouseEvent.CLICK, clickAyame);
top_mc.evora_btn.addEventListener(MouseEvent.CLICK, clickEvora);
top_mc.rogin_btn.addEventListener(MouseEvent.CLICK, clickRogin);
top_mc.toraz_btn.addEventListener(MouseEvent.CLICK, clickToraz);
top_mc.naomi_btn.addEventListener(MouseEvent.CLICK, clickNaomi);
top_mc.rummy_btn.addEventListener(MouseEvent.CLICK, clickRummy);
top_mc.teeth_btn.addEventListener(MouseEvent.CLICK, clickTeeth);
top_mc.sichan_btn.addEventListener(MouseEvent.CLICK, clickSichan);

extras_mc.blog_btn.addEventListener(MouseEvent.CLICK, clickBlog);

function clickBlog(event:MouseEvent):void
{
    navigateToURL(new URLRequest("http://www.gowangadventures.blogspot.com"), "_blank");
}

function clickGowang(evtObj:MouseEvent){
gotoAndStop("gowang", "Scene 1");
}
function clickAyame(evtObj:MouseEvent){
gotoAndStop("ayame", "Scene 1");
}
function clickEvora(evtObj:MouseEvent){
gotoAndStop("evora", "Scene 1");
}
function clickRogin(evtObj:MouseEvent){
gotoAndStop("rogin", "Scene 1");
}
function clickToraz(evtObj:MouseEvent){
gotoAndStop("toraz", "Scene 1");
}
function clickNaomi(evtObj:MouseEvent){
gotoAndStop("naomi", "Scene 1");
}
function clickRummy(evtObj:MouseEvent){
gotoAndStop("rummy", "Scene 1");
}
function clickTeeth(evtObj:MouseEvent){
gotoAndStop("teeth", "Scene 1");
}
function clickSichan(evtObj:MouseEvent){
gotoAndStop("sichan", "Scene 1");
}
function clickStory(evtObj:MouseEvent){
gotoAndStop("story");
}
function clickWorld(evtObj:MouseEvent){
gotoAndStop("world");
}
function clickCharacters(evtObj:MouseEvent){
gotoAndStop("characters");
}
function clickExtras(evtObj:MouseEvent){
gotoAndStop("extras");
}
function clickStoryH(evtObj:MouseEvent){
gotoAndStop("story", "Scene 1");
}
function clickWorldH(evtObj:MouseEvent){
gotoAndStop("world", "Scene 1");
}
function clickCharactersH(evtObj:MouseEvent){
gotoAndStop("characters", "Scene 1");
}
function clickExtrasH(evtObj:MouseEvent){
gotoAndStop("extras", "Scene 1");
}
4

1 回答 1

0

不知道为什么会这样,但似乎无法找到与 extras_mc 的实例名称关联的剪辑。我将您在第 85 帧上的代码更改为此,它工作正常:

var extras_mc = this.getChildByName('extras_mc')
var extrasTween:Tween = new Tween(extras_mc, "alpha", Regular.easeOut, 0, 1, 2, true);
于 2011-02-25T20:19:51.663 回答