Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i redraw a shape in ActionScript 3.0?
    primarykey
    data
    text
    <p>My question is: how do I redraw a shape using only code?</p> <p>Short comment on the task itself. I've an eventListener, which grabs clicks on stage and stage resizes. Both execute the same function - <code>redrawEvents(evt:Event)</code>. The stage contains a number of blocks, which represent certain events. On each redraw these blocks are repositioned, and also lines (which represent connections between events) are drawn.</p> <p>I've figured out a way to reposition all the blocks, but I got stuck on redrawing lines.</p> <p>I'm using a single shape to hold all the lines, because lines, unlike blocks, are not interactive. Since the whole point of the application is creating sets of interconnected events, I have to modify this shape every time a new block is created, which also calls redraw function. </p> <p>Here's the code I use to modify the shape</p> <pre><code>stage.addEventListener(MouseEvent.CLICK,redrawEvents); function redrawEvents (evt:Event) { var lines:Shape = new Shape(); lines.graphics.lineStyle(2, 0xFFFFFF, .75); lines.graphics.clear(); for (var k:int = 0; k &lt; connections.length; k++){ lines.graphics.moveTo(eventList[connections[k][0]].x + 50, eventList[connections[k][0]].y + 50); lines.graphics.lineTo(eventList[connections[k][1]].x + 50, eventList[connections[k][1]].y + 50); } addChild(lines); } </code></pre> <p>However, whenever the shape is modified, it still leaves the 'older versions' of itself on screen, and i don't want that. I tried to create and delete instances, varions type conversions, but still that haven't solved the problem.</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload