Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Create a set function in “Customizing Guides Using Flash Builder ”

Avatar

Former Community Member

When I copy this code to my mxml.

<?xml version="1.0" encoding="utf-8"?>
<gc:Wrapper width="100%" height="100%"
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:gc="ga.controls.*" >
    
    <mx:Script>
        <![CDATA[

            Wrapper.instance.bindSetter("Services.employee.empName", empNameSetter);

            private function empNameSetter(value:Object):void
            {
                var empName:String = value as String;  // cast to appropriate type
                if ( empName == "Tony Blue" ) {
                    // do something here
                }
            }

        ]]>
    </mx:Script>

    <mx:VBox width="100%" height="100%">
        <gc:PanelContent width="100%" height="100%" />
        <mx:HBox>
            <gc:PreviousPanelButton label="Back" />
            <gc:NextPanelButton label="Forward" />
            <gc:SubmitButton label="Submit Data" />
        </mx:HBox>
    </mx:VBox>
</gc:Wrapper>

then get a error "visit attribute 'empNameSetter' is undefined"

Who can help me,thanks.

2 Replies

Avatar

Level 2

Hi Rowan,

I don't know whether or not you're still active, but for anyone else looking for a solution to a similar problem I'll break down the solution.

In this line :   Wrapper.instance.bindSetter("Services.employee.empName", empNameSetter);

You are calling the empNameSetter function but aren't passing an object.

private function empNameSetter(value:Object):void{

//code goes here

}

You should either pass an object to your function in the function call like so:
Wrapper.instance.bindSetter("Services.employee.empName", empNameSetter(ObjectGoesHere));

or

Modify your declaration not to take any parameters.

Avatar

Former Community Member

Thank you very much!

I have solved this problem by anonymous function.

like

Wrapper.instance.bindSetter("Services.employee.empName",function(value:Object){

          //code gose here

});