更新:修改标题,以更好地反映我的问题
大家好 :)
我今天的问题围绕着一个自定义事件我想送从一个子类到另一个。
我用我的自定义事件类从子类的事件传递给我的主类很好,但我不知道是谁做的子类之间。
我的自定义事件类
package src.events {
import flash.events.Event;
public class CustomEvent extends Event
{
public static const CHANGE:String="onChange";
public static const COMPLETE:String="onComplete";
public static const IMAGE_LOADED:String="onImageLoaded";
public static const SWF_LOADED:String="onSWFLoaded";
public static const SWF_UNLOAD:String="onSWFUnload";
public static const CLICK:String="onClick";
public static const PAUSE_MOVIE:String="onPause";
public static const INTRO_CLICKED:String="introClicked";
public var params:Object;
public function CustomEvent(type:String, params:Object, bubbles:Boolean = false, cancelable:Boolean = false)
{
super(type, bubbles, cancelable);
this.params=params;
}
public override function clone():Event
{
return new CustomEvent(type, this.params, bubbles, cancelable);
}
public override function toString():String
{
return formatToString("CustomEvent","params","type","bubbles","cancelable");
}
}
子类INTRO -分派事件
package src.display {
import gs.easing.*;
import gs.TweenLite;
import flash.text.*;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
// ☼ ----------------------------------------- Imported Custom Classes
import src.events.CustomEvent;
// ☼ ----------------------------------------- Intro Class
public class Intro extends Sprite
{
private var playBtn:MovieClip;
// ☼ ----------------------------------------- Constructor
public function Intro():void
{
this.addEventListener(Event.ADDED_TO_STAGE, init);
}
// ☼ ----------------------------------------- Init
public function init(event:Event):void
{
draw();
}
public function draw():void
{
playBtn = new PlayThumb;
playBtn.buttonMode = true;
playBtn.x = 582;
playBtn.y = 259;
playBtn.alpha = 1;
addChild(playBtn);
playBtn.addEventListener(MouseEvent.MOUSE_UP, clicked);
}
private function clicked(e:MouseEvent):void
{
trace("clicked big play");
dispatchEvent (new CustomEvent(CustomEvent.INTRO_CLICKED, {}));
trace("event = "+CustomEvent.INTRO_CLICKED);
}
}
子类导航-在我听该事件需要调用导航类的内部此功能:
function introPlayButtonClick(e:CustomEvent):void
{
trace("introPlayButtonClick called");
TweenLite.to(buttons[0], 1, {y:20, ease:Strong.easeOut});
TweenLite.to(buttons[1], 1, {y:navBtnY, ease:Strong.easeOut});
TweenLite.to(introTab, 1, {y:60, ease:Strong.easeOut});
TweenLite.to(scrollerMov, 1, {y:60, ease:Strong.easeOut});
$btn1 = true;
$btn2 = false;
trace("introPlayButtonClick called --- end");
}
好了,所以我相信我的问题就出在导航类,我如何正确地在这里添加的addEventListener? 我没有得到任何的痕迹在我introPlayButtonClick功能。
它在我的主类的工作原理与PAUSE_MOVIE事件,是我通过变量名NV附事件监听到导航类:
nv.addEventListener("onPause", pauseMovie); // Inside of MAIN class
但自从我加入了事件侦听器的导航类里面的INTRO_CLICKED事件我以为所有我需要的是(这)增加,但到目前为止,我没有收到该事件触发。
任何想法,建议,想法?