So in my Main.mxml Application i have a Button with the id=SearchButton and a Click=button_clickHandler_6() with the function attached but i would like to listen for this event in my component ClientDataListSkin.mxml and then execute a function on hearing that event
I assume the ClientDataList component is a child of the main mxml. Rather then having the compnent listen for an event, you need to call a function in that component from the button click handler
Thanks for the response targetplanet and im sure you are right as i do use this appoach on occassion just must be thinking to deep to think i should of used the addeventlister approach.
But could you tell me please the above way did work but the only way i could access the function is using the "public static function" but when using that the fuction cant see ID name of my CallResponder that is declared in <fx:Declarations> but if i use "protected function" the function can see the ID but calling from main wont see the function in the componant!
did you declare the ClientDataListSkin component in the mxml of your main mxml? if so give it an id, and then using that id you should be able to access any public function in that component.
so in your ClientDataListSkin.mxml file say you have a function called getData
public function getData():void
//code to get data
and you have given your ClientDataListSkin insitance an id
<components:ClientDataListSkin id="clientList" ....
in your button listener you should be able to call that function like so
Do you ever get to a point in programming where you think that perhaps i have choosen the wrong hobby to get infatuated about
That code worked really well targetplanet but it had a side effect that just makes me nutts lol
as it triggered a mouse event function in the component that was initialized in Main and just made my web site go nuts . the component that we initialized was a skin but its itemRenderer component that followed had the mouse event! perhaps i better start again with me learning perhaps i missed something
or perhaps i should just have one component to one job instead of trying to be clever and mutitask with less components!
1 person found this helpful
Yeah for a long time my tendency was to lean towards one component for multiple taskes. It seemed like better programming for some reason, but what I found was the code would get really complex, and I would get lost in my own code. Things would break and it would take me forever to find the issue. So I started simplifying. Creating many simpler components that handle one or two tasks, and it made a huge difference in my app development. Sure I had crazy numbers of componets, but when something goes wrong, it is usually easier to find. Another huge improvement in my coding to start using a Framework. I use puremvc, and I couldn't imagine trying to create something without it.