如何将控件添加到弹性面板的标题栏?
我正在尝试通过向面板控件的右上角添加句柄来实现可折叠的 TitleWindow 弹出窗口。不幸的是,绘制控件时,我添加为句柄的图像不会显示。我可以通过更改图像的来源来触发重绘,所以显然它在那里,但它以某种方式隐藏了。
有没有办法让这个 Image 控件对用户可见?
这是窗口的代码:
package
{
import mx.containers.Panel;
import mx.controls.Image;
public class CollapsableWindow extends Panel
{
public function CollapsableWindow()
{
super();
}
public var close:Image;
protected override function createChildren():void
{
super.createChildren();
close = new Image();
close.source = "/assets/close.png";
close.x = this.width - 20;
close.y = 8;
this.titleBar.addChildAt(close, 0);
}
}
}
I'm trying to implement a collapsible TitleWindow popup by adding a handle to the top right corner of a Panel control. Unfortunately, the image that I add as the handle doesn't show up when the control is drawn. I can trigger a redraw by changing the source of the image, so apparently it's there, but it's somehow hidden.
Is there a way to make this Image control visible to the user?
Here's the code for the window:
package
{
import mx.containers.Panel;
import mx.controls.Image;
public class CollapsableWindow extends Panel
{
public function CollapsableWindow()
{
super();
}
public var close:Image;
protected override function createChildren():void
{
super.createChildren();
close = new Image();
close.source = "/assets/close.png";
close.x = this.width - 20;
close.y = 8;
this.titleBar.addChildAt(close, 0);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在 createChildren 方法中创建按钮,然后将其放置在 updateDisplayList 方法中:
You need to create your button in the createChildren method, then position it in the updateDisplayList method:
我遇到了 PNG 未显示在我们的应用程序中的问题。每隔一段时间,我们所有的巴布亚新几内亚就会消失。要测试您的代码是否遇到同样的问题,请尝试使用 GIF 或其他格式的测试图像。如果它有效,那么您将遇到我已经遇到过数十次的相同问题。
在我们的项目中,我们通过两种方式解决这个问题:
我希望以某种方式有所帮助,
--gMale
I've had issues with PNG's not showing up in our app. Every once in a while, all our PNG's disappear. To test whether you're code suffers the same problem, try using a test image that's a GIF or other format. If it works then you're having the same issue I've run into dozens of times.
On our project, we solve this in two ways:
I hope that helps in some way,
-- gMale