Flex 自定义组件不会调整大小
我正在尝试使用以下事件处理程序创建一个扩展对象
public function pickerMove(e:MouseEvent):void {
trace("in mouse move");
var offsetX:int = e.stageX - touchX;
trace(offsetX);
picker.x += offsetX;
trace(picker.width);
picker.width -= offsetX;
trace(picker.width);
touchX = e.stageX;
}
picker.x += offsetX 按预期工作并移动组件的 x 坐标。
问题在于 picker.width -= offsetX
组件的宽度在屏幕上不会改变,但 picker.width 的值在控制台上打印时会发生变化。
以下是跟踪的一些示例输出:
in mouse move
-1
928
929
in mouse move
-1
929
930
in mouse move
-1
930
931
关于自定义组件大小调整,是否有一些我不知道的事情?
I am trying to create an expanding object with the following event handler
public function pickerMove(e:MouseEvent):void {
trace("in mouse move");
var offsetX:int = e.stageX - touchX;
trace(offsetX);
picker.x += offsetX;
trace(picker.width);
picker.width -= offsetX;
trace(picker.width);
touchX = e.stageX;
}
The picker.x += offsetX works just as expected and moves the the x coordinate of the component.
The problem is with the picker.width -= offsetX
The width of the component doesn't change on the screen, but the value of picker.width changes as it is printed out on the console.
Here's some sample output from the trace's:
in mouse move
-1
928
929
in mouse move
-1
929
930
in mouse move
-1
930
931
Is there something that I don't know about custom components resizing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 UIComponent 失效机制并覆盖自定义组件中的
updateDisplayList()
以使用新宽度重新绘制组件。Try to use UIComponent invalidation mechanisms and override
updateDisplayList()
in your custom component to redraw your component with new width.