Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7032211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:54:19+00:00 2026-05-28T00:54:19+00:00

My question is: how do I redraw a shape using only code? Short comment

  • 0

My question is: how do I redraw a shape using only code?

Short comment on the task itself. I’ve an eventListener, which grabs clicks on stage and stage resizes. Both execute the same function – redrawEvents(evt:Event). 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.

I’ve figured out a way to reposition all the blocks, but I got stuck on redrawing lines.

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.

Here’s the code I use to modify the shape

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 < 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);
}

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.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:54:20+00:00Added an answer on May 28, 2026 at 12:54 am

    Each time you draw the lines, you’re adding a new Shape to the stage. You can keep a reference to it and remove it from the display list each time, or just use one instance and the clear() method of Graphics before drawing the new set of lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm using the standardized track listing in this stackoverflow question , and which
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
The question is 2D specific. I am a constantly updating texture, which is a
I'm currently using the following code to apply a radial gradient to the background
[UPDATE] To conclude this question, I implemented my graph using the following two methods
Question as stated in the title.
Question is pretty self explanitory. I want to do a simple find and replace,
Question Alright, I'm confused by all the buzzwords and press release bingo going on.
Question in the title. And what happens when all 3 of $_GET[foo] , $_POST[foo]
Question Can I build a image database/library that has an e-commerce style checkout system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.