AS3-Fader Tween 仅适用于某些影片剪辑,但并非全部
这是我第一次使用 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 可以工作?
如果有人可以提供帮助,我将非常感激。
~这是我在每个框架标签上使用的代码与我想要淡入淡出的页面相对应:
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");
}
This is my first time coding a website using ActionScript. The website is constructed in a very simple manner, there are five main pages and they are connected by buttons on a static navigation bar (the first page, home, doesn't have a corresponding button). Two of the pages (Story and Characters) fade-in correctly without problems. But the other two pages (The World and Extras) don't fade-in, they just jump to the page and I get this error:
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()
I was told to check and make sure all of my naming was correct, and as far as i've seen it all is. The movie clips are labeled the same way they are referenced in the codes, but only two out of four work. Why would only twop work, when I used the same code and naming conventions for the other two?
I would really appreciate if someone could help.
~Here is the code I used on each of the frame labels corresponding with the page I want to fade:
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);
~Here is the full code for the website:
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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道为什么会发生这种情况,但似乎无法找到与 extras_mc 实例名称关联的剪辑。我将第 85 帧上的代码更改为以下代码,效果很好:
Not sure why this would be happening like this, but it seems like it's not able to find the clip associated with the instance name of extras_mc. I changed your code on frame 85 to this and it worked fine: