Flex - 在 MXML 中子类化 VBox 以用作基本组件,需要建议

发布于 2024-12-05 20:53:07 字数 712 浏览 1 评论 0原文

我想扩展 VBox 以添加一些“默认值”和一些样板代码(这里我们称之为“VBoxSub”),其想法是应用程序中的“页面”将扩展此 VBox 子类。

这似乎工作正常,只是扩展“VBoxSub”的最终类在 Flash Builder 的设计模式下不会继承 VBoxSub 中设置的宽度/高度设置。当在组件为空的情况下切换到设计模式时,它显示的只是一个微小的普通框,而不是具有默认 VBox css 背景颜色的较大 1000x700 工作区域。这是怎么回事? (是的,我已经尝试过刷新/重新启动设计视图。)

我希望这些组件中的每一个都具有完全相同的大小,以便在布局 UI 时我确切地知道我必须使用多少空间 - 最好< em>无需将宽度和高度属性复制/粘贴到每个该死的mxml文件中(并且不必担心如果w/h发生变化则更新每个文件!)。 (使用 Flash Builder 4、SDK 4.1)

我尝试这样做以使其正常工作,但在设计视图中仍然没有效果:

override protected function measure():void {
    super.measure();

    measuredWidth=1000;
    measuredMinWidth=1000;
    measuredHeight=700;
    measuredMinHeight=700;
}

我真的需要在每个组件中硬编码宽度/高度吗?应用程序内的页面”?

I'd like to extend VBox to add some "defaults" and a bit of boilerplate-ish code (let's call it "VBoxSub" here), the idea being that "pages" in the application would extend this VBox subclass.

This seems to work fine except that the final classes extending "VBoxSub" don't inherit the width/height settings set in VBoxSub when in Flash Builder's design mode. When switching to design mode with the component empty, all it shows is a tiny plain box instead of a larger 1000x700 working area with the default VBox css background color. What's going on here? (Yeah I've tried refreshing/restarting design view.)

I'd like to have each of these components all be exactly the same size so that when laying out the UI I know exactly how much space I have to work with - preferably without having to copy/paste the width and height attributes into every darn mxml file (and having to worry about updating each one if the w/h ever change!). (Using Flash Builder 4, SDK 4.1)

I've tried doing this to get it to work, but still no good in Design View:

override protected function measure():void {
    super.measure();

    measuredWidth=1000;
    measuredMinWidth=1000;
    measuredHeight=700;
    measuredMinHeight=700;
}

Do I really need to hard code width/height in every component "page" within the application?

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

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

发布评论

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

评论(1

笙痞 2024-12-12 20:53:07

Flash Builder 不在设计模式下执行 Actionscript。由于不执行 AS 代码,因此不会在设计模式下测量 VBox。

在这种情况下您需要使用声明性 MXML。

Flash Builder doesn't execute Actionscript in design mode. Since the AS code doesn't get executed, the VBox doesn't get measured in design mode.

You need to use declarative MXML in such a situation.

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