O.K. Here's the situation...
I have a custom mxml component that contains a couple of images and 4 buttons. The component file already contains a clickHandler
for each of the buttons. I need to be able to either access the clickHandler
or create another function and attach it to those buttons from within my Main.mxml
file. Should I add to the original clickHandlers
? if so, how do I apply the method to my Main.mxml
file?
FYI: The component has 5 states and each clickHandler
triggers transitions between the states.
Here are the two clickHandlers
from the component file:
protected function submit_clickHandler():void
{
const state:String = currentState;
if ( state == 'state1' ) {
currentState='state2';
}
if ( state == 'state3' ) {
currentState='state4';
addElement(images[i]); //The methods I want to run from
getStudentAnswer(); //within the Main.mxml.
submit(); //If I add them here, I get an
newQuestion(); //undefined method error.
}
if ( state == 'state4' ) {
currentState='state4';
}
if ( state == 'state5' ) {
currentState='state4';
}
if ( state == 'state3' ) {
Sequence1.play();
}
}
protected function checkAnswer_clickHandler():void
{
const state:String = currentState;
if ( state == 'state2' ) {
currentState='state1';
}
if ( state == 'state4' ) {
currentState='state5';
}
}
Thanks, JM