如何在 Adobe Flex 中操纵形状?
我正在开发一个应用程序,在屏幕上绘制一些矩形,然后需要操作形状(更改它们的大小、位置)。我尝试用 .drawRect 做一些事情,并在每次操作它时清除形状,但 RAM 使用量先增加后下降(大概是因为我不断重新初始化一个新组件,然后将其删除,而垃圾收集正在将其清除) 。这看起来可能不是最有效的方法。
有没有办法让我只创建一个形状一次,然后在画布上移动它(并在不使用所有 RAM 的情况下更改其宽度和高度?
I'm working on an application where I'm drawing some rectangles on the screen, and then will need to manipulate the shapes (change their size, location). I tried to do something with .drawRect and clearing the shape each time I was manipulating it, but the RAM usage was spiking and then falling (presumeably because i keep reinitializing a new component and then removing it, and garbage collection was cleaning it out). This seems like its probably not the most efficient way to do it.
Is there a way for me to just create a shape once, and then move it around on a canvas (and change its width and height without all this RAM usage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你所做的只是改变它的偏移,并调整它的宽度和高度,而不需要从根本上改变形状的结构(例如圆化某些矩形的角),你应该能够维护对Shape 并调整它的 x、y、scaleX、scaleY 属性以实现更改。
If all you're doing is changing it's offsets, and adjusting it's width and height without needing to fundamentally change the structure of the shape (such as rounding the corners of a rectangle of some such) you should be able to just maintain a reference to the Shape and adjust it's x, y, scaleX, scaleY properties to effect the changes.
您可以尝试 Degrafa 绘制矩形。
要移动矩形:
You can try Degrafa to draw the rectangle.
To move the rectangle: