Search code examples
flashactionscript-3displayobject

AS3 add a border to a displayobject


I know how to draw a rectangle and add it to a DisplayObjectContainer, but do you see a simpler method to directly add a border to a DisplayObject?

DisplayObject don't seem to have addChild(), so I would have to add it on the parent, which is not perfect in my opinion...


Solution

  • I think that if you're forced to use DisplayObject rather than DisplayObjectContainer then you don't have much choice than to write your border to the parent one way or another. Agreed though, it's not a nice way of doing things and I think that if it's possible the better approach would be to not use DisplayObject.

    Edit: How are you creating this as DisplayObject? You can't instantiate displayObjects directly, so is this an extension of DisplayObject or the return value of something?