You technically cannot do this, since callLater() actually takes a function as an argument and a setter is an accessor.

However, rules where meant to be broken (or at least worked around).

You can do it by creating a function inline which sets the property within your callLater invocation.

Here is a simple class with a method and a setter:

package
{
    import mx.controls.Alert;
    public class MyClass
    {
        public function set stuff(value:String):void{
            Alert.show("setter for stuff: " + value);
        }      
       
        public function junk(value:String):void{
            Alert.show("function junk: " + value);
        }
    }
}
 

Here is a simple app demonstrating the workaround:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
   
    <mx:Script>
        <![CDATA[
            public var foo:MyClass;
       
            public function init():void{
                foo=new MyClass();
            }
        ]]>
    </mx:Script>

<!–
    The following will not compile with this error:

Error 1119: Access of possibly undefined property stuff through a reference with static type MyClass.

    <mx:Button label="call setter within callLater"
        click="callLater(foo.stuff,[’bunch of stuff’])"/>      
–> 
    <mx:Button label="call function within callLater"
        click="callLater(foo.junk,[’bunch of junk’])"/> 
    <mx:Button label="call setter within callLater"
        click="callLater(function():void{foo.stuff=’bunch of stuff’})"/>       
</mx:Application>
 

A complete Flex Builder 2.0.1 Project Archive (.zip) of this sample can be found here.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • digg
  • Technorati
  • Reddit
  • del.icio.us
  • Slashdot