Re: [Flashcoders] Radiobutton - Dispatch event on code selected?
Thank you both... I found another way (not an elegant one, but it works): radioButton.onRelease(); Regards, On Thu, 30 Mar 2006 05:40:34 -0300, Aaron Smith <[EMAIL PROTECTED]> wrote: Sure its possible!!! Marcelo, here is a solution: put two radio buttons on the stage and call it rb1 / rb2. then in the actions layer put: import mx.controls.RadioButton; import mx.utils.Delegate; import mx.events.EventDispatcher; var dispatchEvent:Function; EventDispatcher.initialize(this); //create prototype reference for RadioButton var osv = _global.mx.controls.RadioButton.prototype; //hold onto the old setSelected method ( The intrinsic set Selected method is in SimpleButton, RadioButton inherits from that. the set method simply calls setSelected. ) osv.oldSetSelected = osv.setSelected; osv.oldOnRelease = osv.onRelease; //overwrite onrelease to deal with multiple events being dispatched. osv.onRelease = function():Void { this['wasReleased'] = true; this.oldOnRelease.apply(this,[]); } //overwrite the old method with new method. osv.setSelected = function(val:Boolean):Void { if( !this['wasReleased'] ) { if( val == true ) { this.dispatchEvent( { type:'codeSelected' } ); this.oldSetSelected.apply( this,[ true ] ); } } else { this.oldSetSelected.apply( this,[ true ] ); } this['wasReleased'] = false; } //add listener to radio button. rb1.addEventListener('codeSelected', Delegate.create(this, handleCodeSelect)); rb1.addEventListener('click', Delegate.create(this, handleClick)); //handle code selected event function handleCodeSelect():Void { trace("codeSelected"); } //handle click event function handleClick():Void { trace("CLICK"); } //set an interval to do some testing on the codeSelected event tmpInt = setInterval(setSel,1000,true); //set the selected property function setSel():Void { //trigger the event rb1.selected = true; } test that out.. you'll see that for testing i just set an interval to change the selected property to true.. the event gets dispatched every time the selected property is set to true. Also worth mentioning you have to update the onRelease method to deal with multiple events being dispatched. Also don't name the codeSelected event as click, as that is not whats happening and would cause confusion. rb2 is never used in this example.. just use that to click back and forth between... also try commenting out the interval just for more testing.. you'll see that just the click event fires.. smith Danny Kodicek wrote: >It´s possible to make the radio button dispatch the "click" event if i select it by code? Not directly, but you could add something like this (I haven't used the rb component for a while, but I think this would work radioButton.autoClick=function() { this.selected=true linkType_cml.setType() } Then to select the radio button you just call radioButton.autoClick(), and your event should be dispatched. Danny ___ 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 -- _ Marcelo Volmaro ___ 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] Radiobutton - Dispatch event on code selected?
Get with the times... Cor, first you're talking bout Director, then I hear you're still using MX... Tsk... You're obviously not on the forefront of technology, huh? ;-) It's true. The problem is, I can't quite see the point of getting completely up to speed with AS2 when AS3 is just round the corner, so I'm treading water to some extent. Also, Director's only just become able to deal with Flash 8 content, so when working with Flash in Director, you're always a bit limited. Danny ___ 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] Radiobutton - Dispatch event on code selected?
Get with the times... Cor, first you're talking bout Director, then I hear you're still using MX... Tsk... You're obviously not on the forefront of technology, huh? ;-) Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Kodicek Sent: 30 March 2006 09:46 To: Flashcoders mailing list Subject: Re: [Flashcoders] Radiobutton - Dispatch event on code selected? Crap, I keep forgetting about Dispatchers. Apologies - been coding in MX too long. Danny - Original Message - From: "Aaron Smith" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" Sent: Thursday, March 30, 2006 9:40 AM Subject: Re: [Flashcoders] Radiobutton - Dispatch event on code selected? Sure its possible!!! Marcelo, here is a solution: put two radio buttons on the stage and call it rb1 / rb2. then in the actions layer put: import mx.controls.RadioButton; import mx.utils.Delegate; import mx.events.EventDispatcher; var dispatchEvent:Function; EventDispatcher.initialize(this); //create prototype reference for RadioButton var osv = _global.mx.controls.RadioButton.prototype; //hold onto the old setSelected method ( The intrinsic set Selected method is in SimpleButton, RadioButton inherits from that. the set method simply calls setSelected. ) osv.oldSetSelected = osv.setSelected; osv.oldOnRelease = osv.onRelease; //overwrite onrelease to deal with multiple events being dispatched. osv.onRelease = function():Void { this['wasReleased'] = true; this.oldOnRelease.apply(this,[]); } //overwrite the old method with new method. osv.setSelected = function(val:Boolean):Void { if( !this['wasReleased'] ) { if( val == true ) { this.dispatchEvent( { type:'codeSelected' } ); this.oldSetSelected.apply( this,[ true ] ); } } else { this.oldSetSelected.apply( this,[ true ] ); } this['wasReleased'] = false; } //add listener to radio button. rb1.addEventListener('codeSelected', Delegate.create(this, handleCodeSelect)); rb1.addEventListener('click', Delegate.create(this, handleClick)); //handle code selected event function handleCodeSelect():Void { trace("codeSelected"); } //handle click event function handleClick():Void { trace("CLICK"); } //set an interval to do some testing on the codeSelected event tmpInt = setInterval(setSel,1000,true); //set the selected property function setSel():Void { //trigger the event rb1.selected = true; } test that out.. you'll see that for testing i just set an interval to change the selected property to true.. the event gets dispatched every time the selected property is set to true. Also worth mentioning you have to update the onRelease method to deal with multiple events being dispatched. Also don't name the codeSelected event as click, as that is not whats happening and would cause confusion. rb2 is never used in this example.. just use that to click back and forth between... also try commenting out the interval just for more testing.. you'll see that just the click event fires.. smith Danny Kodicek wrote: > > >It´s possible to make the radio button dispatch the "click" event if i > select it by code? > > Not directly, but you could add something like this (I haven't used the rb > component for a while, but I think this would work > > radioButton.autoClick=function() { > this.selected=true > linkType_cml.setType() > } > > Then to select the radio button you just call radioButton.autoClick(), and > your event should be dispatched. > > Danny > ___ > 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 ___ 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] Radiobutton - Dispatch event on code selected?
Crap, I keep forgetting about Dispatchers. Apologies - been coding in MX too long. Danny - Original Message - From: "Aaron Smith" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" Sent: Thursday, March 30, 2006 9:40 AM Subject: Re: [Flashcoders] Radiobutton - Dispatch event on code selected? Sure its possible!!! Marcelo, here is a solution: put two radio buttons on the stage and call it rb1 / rb2. then in the actions layer put: import mx.controls.RadioButton; import mx.utils.Delegate; import mx.events.EventDispatcher; var dispatchEvent:Function; EventDispatcher.initialize(this); //create prototype reference for RadioButton var osv = _global.mx.controls.RadioButton.prototype; //hold onto the old setSelected method ( The intrinsic set Selected method is in SimpleButton, RadioButton inherits from that. the set method simply calls setSelected. ) osv.oldSetSelected = osv.setSelected; osv.oldOnRelease = osv.onRelease; //overwrite onrelease to deal with multiple events being dispatched. osv.onRelease = function():Void { this['wasReleased'] = true; this.oldOnRelease.apply(this,[]); } //overwrite the old method with new method. osv.setSelected = function(val:Boolean):Void { if( !this['wasReleased'] ) { if( val == true ) { this.dispatchEvent( { type:'codeSelected' } ); this.oldSetSelected.apply( this,[ true ] ); } } else { this.oldSetSelected.apply( this,[ true ] ); } this['wasReleased'] = false; } //add listener to radio button. rb1.addEventListener('codeSelected', Delegate.create(this, handleCodeSelect)); rb1.addEventListener('click', Delegate.create(this, handleClick)); //handle code selected event function handleCodeSelect():Void { trace("codeSelected"); } //handle click event function handleClick():Void { trace("CLICK"); } //set an interval to do some testing on the codeSelected event tmpInt = setInterval(setSel,1000,true); //set the selected property function setSel():Void { //trigger the event rb1.selected = true; } test that out.. you'll see that for testing i just set an interval to change the selected property to true.. the event gets dispatched every time the selected property is set to true. Also worth mentioning you have to update the onRelease method to deal with multiple events being dispatched. Also don't name the codeSelected event as click, as that is not whats happening and would cause confusion. rb2 is never used in this example.. just use that to click back and forth between... also try commenting out the interval just for more testing.. you'll see that just the click event fires.. smith Danny Kodicek wrote: >It´s possible to make the radio button dispatch the "click" event if i select it by code? Not directly, but you could add something like this (I haven't used the rb component for a while, but I think this would work radioButton.autoClick=function() { this.selected=true linkType_cml.setType() } Then to select the radio button you just call radioButton.autoClick(), and your event should be dispatched. Danny ___ 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
Re: [Flashcoders] Radiobutton - Dispatch event on code selected?
Sure its possible!!! Marcelo, here is a solution: put two radio buttons on the stage and call it rb1 / rb2. then in the actions layer put: import mx.controls.RadioButton; import mx.utils.Delegate; import mx.events.EventDispatcher; var dispatchEvent:Function; EventDispatcher.initialize(this); //create prototype reference for RadioButton var osv = _global.mx.controls.RadioButton.prototype; //hold onto the old setSelected method ( The intrinsic set Selected method is in SimpleButton, RadioButton inherits from that. the set method simply calls setSelected. ) osv.oldSetSelected = osv.setSelected; osv.oldOnRelease = osv.onRelease; //overwrite onrelease to deal with multiple events being dispatched. osv.onRelease = function():Void { this['wasReleased'] = true; this.oldOnRelease.apply(this,[]); } //overwrite the old method with new method. osv.setSelected = function(val:Boolean):Void { if( !this['wasReleased'] ) { if( val == true ) { this.dispatchEvent( { type:'codeSelected' } ); this.oldSetSelected.apply( this,[ true ] ); } } else { this.oldSetSelected.apply( this,[ true ] ); } this['wasReleased'] = false; } //add listener to radio button. rb1.addEventListener('codeSelected', Delegate.create(this, handleCodeSelect)); rb1.addEventListener('click', Delegate.create(this, handleClick)); //handle code selected event function handleCodeSelect():Void { trace("codeSelected"); } //handle click event function handleClick():Void { trace("CLICK"); } //set an interval to do some testing on the codeSelected event tmpInt = setInterval(setSel,1000,true); //set the selected property function setSel():Void { //trigger the event rb1.selected = true; } test that out.. you'll see that for testing i just set an interval to change the selected property to true.. the event gets dispatched every time the selected property is set to true. Also worth mentioning you have to update the onRelease method to deal with multiple events being dispatched. Also don't name the codeSelected event as click, as that is not whats happening and would cause confusion. rb2 is never used in this example.. just use that to click back and forth between... also try commenting out the interval just for more testing.. you'll see that just the click event fires.. smith Danny Kodicek wrote: >It´s possible to make the radio button dispatch the "click" event if i select it by code? Not directly, but you could add something like this (I haven't used the rb component for a while, but I think this would work radioButton.autoClick=function() { this.selected=true linkType_cml.setType() } Then to select the radio button you just call radioButton.autoClick(), and your event should be dispatched. Danny ___ 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] Radiobutton - Dispatch event on code selected?
>It´s possible to make the radio button dispatch the "click" event if i select it by code? Not directly, but you could add something like this (I haven't used the rb component for a while, but I think this would work radioButton.autoClick=function() { this.selected=true linkType_cml.setType() } Then to select the radio button you just call radioButton.autoClick(), and your event should be dispatched. Danny ___ 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