Re: [Flashcoders] Implementing GroupName for my own component
Here is some sturdy logic for grabing some siblings, in any case: function getSiblings(target:Object):Array { var i:Number = radioButtons.length, r:Array=[]; while(i--)if(radioButtons[i]!=target)r.push(radioButtons[i]); return r; } More likely, you will be doing something like this in your group class: var radioButtons:Array; private var _selectedIndex:Number; function setSelect(index:Number):Void { deselect(); _selectedIndex = index; select(); } function select():Void { radioButtons[_selectedIndex].setSelected(true); } function deselect():Void { radioButtons[_selectedIndex].setSelected(false); } //and this in your radioButton class function setSelected(value:Boolean):Void { this.dotGraphic._visible=value; } The amount of functions may seem redundant, but seperating the tasks like this will give the component a real flexible API. Don't know when you might need your radio buttons to take the dog for a walk or something, hehe. M. On 4/22/06, Julian 'Julik' Tarkhanov <[EMAIL PROTECTED]> wrote: > > > On 21-apr-2006, at 23:49, elibol wrote: > > > I think the best way to implement this would be to have a > > RadioGroup class > > that would instantiate through static functions of the RadioButton > > class. A > > static variable of the RadioGroup class would manage RadioGroup > > instances, > > it would add and remove RadioGroup instances through a static API. > > A static > > function of the RadioButton would take the RadioButton instances > > radioGroupID property and check if it exists, if it does it would > > add the > > instance to the radio group, if not it would instantiate a new > > radio group. > > > > Each radio button would have an instance of the radio group they > > belonged > > to, when they were selected, they would just call a select() style > > function > > of their own radio group and submit their index/id to be activated. > > You > > should handle activation and deactivation of radio buttons from the > > radio > > group class. > > > > You should also implement a die() method which derefrences radio > > buttons > > from radio groups so that radio group instances are destroyed when > > they no > > longer contain any radio buttons. > > > > Hope this helps, > > Yeo, will try that, I just hoped there is a way to determine the > siblings at runtime and avoid the whole referencing-dereferencing- > registration-callbacks thing. Hope that will be possible with AS3. > > Attaching callbacks to the group instead of the buttons is a n > interesting idea though. > > -- > Julian 'Julik' Tarkhanov > please send all personal mail to > me at julik.nl > > > ___ > 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
Re: [Flashcoders] Implementing GroupName for my own component
On 21-apr-2006, at 23:49, elibol wrote: I think the best way to implement this would be to have a RadioGroup class that would instantiate through static functions of the RadioButton class. A static variable of the RadioGroup class would manage RadioGroup instances, it would add and remove RadioGroup instances through a static API. A static function of the RadioButton would take the RadioButton instances radioGroupID property and check if it exists, if it does it would add the instance to the radio group, if not it would instantiate a new radio group. Each radio button would have an instance of the radio group they belonged to, when they were selected, they would just call a select() style function of their own radio group and submit their index/id to be activated. You should handle activation and deactivation of radio buttons from the radio group class. You should also implement a die() method which derefrences radio buttons from radio groups so that radio group instances are destroyed when they no longer contain any radio buttons. Hope this helps, Yeo, will try that, I just hoped there is a way to determine the siblings at runtime and avoid the whole referencing-dereferencing- registration-callbacks thing. Hope that will be possible with AS3. Attaching callbacks to the group instead of the buttons is a n interesting idea though. -- Julian 'Julik' Tarkhanov please send all personal mail to me at julik.nl ___ 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
Re: [Flashcoders] Implementing GroupName for my own component
Julian 'Julik' Tarkhanov wrote: That is, if I have 5 instances of RadioCompnent inside a specific timeline, can I programmatically retrieve all of them? What I would do is to create a class with static methods only as groups manager so you just need to register RadioButton components within that manager. It's quite obviously should be done in constructor. -- Michael "Antares" Klishin, Email: [EMAIL PROTECTED] Web: www.novemberain.com Non progredi est regredi ___ 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
Re: [Flashcoders] Implementing GroupName for my own component
I think the best way to implement this would be to have a RadioGroup class that would instantiate through static functions of the RadioButton class. A static variable of the RadioGroup class would manage RadioGroup instances, it would add and remove RadioGroup instances through a static API. A static function of the RadioButton would take the RadioButton instances radioGroupID property and check if it exists, if it does it would add the instance to the radio group, if not it would instantiate a new radio group. Each radio button would have an instance of the radio group they belonged to, when they were selected, they would just call a select() style function of their own radio group and submit their index/id to be activated. You should handle activation and deactivation of radio buttons from the radio group class. You should also implement a die() method which derefrences radio buttons from radio groups so that radio group instances are destroyed when they no longer contain any radio buttons. Hope this helps, M. On 4/21/06, Julian 'Julik' Tarkhanov <[EMAIL PROTECTED]> wrote: > > I would like to implement a radio-like component and provide a > groupName for it (I don't use MM components because they do not fit > my application). > > Is there a way to dynamically retrieve all siblings of the > component's instance which have the same class (or subclass) of the > component and the same groupName dynamically? Or will my best option > be just implementing groupName as an accessor and refrencing > dependent Radio buttons elsewhere? > > That is, if I have 5 instances of RadioCompnent inside a specific > timeline, can I programmatically retrieve all of them? > -- > Julian 'Julik' Tarkhanov > please send all personal mail to > me at julik.nl > > > ___ > 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] Implementing GroupName for my own component
I would like to implement a radio-like component and provide a groupName for it (I don't use MM components because they do not fit my application). Is there a way to dynamically retrieve all siblings of the component's instance which have the same class (or subclass) of the component and the same groupName dynamically? Or will my best option be just implementing groupName as an accessor and refrencing dependent Radio buttons elsewhere? That is, if I have 5 instances of RadioCompnent inside a specific timeline, can I programmatically retrieve all of them? -- Julian 'Julik' Tarkhanov please send all personal mail to me at julik.nl ___ 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