开发者

AS3- Fader Tween only working on some movie clips but not all

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 .FLA:

~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_b开发者_如何学JAVAtn.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");
}


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:

var extras_mc = this.getChildByName('extras_mc')
var extrasTween:Tween = new Tween(extras_mc, "alpha", Regular.easeOut, 0, 1, 2, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜