Hello eka,

perhaps I can cotton up with (btw. is this good english?)
AsBroadcaster, since it is availablefrom flash version 6 and above.
:-)
But I can't find documentations about the set/get syntax you used. But
it works just perfect. And I guess this set and get keywords are
available within all classes, and thus in classes extending MovieClip,
too, right? That is an advantage to addProperty, which is only
available to Object.

You write "In my personnal AS2 OpenSource framework".. I guess, we all
have our own personnal AS2 OpenSource framework at home. :-) Currently
I try to implement layout mechanisms other than absolute coordinates.
This is, why I want this onX events and such things.

Thanks,
Matthias


2006/11/30, eka <[EMAIL PROTECTED]>:
ooops...  ui.addListener(this) ; is no necessary now in your test in my last
message;)

the

2006/11/30, eka <[EMAIL PROTECTED]>:
>
> Hello :)
>
> you can but a good event model use AsBroadcaster or other system to
> dispatch the events :) In my personnal AS2 OpenSource framework i use a
> event model compatible with W3C Dom3 event model for example (like AS3
> framework).... it's more easy to use a event model to dispatch information
> in callbacks methods ! If you want dispatch the information in your class...
> use this.addListener(this) and you can use onX method directly on your
> instance :)
>
> class MyUIObject
>  {
>
>     /**
>      * Constructor of the class.
>      */
>     public function MyUIObject()
>     {
>         this.addListener(this) ;
>      }
>
>     /**
>      * Inject addListener, removeListener and broadcastMessage methods in
> the prototype of the class.
>      */
>     static private var __INITBROADCASTER__ = AsBroadcaster.initialize(
> MyUIObject.prototype ) ;
>
>         // Public Properties
>
>     /**
>      * The code of this method is injected by the AsBroadcaster tool.
>      * Use this declaration in the AS2 compilation.
>      */
>     public var addListener:Function ;
>
>     /**
>      * The code of this method is injected by the AsBroadcaster tool.
>      * Use this declaration in the AS2 compilation.
>      */
>     public var broadcastMessage:Function ;
>
>     /**
>      * This method is empty but can be override by the user in this code
> to notify the x value modification.
>      */
>      public var onX:Function ;
>
>     /**
>      * The code of this method is injected by the AsBroadcaster tool.
>      * Use this declaration in the AS2 compilation.
>      */
>     public var removeListener:Function ;
>
>     /**
>      * (read-write) Returns the x position of the ui object.
>      */
>     public function get x():Number
>     {
>         return getX() ;
>     }
>
>     /**
>      * (read-write) Sets the x position of the ui object.
>      */
>     public function set x( value:Number ):Void
>     {
>         setX( value ) ;
>     }
>
>         // Public Methods
>
>     /**
>      * Returns the x position of the UI object.
>      */
>    public function getX():Number
>     {
>        return _x;
>    }
>
>     /**
>      * Sets the x position of the UI object.
>      */
>     public function setX( value:Number ):Void
>     {
>         _x = value ;
>          broadcastMessage("onX" , this, _x) ;
>    }
>
>         // Private Properties
>
>     /**
>      * The internal x position of the UI object.
>      */
>     private var _x:Number ;
>
> }
>
> And in your code :
>
> var ui:MyUIObject = new MyUIObject();
> ui.onX = function ( who , x )
> {
>      trace("onX : " + who + " with the value : " + x) ;
> }
> ui.addListener(this) ;
> ui.x = 25 ;
>
> EKA+ :)
>
> 2006/11/30, Matthias Dittgen <[EMAIL PROTECTED]>:
> >
> > Hello EKA,
> >
> > thanks for your reply.
> >
> > to your 1: yes, i really don't wanted to use watch. the watch method
> > is less performant, I have read on this list sometime before. That's,
> > why I asked my question. It admit, it has been more than only one
> > question. :-)
> >
> > to your 2: I usually give my constructor the same name as the class.
> > This is a typical mistake, when I use the copy&paste&change method to
> > write emails.
> >
> > to your 3: "is AS2 used get and set keywords to create virtual
> > properties and don't use addProperty method!", I was not aware of the
> > set and get keywords. Is this syntax supported by both Flash IDE and
> > MTASC? Be sure, I'll try that!
> >
> > to your second 3: "you can use in your example the Asbroadcaster class"
> > But I don't have to. The way you use "set x(x:Number)", "get
> > x():Number", "setX(x:Number)" and getX():Number", I could just change
> > your
> >
> > public function setX( value:Number ):Void
> > {
> >     _x = value ;
> >     broadcastMessage("onX" , this, _x) ;
> > }
> >
> > into:
> >
> > public function onX():Void {} // can be dynamically overwritten
> > public function setX( value:Number ):Void
> > {
> >     _x = value ;
> >     onX();
> > }
> >
> > ,can't I?
> >
> > But again: thanks a lot for introducing the set and get keywords to
> > me. I'll try that now!
> > Thanks,
> >
> > Matthias
> > _______________________________________________
> > 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

_______________________________________________
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