mercredi 24 juin 2015

dispatch event not fired in action script 2.0

I have created a class named CheckBoxSelectAll in which I am triggering an event as below.

import mx.events.EventDispatcher;
import flash.filters.GlowFilter;
class CheckBoxSelectAll  
{
    public function dispatchEvent() {};
    public function addEventListener() {};
    public function removeEventListener() {};

    private var checkbox_mc:MovieClip;
    private var parent_mc:MovieClip;                        

    function CheckBoxSelectAll()
    {
        mx.events.EventDispatcher.initialize(this);
    }

    function CreateCheckBox(c_mc:MovieClip)
    {                               
        var labelGlow:GlowFilter = new GlowFilter(0xFFFFFF, .30, 4, 4, 3, 3);
        var labelFilters:Array = [labelGlow];

        this.parent_mc = c_mc;                  
        checkbox_mc = parent_mc.createEmptyMovieClip("",this.checkbox_mc.getNextHighestDepth() );

        checkbox_mc._x =450;// boxX;
        checkbox_mc._y =143;// boxY;
        checkbox_mc.lineStyle(1, 0);
        checkbox_mc.beginFill(currentFill, currentAlpha);
        checkbox_mc.moveTo(0, triSize);
        checkbox_mc.lineTo(triSize, triSize);
        checkbox_mc.lineTo(triSize, 0);
        checkbox_mc.lineTo(0, 0);
        checkbox_mc.lineTo(0, triSize);
        checkbox_mc.endFill();              
        checkbox_mc._visible = true;
        checkbox_mc.onPress = function() {
            var eventObject:Object = {target:this, type:'onDataReady'};                         
            dispatchEvent(eventObject);
            trace("OnPress refresh...");
        }
    }   
}

In Parent movie clip, used following code

var select_all_listener:Object = new Object();
select_all_listener.onDataReady = triggerDisksLoad;       

    var select_all_box:CheckBoxSelectAll;
    select_all_box = new CheckBoxSelectAll(); 
    select_all_box.addEventListener("onDataReady", select_all_listener);
    select_all_box.CreateCheckBox(this);

function triggerDisksLoad(evtObj) {     trace("triggerDisksLoad called...!!!"); }

Here function triggerDisksLoad is not called. Kindly suggest the fix for this.

Aucun commentaire:

Enregistrer un commentaire