开发者

How do I fix this warning in my mx:request tag?

I'm running an HTTPService开发者_如何学编程 with the following request:

<mx:request xmlns="">
    <view>{myViewStack.selectedChild.name}</view>
</mx:request>

The idea being to pass which child is selected on the viewstack to the php page, and then get that back so I can run some logic based on which child of the viewstack was selected at the time.

Everything seems to work, but I get the following warning:

Data binding will not be able to detect assignments to "name".

This doesn't seem to be causing any trouble, but I know warnings usually mean that I am not following the best practice. How can I fix this? I don't really need this item to be bound, because the name will never change at runtime, but I don't know how else to include it in the request.

Wouter's given me a good workaround. But is there any way to call a variable in a request like this without binding?


There is no way to tell Flex that you're not interested in changes to name, and no way to flag a warning to be ignored.

As a workaround, you can extract the getting of the name into a separate function. Something like this:

<mx:Script>
    private function getName(container:Container):String {
        return container.name;
    }
</mx:Script>
...
<mx:request xmlns="">
    <view>{getName(myViewStack.selectedChild)}</view>
</mx:request>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜