【发布时间】:2010-04-11 19:50:09
【问题描述】:
我有一个 Document 类、Intro 类和 Nav 类。
Intro 类首先运行,然后发送自定义调度事件以运行 Nav 类,但我收到此错误:
removed Intro
ArgumentError: Error #1063: Argument count mismatch on com.secrettowriting.StanPlayer.ui::Navigation/addNav(). Expected 0, got 1.
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.secrettowriting.StanPlayer.display::Intro/removeIntro()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Navigation 类中的 addNav 函数应该有 0 个参数/变量,并且我没有向它发送任何参数/变量,这就是为什么我对它为什么说我得到 1 感到困惑。
(1) 运行,附加完整的监听器
private function drawIntro():void
{
intro = new Intro();
intro.drawIntro();
intro.addEventListener("onComplete", nav.addNav);
stage.addChild(intro);
}
(2) 在 Intro 类中,此函数将触发并发送调度事件,但我在跟踪语句之后立即收到该错误。
private function removeIntro(e:TimerEvent):void
{
if (n < 10){
n++
} else if (n == 10){
introRemover.removeEventListener(TimerEvent.TIMER, removeIntro);
removeChild(introMov);
trace("removed Intro");
dispatchEvent (new CustomEvent(CustomEvent.COMPLETE, {})); // → Intro to Navigation
}
}
(3)然后假设在导航中触发此功能
public function addNav():void
{
trace("addNav ----");
addChild(weAreA);
addChild(introText);
addChild(chooseAVideo);
TweenLite.to(weAreA, 2, {alpha:1});
TweenLite.to(introText, 3, {alpha:1});
TweenLite.to(introText, 3, {alpha:1});
}
类代码 ------------------------------------ --------------------------
我的文档类:
public function HomePlayer():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
// Use when Live
//videoURL = this.loaderInfo.parameters.theVIDEO; // Get the Video URL from HTML
// Remove when video testing ready
videoURL = "videos/WhatDifferentiatesUs.flv";
drawNav();
drawIntro();
}
private function drawIntro():void
{
intro = new Intro();
intro.drawIntro();
intro.addEventListener("onComplete", nav.addNav);
stage.addChild(intro);
}
private function drawNav():void
{
nav = new Navigation();
nav.drawNav();
stage.addChild(nav);
}
介绍类:
Public function Intro():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
}
public function drawIntro():void
{
introMov = new IntroMov();
introMov.alpha = 0;
addChild(introMov);
TweenLite.to(introMov, 3, {alpha:1});
// Timer
introFader = new Timer(INTRO_DELAY);
introFader.addEventListener(TimerEvent.TIMER, fadeIntro);
introFader.start();
introRemover = new Timer(INTRO_DELAY);
introRemover.addEventListener(TimerEvent.TIMER, removeIntro);
}
private function fadeIntro(e:TimerEvent):void
{
if (i < 30){
i++
} else if (i == 30){
TweenLite.to(introMov, 1.5, {alpha:0});
introFader.removeEventListener(TimerEvent.TIMER, fadeIntro);
introRemover.start();
}
}
private function removeIntro(e:TimerEvent):void
{
if (n < 10){
n++
} else if (n == 10){
introRemover.removeEventListener(TimerEvent.TIMER, removeIntro);
removeChild(introMov);
trace("removed Intro");
dispatchEvent (new CustomEvent(CustomEvent.COMPLETE, {})); // → Intro to Navigation
}
}
导航类函数:
public function drawNav():void
{
weAreA = new WeAreA();
weAreA.alpha = 0;
weAreA.x = 20;
weAreA.y = 35;
introText = new IntroText();
introText.alpha = 0;
introText.x = 20;
introText.y = 124;
chooseAVideo = new ChooseAVideo();
chooseAVideo.alpha = 0;
chooseAVideo.x = 20;
chooseAVideo.y = 336;
}
public function addNav():void
{
addChild(weAreA);
addChild(introText);
addChild(chooseAVideo);
TweenLite.to(weAreA, 2, {alpha:1});
TweenLite.to(introText, 3, {alpha:1});
TweenLite.to(introText, 3, {alpha:1});
}
【问题讨论】:
标签: flash actionscript-3 function arguments