tags:

views:

33

answers:

2

Hi--

I want to get this to work:

private function frigganWork(event:MouseEvent):void { trace("WTF?"); navigateToURL(new URLRequest("http://stackoverflow.com/questions/ask"), "_self");

}

but I get an error: "Call to possibly undefined method frigganWork."

+1  A: 

If you are calling frigganWork() from within an inline item renderer - you have to change the scope of the method to public.

clownbaby
<mx:Image source="assets/{data.source}" buttonMode="true" click="frigganWork()" />I've changed the scope to public, same error
ryan
<mx:itemRenderer> <mx:Component> <mx:VBox verticalAlign="middle" horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundColor="#cccccc" rollOverEffect="bLur" > <mx:Image source="assets/{data.source}" buttonMode="true" click="frigganWork()" /> </mx:VBox> </mx:Component> </mx:itemRenderer>
ryan
what am I doing wrong?
ryan
+3  A: 

Because you're inside a mx:Component tag, your scope has changed: this now refers to the itemRenderer component.

You can resolve to the larger scope by using outerDocument. The event handler function does need to be public since it's being called from another class.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
    <![CDATA[
        public function onClick(event:Event):void {}
    ]]>
</mx:Script>
    <mx:ComboBox>
        <mx:itemRenderer>
            <mx:Component>
                <mx:Image click="{outerDocument.onClick(event)}" />
            </mx:Component>
        </mx:itemRenderer>
    </mx:ComboBox>
</mx:Application>
Michael Brewer-Davis
Agreed. I've always used parentDocument, but it seems the same.
adamcodes
THANK YOU Michael!!!
ryan