Dispatch an event and add/use a listener to recive it.
 
i.e.
 
In component # 2 put this after the Hbox
 
<mx:Metadata>
 [Event("deleted")]
</mx:Metadata>
 
and then dispatch it in you button like so.
 
<mx:Button label="Delete" click="dispatchEvent(new Event('deleted'));" />
 
now in component #1 you can get at it. Like so
 
<component2 deleted="delete()" id="c2">
or
 
on init of #1 add a function
 
private function myinit(){
    c2.addEventListener("deleted", delete);
}
 
and in the form tag add
 
<mx:Form initialize="myinit();"
 
This is all off the top of my head but should work (un tested etc..)
 
Respond if you need more help...
 
Jason
 
-----Message d'origine-----
De : [email protected] [mailto:[EMAIL PROTECTED]De la part de rgwilson26
Envoyé : jeudi 9 février 2006 16:39
À : [email protected]
Objet : [flexcoders] referencing functions within a component

I am fairly new to Flex and wondering how to get one component to
call a function within another component. How do I reference the
function in component #1 from #2?

**************component #1*****************
<mx:Form xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
private function delete():Void{
       Alert.Show("you have been deleted");
}
<mx:Vbox>
  <component2 id="c2">
</mx:Vbox>

</mx:Form>


**************component #2*****************
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox height="25" xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:TextInput id="txtRCAParticipants1" width="150" text="" />
<mx:Button label="Delete" click="delete();" />
</mx:HBox>





--
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
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to