Gregory,

A lot of times, I do something like...
        
        private var propsSet:Array = new Array();
        
        public function set ballType(_value:String):void{
                _ballType= _value;
                propsSet.push("ballType");
                checkProps();
        }
        
        private function checkProps():void{
                if(propsSet.length >= 12){
                        // do Blah once all are set...                  
                }
                
                // You can also check to see if a single property or different
multiple properties have been set, and do certain actions then...
                if(propsSet.indexOf("ballType") != -1){
                        // do Blah if "ballType" has been set...
                }
        }

I try to avoid onEnterFrames if possible (unless I really need them,
for something like papervision scene rendering)..

Timers are not the best method, although they usually work, but I find
that the above approach is the best method.

- Taka

On Thu, Feb 19, 2009 at 10:17 AM, Gregory N <greg.gousa...@gmail.com> wrote:
> After some consideration...
>
> If I have, say dozen of Inspectable parameters AND a method that need
> several of them to work properly, then I'll have to call this method
> after a delay - to be sure that all necessary setters were called
> before it..
> Thus, turning back to enter_frame trick :-(
> Or am I missing something trivial?
>
> On 2/19/09, Gregory N <greg.gousa...@gmail.com> wrote:
>> Muzak,
>>
>> Nice addition, thanks for pointing to it.
>> Frankly, I'd prefer to avoid calling commitProperties() after *each*
>> of the setters...
>> Anyway, this way looks better than my enter_frame trick :-)
>>
>> However, the problem " none of the setters are called if no
>> inspectable params were changed" still remains. So we have to
>> duplicate default values in [Inspectable] and constructor/declaration
>> (or some init function)
>>
>> On 2/19/09, Muzak <p.ginnebe...@telenet.be> wrote:
>>> This workflow is more or less what the Flex components follow:
>>>
>>> package {
>>>
>>>  import flash.display.MovieClip;
>>>
>>>  public class Rectangle extends MovieClip {
>>>
>>>   private var _prop:String = "Hello";
>>>   private var propChanged:Boolean = false;
>>>
>>>   public function Rectangle():void {
>>>    trace("Rectangle ::: CONSTRUCTOR");
>>>    init();
>>>   }
>>>
>>>   private function init():void {
>>>    trace("Rectangle ::: init");
>>>    // do stuff here
>>>    commitProperties();
>>>   }
>>>
>>>   protected function commitProperties():void {
>>>    trace("Rectangle ::: commitProperties");
>>>    if(propChanged) {
>>>     trace("    - propChanged: ", propChanged);
>>>     trace("    - prop: ", _prop);
>>>     propChanged = false;
>>>     // do stuff with _prop
>>>    }
>>>   }
>>>
>>>   [Inspectable(defaultValue="Hello")]
>>>   public function get prop():String {
>>>    trace("Rectangle ::: get prop");
>>>    return _prop;
>>>   }
>>>   public function set prop(value:String):void {
>>>    trace("Rectangle ::: set prop");
>>>    if(value != _prop) {
>>>     _prop = value;
>>>     propChanged = true;
>>>     commitProperties();
>>>    }
>>>   }
>>>  }
>>> }
>>>
>>> regards,
>>> Muzak
>>>
>>> ----- Original Message -----
>>> From: "Gregory N" <greg.gousa...@gmail.com>
>>> To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
>>> Sent: Thursday, February 19, 2009 10:25 AM
>>> Subject: Re: [Flashcoders] component def doesn't pass params to
>>> constructor?
>>>
>>>
>>>> Michael,
>>>>
>>>> Haven't you read my reply to one of your prev. questions?
>>>> Well, let me quote it here again:
>>>> ===
>>>> Subject: Re: [Flashcoders] my component not instancing properly on
>>>> timeline
>>>>
>>>> It seems your problem is similar to one I had with my components.
>>>> The matter is that, unlike their behavior in AS2, in AS3 (CS3)
>>>> components setters of  [Inspectable] parameters are called lo-o-ong
>>>> AFTER constructor
>>>>
>>>> As described here
>>>> http://www.bit-101.com/blog/?p=1181
>>>> So, even if I set my init() as listener for ADDED_TO_STAGE event...
>>>> it's still before setters.
>>>>
>>>> for now, I found a solution:
>>>> I put my init() in ENTER_FRAME listener and then remove this listener
>>>> :-)
>>>> This means that listeners are called before 1st  ENTER_FRAME event.
>>>> Perhaps my solution isn't too elegant.... but it works :-)
>>>>
>>>> Also, be sure to duplicate default values for your parameters :-)
>>>> ===
>>>>
>>>> Note that the above solution is intended to use with sprite-based
>>>> components.
>>>> Perhaps if you subclass UIComponent, the situation with setters is
>>>> better... perhaps :-)
>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Flashcoders mailing list
>>> Flashcoders@chattyfig.figleaf.com
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>
>>
>> --
>> --
>> Best regards,
>>  GregoryN
>> ================================
>> http://GOusable.com
>> Flash components development.
>> Usability services.
>>
>
>
> --
> --
> Best regards,
>  GregoryN
> ================================
> http://GOusable.com
> Flash components development.
> Usability services.
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to