Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

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

Avatar

Not applicable

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.

1 Reply

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

Not applicable

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

});