Re: [flexcoders] Event Handlers inside custom components

2005-07-28 Thread Manish Jethani
On 7/28/05, Archibald Scatflinger [EMAIL PROTECTED] wrote:

 I do not want to use implicit getter/setters because I want the
 components property to be bindable.

To make the component's property bindable, specify a ChangeEvent for
the property and dispatch the event when the value changes.

e.g.

?xml version=1.0?
mx:Box xmlns:mx=http://www.macromedia.com/2003/mxml; xmlns=*
  mx:Label text={labelText} /
  mx:Script

// Storage for 'labelText' property
private var _labelText:String = ;

[ChangeEvent(labelTextChange)]
public function get labelText():String
{
  return _labelText;
}
public function set labelText(value:String):Void
{
  if (value != _labelText)
  {
_labelText = value;
dispatchEvent({type: labelTextChange});
  }
}
  /mx:Script
/mx:Box

When labelText is modified, the component dispatches an event to
trigger binding.  Check out the generated AS to see how this works.

Manish


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Event Handlers inside custom components

2005-07-28 Thread Kelly R


I actually figured this out right after I asked but I did it a different way.
It does basically the same thing though.

Here is an example:


!—My application page (TestApp.mxml)-- 

-


?xml version="1.0" encoding="utf-8"?
mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns:Weee="*" initialize="SetVar()"
mx:Script
![CDATA[
function SetVar(){
MyTest.MyValue = "Rararararar";
}
]]
/mx:Script

Weee:MyTestComp id="MyTest" /

/mx:Application

-



!—My component file (MyTestComp.mxml)--

-


?xml version="1.0" encoding="utf-8"?
mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" width="400" height="400"
mx:Script
![CDATA[
var MyValue:String = "BlahBlah"

function set MyOtherValue(NewValue):Void {
mx.core.Application.alert('The new value is: '+MyValue);
}


]]
/mx:Script
mx:Binding source="MyValue" destination="MyOtherValue" /

/mx:VBox


-



From: Manish Jethani [EMAIL PROTECTED]Reply-To: flexcoders@yahoogroups.comTo: flexcoders@yahoogroups.comSubject: Re: [flexcoders] Event Handlers inside custom componentsDate: Thu, 28 Jul 2005 23:12:51 +0530On 7/28/05, Archibald Scatflinger [EMAIL PROTECTED] wrote:  I do not want to use implicit getter/setters because I want the  components property to be bindable.To make the component's property bindable, specify a "ChangeEvent" forthe property and dispatch the event when the value changes.e.g.?xml version="1.0"?mx:Box xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*" mx:Label text="{labelText}" / mx:Script // Storage 
for 'labelText' property private var _labelText:String = ""; [ChangeEvent("labelTextChange")] public function get labelText():String { return _labelText; } public function set labelText(value:String):Void { if (value != _labelText) { _labelText = value; dispatchEvent({type: "labelTextChange"}); } } /mx:Script/mx:BoxWhen labelText is modified, the component dispatches an event totrigger binding. Check out the generated AS to see how this works.Manish





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





  




  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  













Re: [flexcoders] Event Handlers inside custom components

2005-07-28 Thread Kelly R


I actually figured this out right after I asked but I did it a different way.
It does basically the same thing though.

Here is an example:


!—My application page (TestApp.mxml)-- 

-


?xml version="1.0" encoding="utf-8"?
mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns:Weee="*" initialize="SetVar()"
mx:Script
![CDATA[
function SetVar(){
MyTest.MyValue = "Rararararar";
}
]]
/mx:Script

Weee:MyTestComp id="MyTest" /

/mx:Application

-



!—My component file (MyTestComp.mxml)--

-


?xml version="1.0" encoding="utf-8"?
mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" width="400" height="400"
mx:Script
![CDATA[
var MyValue:String = "BlahBlah"

function set MyOtherValue(NewValue):Void {
mx.core.Application.alert('The new value is: '+MyValue);
}


]]
/mx:Script
mx:Binding source="MyValue" destination="MyOtherValue" /

/mx:VBox


-



From: Manish Jethani [EMAIL PROTECTED]Reply-To: flexcoders@yahoogroups.comTo: flexcoders@yahoogroups.comSubject: Re: [flexcoders] Event Handlers inside custom componentsDate: Thu, 28 Jul 2005 23:12:51 +0530On 7/28/05, Archibald Scatflinger [EMAIL PROTECTED] wrote:  I do not want to use implicit getter/setters because I want the  components property to be bindable.To make the component's property bindable, specify a "ChangeEvent" forthe property and dispatch the event when the value changes.e.g.?xml version="1.0"?mx:Box xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*" mx:Label text="{labelText}" / mx:Script // Storage 
for 'labelText' property private var _labelText:String = ""; [ChangeEvent("labelTextChange")] public function get labelText():String { return _labelText; } public function set labelText(value:String):Void { if (value != _labelText) { _labelText = value; dispatchEvent({type: "labelTextChange"}); } } /mx:Script/mx:BoxWhen labelText is modified, the component dispatches an event totrigger binding. Check out the generated AS to see how this works.Manish





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Computer software testing
  
  
Macromedia flex
  
  
Development
  
  


Software developer
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  














[flexcoders] Event Handlers inside custom components

2005-07-27 Thread Archibald Scatflinger
I have a custom component and I want to make it so that when one of
its properties is changed by an external source then it triggers one
of the components methods.

I realize that this is probably really simple and I am just missing
something but everything I have tried has either produced errors or
just not worked.

I do not want to use implicit getter/setters because I want the
components property to be bindable.


For example:

When this happens:

MyCustomComponent.someproperty = SomeNewValue;

I want it to trigger this:

MyCustomComponent.DoSomeFunction();

I want this to be defined inside of the component though so it is
invisible outside of the component.



Any thoughts?


Is this as easy as I think it should be?








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Event Handlers inside custom components

2005-07-27 Thread Scott Barnes
Yes,

using object.watch(prop, callback [, user data])



On 7/28/05, Archibald Scatflinger [EMAIL PROTECTED] wrote:
 I have a custom component and I want to make it so that when one of
 its properties is changed by an external source then it triggers one
 of the components methods.
 
 I realize that this is probably really simple and I am just missing
 something but everything I have tried has either produced errors or
 just not worked.
 
 I do not want to use implicit getter/setters because I want the
 components property to be bindable.
 
 
 For example:
 
 When this happens:
 
 MyCustomComponent.someproperty = SomeNewValue;
 
 I want it to trigger this:
 
 MyCustomComponent.DoSomeFunction();
 
 I want this to be defined inside of the component though so it is
 invisible outside of the component.
 
 
 
 Any thoughts?
 
 
 Is this as easy as I think it should be?
 
 
 
 
 
 
 
 
 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links
 
 
 
 
 
 
 


-- 
Regards,
Scott Barnes
http://www.mossyblog.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/