Hi,

I encountered an error using the SetEventHandler and made a simple
test case to see what was the problem:
In my app I have a component that contains button and dispatches a
"goPrevious" event when the component::button is clicked.
Following the "goPrevious" event, the main app changes its state.  The
new state uses the SetEventHandler to change the "goPreviousHandler":

My main app:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" xmlns:local="*" creationComplete="init()">
        <mx:Script>
                <![CDATA[
                        import mx.controls.Alert;
                        
                        private function init():void
                        {
                                trace(document.toString());
                        }
                        private function onClick1(evt:Event):void
                        {
                                Alert.show("chnaging from state 1 to state 2");
                                currentState = "myState"
                        }
                        
                        private function onClick2(evt:Event):void
                        {
                                Alert.show("state 2");
                        }
                ]]>
        </mx:Script>
        
        <mx:states>
                <mx:State name="myState">
                        <mx:SetProperty target="{bt}" name="alpha" value="0.2" /
                        <!--<mx:SetEventHandler target="{bt}" 
handlerFunction="onClick2"
name="goPrevious" /> -->
                </mx:State>
        </mx:states>
        <local:MyButton id="bt" goPrevious="onClick1(event)" />
        <!--<mx:Button id="bt" click="onClick1()"  /> -->
</mx:Application>

---------------------------------------------------------------
The Component:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="100"
height="100" 
        click="onClick()" creationPolicy="auto" >
<mx:Metadata>
        [Event(name="goPrevious", type="events.NavigationEvent")]
</mx:Metadata>

<mx:Script>
        <![CDATA[
                import events.NavigationEvent;
                
                private function onClick():void
                {
                        dispatchEvent(new 
NavigationEvent(NavigationEvent.GO_PREVIOUS));
                }
        ]]>
</mx:Script>
        <mx:Button label="previous" click="onClick()" />
</mx:VBox>



And this is the error you get from the SetEventH/handler object:

ReferenceError: Error #1069: Property __bt_goPrevious not found on
MyButton and there is no default value.
        at mx.states::SetEventHandler/apply()


It seems that inside the SetEventHandler.apply() function it can't
find the oldHandlerFunction.


I'm struggling this bug for hours now and been goggling it a lot, yet
nothing useful was found...

I'd be grateful if anyone take a look at that.

Thanks in advance, 
Almog Kurtser

Reply via email to