I have a ListItem class attached to a movieClip in the library.
There is an instance of the ListItem on stage with an instance name of: mcListItem1
Here is the ListItem class
import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.events.EventDispatcher;
class net.tread1.PTListItem extends MovieClip{
//Class Variables
private var markTween:Tween; //Tween for fading in checkmark
private var boxTween:Tween; //Tween for fading in checkbox
private var textTween:Tween; //Tween for fading in text
private var marked:Boolean; //Boolean to store if ListItem is marked or not
private var origY:Number; //Original y coordinate of the ListItem
private var itemNumber:Number; //The number of the mc the item relates too
//Class Objects
private var txtText:TextField; //The textfield in the listItem (txtText)
private var checkMark:MovieClip;//The checkmark in the listItem (mcCheck)
private var checkBox:MovieClip; //The checkbox in the listItem (mcCheckbox)
//Class Constants/Statics
private static var TEXT;
private static var CHECKMARK;
private static var CHECKBOX;
private static var ITEM_START_ALPHA = 0; //The alpha each list item starts at
private static var END_ALPHA = 100; //The alpha each list item ends at when faded in
//EventDispatcher Constants
private static var addEventListener:Function;
private static var removeEventListener:Function;
private static var dispatchEvent:Function;
//Class Constructor
public function PTListItem(){
//Wait until this item is loaded
this.onLoad = function():Void{
//Initialize EventDispatcher
EventDispatcher.initialize(this);
//Initialize all non-constant variables
init();
//Set event dispatchers
setDispatchers();
}
}//END CONSTRUCTOR
private function init():Void{
//Stop the list movieclip
this.stop();
//Initialize runtime constants
TEXT = this['txtText'];
CHECKMARK = this['mcCheck'];
CHECKBOX = this['mcCheckbox'];
//Initialize variables
marked = false;
origY = this._y;
//Set alphas
//TEXT._alpha = ITEM_START_ALPHA;
//CHECKMARK._alpha = ITEM_START_ALPHA;
//CHECKBOX._alpha = ITEM_START_ALPHA;
}//END INIT
private function setDispatchers():Void{
this.onRollOver = function(){
dispatchEvent({type:'light', target:this, object:1});
trace("dispatching Event");
}
}
}//END CLASS
Here is the code from the main timeline of the .fla where I then try to catch the event being dispatched:
import mx.utils.Delegate;
function handleConstruct(evt):Void{
trace("inside handle event");
trace(evt.type);
trace(evt.target);
trace(evt.object);
}
mcListItem1.addEventListener('light', Delegate.create(this,handleConstruct));
This is line for line from a tutorial I found and the code is in accordance with several other tutorials I found yet the event is either not being dispatched or it’s not being heard because the only trace I get is from the trace line after the dispatchEvent.
Any help would be appreciated.