hassicho
hassicho

Reputation: 99

add button to spark panel

I have a custom skin for spark panel which contains a button and a text field. The function for the button is defined inside the main view. how can I link between them?

the main view looks like the following

<s:view>
 <fx:Script>
    <![CDATA[

            function clickHandler():void{
             // handler
            }

            ]]>
 </fx:Script>
 <s:panel skinclass="mySkin">
 </s:panel>
</s:view> 

in the skin class, i just added a button and textfield besides the label. now the button should fire the function "clickHandler"

Upvotes: 0

Views: 147

Answers (2)

Juanpe
Juanpe

Reputation: 446

If you want to access the main compenent use this sentence:

FlexGlobals.topLevelApplication.[Your public method]

Use your click event on button to calla method that calls to the top application, this isn´t the best way to access the main compenent, as using events would be a better choice, if you start using FlexGlobals in every class, at the end you will have loads of pointers and the project won't be very organized, its better just to add an event listener in the main to that view and then create the event.

Upvotes: 2

Jiya1491
Jiya1491

Reputation: 26

Make one component not SkinClass...and put your textfield and button in it...then dispatch button click event from component and use that component...

Upvotes: 0

Related Questions