flex:将 id 分配给基元
我通过动作脚本在屏幕上创建了一些 Flex 原语。现在,根据业务逻辑,我需要对其中一些原语进行更改,例如:更改厚度、箭头方向等。
一种想法是在构建这些原语时为其分配 id - 我该怎么做?
例如,我得到一条如下所示的线
var myShape:Shape=new Shape();
myShape.graphics.lineStyle(thickness,color);
myShape.graphics.moveTo(XFrom,YFrom);
myShape.graphics.lineTo(XTo,YTo);
如果根据某些条件,我想更改上面的颜色/厚度,我如何引用上面的这条线?
I have created a few flex primitives on screen via action script. Now based on business logic, I need to make changes to some of these primitives such as: changing thickness, direction of arrowhead etc
One thought was to assign id's to these primitives as they are built- how do I do that?
e.g. I get a line built as below
var myShape:Shape=new Shape();
myShape.graphics.lineStyle(thickness,color);
myShape.graphics.moveTo(XFrom,YFrom);
myShape.graphics.lineTo(XTo,YTo);
If, based on some condition, I want to change the color/ thickness of above, how do i reference this line above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可以想象这是在某种组件内完成的。所有 UIComponent 都有一个您想要的 生命周期坚持。您可以重写多个函数以获得您想要的功能类型。像这样:
如果您希望它在数据更改时运行,您应该查看
invalidateDisplayList
,您将在任何数据更改后调用它,并且它将在下一帧上运行 updateDisplayList 函数。It'd imagine this is done within a component of some sort. All UIComponents have a lifecycle which you want to adhere to. You can override several functions to get the kind of functionality you want. Like this:
And if you want it to run when you data changes, you should look into
invalidateDisplayList
which you would call after whatever data has changed and it would run the updateDisplayList function on the next frame.我想出了一个更简单的方法
基本上不是直接绘制图元,而是将绘制分配给一个形状函数,该函数将返回一个 Shape 对象。
现在,原始线有一个简单的处理程序来更改属性。如果您需要有关如何实现此目标的更多具体细节,请告诉我
I came up with a more easier approach
Basically instead of drawing the primitives directly, assigned the draw to a shape function which will return a Shape object.
Now the primitive line has a easy handler to change properties. let me know if you need more specific details on how to achieve this