数据绑定将无法检测对“topLevelApplication”的分配。

发布于 2024-10-09 05:54:32 字数 532 浏览 8 评论 0原文

我正在将应用程序从 Flex 3 迁移到 Flex 4。 在某些情况下,弹出窗口的宽度和高度与应用程序的宽度和高度绑定。

width="{Application.application.width - 24}" 
height="{Application.application.height - 32}"

Application.application 在 4.0 中已弃用。所以我将其替换为

width="{FlexGlobals.topLevelApplication.width - 24}" 
height="{FlexGlobals.topLevelApplication.height - 32}"

现在编译器给出警告,无法检测到 topLevelApplication 的数据绑定。

数据绑定将无法 检测分配给 “顶级应用程序”

我的问题是:是否有另一个(可绑定)属性可以用来获得与以前相同的功能?

I am migrating an application from Flex 3 to Flex 4.
In some cases there are popup windows of which the width and height is bound to the application width and height.

width="{Application.application.width - 24}" 
height="{Application.application.height - 32}"

Application.application is deprecated in 4.0. so I have replaced this with

width="{FlexGlobals.topLevelApplication.width - 24}" 
height="{FlexGlobals.topLevelApplication.height - 32}"

Now the compiler gives the warning that data bindings cannot be detected for topLevelApplication.

Data binding will not be able to
detect assignments to
"topLevelApplication"

My question is: Is there another (bindable) property somewhere that I can use to get the same functionality as before?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

命硬 2024-10-16 05:54:32

只需创建一个对象类型的变量并使其可绑定:

[Bindable]
private var application:Object = FlexGlobals.topLevelApplication;

然后使用该变量。

height="{application.height}"

Just create a variable of type object and make it bindable :

[Bindable]
private var application:Object = FlexGlobals.topLevelApplication;

And then use the variable.

height="{application.height}"
怎樣才叫好 2024-10-16 05:54:32

如果您使用{this.screen.height},您的警告就会消失。

蒂姆

If you use {this.screen.height} your warnings should go away.

Tim

呢古 2024-10-16 05:54:32

这应该适用于强制转换:

height="{(FlexGlobals.topLevelApplication as Application).height - 32}"

它不适用于当前代码的原因是因为 FlexGlobals.topLevelApplication 被键入为对象。

This should work with a cast:

height="{(FlexGlobals.topLevelApplication as Application).height - 32}"

The reason why it isn't working with your current code is because FlexGlobals.topLevelApplication is typed as an Object.

夜血缘 2024-10-16 05:54:32

我被卡住了半个小时,发现Bindable只能与大写的“B”一起使用,我做到了,它解决了我的问题。

因此,只需编写Bindable,而不是bindable,因为引用的类是bindable.Bindable

I was stuck for half an hour and found out that Bindable only works with a capital 'B', I did it and it solved my problem.

So, instead of bindable just write Bindable as the referred class is bindable.Bindable.

可爱咩 2024-10-16 05:54:32

我正在努力解决类似的警告,但我使用的是 VBox,而不是对象问题(通过 [Bindable] 前缀解决)。我需要根据我的 vbox 有多少个孩子来更改图像的来源。所以解决这个问题的办法就是只使用“this”哈哈。这是一个示例:

<mx:Image width="24" height="24" source="{this.vbBox1.getChildren().length>1 ?    'assets/icons/forwardDisable.png':'assets/icons/forward.png'}"/>

如果您不使用“this”,IDE 将显示一条警告,类似于该对象的警告。我希望它能帮助其他人!

此致

i was struggling with a similar warning, but instead of an object problem (wich is solved with the [Bindable] prefix) i was using a VBox. I needed to change the source of an image depending on how many childs my vbox has. So the solution to this is only using "this" lol. here's an example:

<mx:Image width="24" height="24" source="{this.vbBox1.getChildren().length>1 ?    'assets/icons/forwardDisable.png':'assets/icons/forward.png'}"/>

If you dont use "this" the IDE will show you a warning similar to the one that you have with the object. I hope it helps others!

Best Regards

那一片橙海, 2024-10-16 05:54:32

创建您的应用程序的可绑定变量类型,即 myApp,以获取 myApp 中定义的所有变量或代码补全:

[Bindable]
private var globals:myApp = FlexGlobals.topLevelApplication as myApp;

然后使用该变量。

height="{globals.height}"

Create a bindable variable type of your application i.e myApp to obtain all the variable defined in myApp or code completion:

[Bindable]
private var globals:myApp = FlexGlobals.topLevelApplication as myApp;

And then use the variable.

height="{globals.height}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文