Hello :)

your code is very light :)

try this :

import mx.events.EventDispatcher ;

class com.test.mvc.AbstractView{

   // ---o Constructor

   private function AbstractView() {

       // Abstract Class !!

   }

   // ----o Init EventDispatcher

   static private var __initDispatcher = EventDispatcher.initialize(
AbstractView.prototype) ;

   public var addEventListener:Function;
   public var removeEventListener:Function;
   public var dispatchEvent:Function;

   // ----o You Methods etc...

}

--------

import mx.utils.Delegate ;

class com.test.app.SampleView extends AbstractView{

   // ----o Constructor

   public function SampleView() {

       // your code in the constructor

   }

   // ----o Constants

   static public var LOAD_SOMETHING:String = "onLoadSomething" ;

   static private var __ASPF__ = _global.ASSetPropFlags(SampleView,
["LOAD_SOMETHING"], 7, 7) ;

   // ----o Public Properties

   public var test_mc:MovieClip ;

   // ----o Public Methods

   public function load_something(t):Void {

       test_mc = t.attachMovie("test_mc.jpg", "test_mc",
t.getNextHighestDepth());
       test_mc.onPress = Delegate.create(this, _onPress) ;

       // ---o Dispatch event

       var e = { type: LOAD_SOMETHING, target:this } ;

       dispatchEvent( { type: LOAD_SOMETHING , target:this} ); // test 1

   }

   // ----o Private Methods

   private function _onPress():Void {

       var e = { type: LOAD_SOMETHING, target:test_mc } ;

       dispatchEvent ( e ) ; // test 2

   }
}

or show more code please ;)

EKA+ :)


2006/6/8, Sam <[EMAIL PROTECTED]>:

Hi,
Is it possible to dispatch events from a simple call to a method?

I have a view class that extends an abstract view class that contains
the EventDispatcher  class.
I don't have a problem dispatching events from onPress and other
handler, but what if I want to dispatch an event when simply calling
a method?


class com.test.mvc.AbstractView{

     public var addEventListener:Function;
        public var removeEventListener:Function;
        public var dispatchEvent:Function;
}

class com.test.app.SampleView extends AbstractView{

        public function load_something(t)
        {
                test_mc = t.attachMovie("test_mc.jpg", "test_mc",
t.getNextHighestDepth());

                dispatchEvent({type:"onLoadSomething"}); //this does not
work

                test_mc.onPress = function(){
                        this._parent._parent.dispatchEvent
({type:"onLoadSomething", target:this});        //this works
                         }

        }
}


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to