Search code examples
apache-flexgraphicsflex4primitive

flex: assigning id to primitives


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?


Solution

  • 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