开发者

Programmatic equivalent of: {foo(boundProperty)}?

Is there a programmatic equivalent of the following:

When using mxml, I can bind a property to a function, so that if the property changes, the bound function will be invoked (with the bound property as parameter.

For example:

<fx:Script>
    <![CDATA[

        [Bindable]
        var type:String;
        private function getText(t:String):String开发者_如何学Python{
        }

    ]]>
</fx:Script>


<s:Label text="{getText(type)}" />

Is there a programmatic equivalent? Thanks in advance!


Yes.

It's been a while since I played with this, but effectively, the MXMLC compiler will process your .mxml files and files with metadata into functionally equivalent AS3 source files, which are then compiled into bytecode. If you run MXMLC from the command line, the option to enable this is keep-generated-actionscript=true . From the IDE, you should be to use that under project->properties->compiler options.

Be warned, those generated files aren't really meant to be readable, but ultimately they show you a lot of what's happening behind the scenes, including the way mxml bindings are implemented.

(more directly relevant, there's a good chance that http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/binding/utils/BindingUtils.html and ChangeWatcher.html have something to do with what you want.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜