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

  • Home
  • SEARCH
  • 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 8566709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:43:02+00:00 2026-06-11T17:43:02+00:00

Having a bit of a problem with some code I’ve written. Basically what it

  • 0

Having a bit of a problem with some code I’ve written. Basically what it does is take 3 values that constantly change and graphs them over time in the form of a cumulative line graph. It almost works except I get this weird line drawn across the entire stage and further and I can’t figure out what the issue is. The full code is below, you can run it by pasting it into flash.

import flash.display.Shape;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.utils.Timer;

var y1:Array = new Array();
var y2:Array = new Array();
var y3:Array = new Array();
var avg:Array = new Array();

var y1Shape:Shape = new Shape();
var y2Shape:Shape = new Shape();
var y3Shape:Shape = new Shape();
var avgShape:Shape = new Shape();

var container:Sprite = new Sprite();

var scale:uint = 1;

var redrawGraph:int = setInterval(reDraw,500);

var y1Int:int = 0;
var y2Int:int = 0;
var y3Int:int = 0;

container.addChild(y1Shape);
container.addChild(y2Shape);
container.addChild(y3Shape);
container.addChild(avgShape);
this.addChild(container);

function reDraw():void
{
    y1Shape.graphics.clear();
    y2Shape.graphics.clear();
    y3Shape.graphics.clear();
    avgShape.graphics.clear();

    y1Shape.graphics.lineStyle(1, 0x0066FF, 1);
    y1Shape.graphics.beginFill(0x0066FF, 0.5);
    y2Shape.graphics.lineStyle(1, 0x009900, 1);
    y2Shape.graphics.beginFill(0x009900, 0.5);
    y3Shape.graphics.lineStyle(1, 0x990000, 1);
    y3Shape.graphics.beginFill(0x990000, 0.5);
    avgShape.graphics.lineStyle(1, 0x000000, 1);

    y1Int = rand();
    y2Int = rand();
    y3Int = rand();

    trace(y1Int, y2Int, y3Int);

    y1.unshift(y1Int);
    y2.unshift(y2Int);
    y3.unshift(y3Int);
    popOut(y1);
    popOut(y2);
    popOut(y3);

    var i:uint,sum:uint,aLength:uint,len:uint = y1.length,max:int = 0,height_:int = 400;
    scale = 10;
    for (i=0; i<len; i++)
    {
        max = Math.max(y1[i] + y2[i] + y3[i],max);
    }

    for (i=0; i<len; i++)
    {
        sum +=  y1[i] + y2[i] + y3[i];
    }

    avg.unshift(Math.round(sum/len));

    /*--------------------------------MATCHED GRAPH------------------------------------------*/
    var y1_commands:Vector.<int> = new Vector.<int>();
    var y1_coord:Vector.<Number>= new Vector.<Number>();
    var y1_coord_rev:Vector.<Number> = new Vector.<Number>();
    y1_commands.push(1);
    y1_coord.push(400,height_);

    for (i=0; i<len; i++)
    {
        y1_commands.push(2);
        y1_coord.push((400-i*scale),height_-(Math.round((y1[i]/max)*height_)));
        y1_coord_rev.unshift((400-i*scale),height_-(Math.round((y1[i]/max)*height_)));
    }
    for (i=len; i>0; i--)
    {
        y1_commands.push(2);
        y1_coord.push(400 - i*scale,height_);
    }
    y1_commands.push(2);
    y1_coord.push(400,height_);

    /*--------------------------------MATCHED GRAPH------------------------------------------*/

    /*----------------------------------BUSY GRAPH-------------------------------------------*/
    var y2_commands:Vector.<int> = new Vector.<int>();
    var y2_coord:Vector.<Number>= new Vector.<Number>();
    var y2_coord_rev:Vector.<Number> = new Vector.<Number>();
    y2_commands.push(1);
    y2_coord.push(400,height_-(Math.round((y1[i]/max)*height_)));

    for (i=0; i<len; i++)
    {
        y2_commands.push(2);
        y2_coord.push((400-i*scale),height_-(Math.round(((y1[i]+y2[i])/max)*height_)));
        y2_coord_rev.unshift((400-i*scale),height_-(Math.round(((y1[i]+y2[i])/max)*height_)));
    }
    for (i=len; i>0; i--)
    {
        y2_commands.push(2);
        y2_coord.push(400 - i*scale, height_-(Math.round((y1[i]/max)*height_)));
    }
    y2_commands.push(2);
    y2_coord.push(400,height_-(Math.round((y1[i]/max)*height_)));

    /*----------------------------------BUSY GRAPH-------------------------------------------*/

    /*----------------------------------VAC GRAPH-------------------------------------------*/
    var y3_commands:Vector.<int> = new Vector.<int>();
    var y3_coord:Vector.<Number>= new Vector.<Number>();
    var y3_coord_rev:Vector.<Number> = new Vector.<Number>();
    y3_commands.push(1);
    y3_coord.push(400,height_-(Math.round(((y1[i]+y2[i])/max)*height_)));

    for (i=0; i<len; i++)
    {
        y3_commands.push(2);
        y3_coord.push((400-i*scale),height_-(Math.round(((y1[i]+y2[i]+y3[i])/max)*height_)));
        y3_coord_rev.unshift((400-i*scale),height_-(Math.round(((y1[i]+y2[i]+y3[i])/max)*height_)));
    }
    for (i=len; i>0; i--)
    {
        y3_commands.push(2);
        y3_coord.push(400 - i*scale, height_-(Math.round(((y1[i]+y2[i])/max)*height_)));
    }
    y2_commands.push(2);
    y2_coord.push(400,height_-(Math.round(((y1[i]+y2[i])/max)*height_)));

    /*----------------------------------BUSY GRAPH-------------------------------------------*/
    //y3Shape.graphics.drawPath(y3_commands, y3_coord);
    y2Shape.graphics.drawPath(y2_commands, y2_coord);
    y1Shape.graphics.drawPath(y1_commands, y1_coord);

}

function popOut(a:Array):void
{
    if (a.length >=Math.ceil(400/scale))
    {
        a.pop();
    }
}

function rand():int
{
    return Math.floor(Math.random() * (1 + 5 - 0) + 0);
}

y3Shape is commented out until the problem with y2Shape is fixed (having both drawn just makes the problem harder to figure out).

Any ideas what could be up?

Thanks

  • 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-06-11T17:43:03+00:00Added an answer on June 11, 2026 at 5:43 pm

    If you insert trace your vectors near .drawPath, you’ll see something like that:

    trace(y2_commands); // 1,2,2,2,2
    trace(y2_coord); // 400,171,400,57,390,NaN,400,171,400,57
    

    So, NaN (Not a Number) means, that you have error in coordinates calculating.

    ps. y1[i] in first calculating of BUSY GRAPH is undefined

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

Sidebar

Related Questions

I'm having a bit of a problem normalizing a UPC string code so that
I'm having a bit of an odd problem while trying to compile some code
I'm having a bit of a problem with some legacy code. A ticket asks
Im having some problem with a bit of JQuery code and I don't know
Hey, I'm having some difficulty with CSS and IE6 compatibility. URL : http://bit.ly/dlX7cS Problem
I'm having a bit of a problem using FieldOffset correctly with arrays. The code
I'm having a bit of a problem because neither Javascript nor ActiveX (written in
I'm having an interesting but difficult problem with my JavaScript code. Basically, I'm trying
I'm having a bit of difficulty with some java code class foo{ public bar()
I am having a bit of a problem here. I have two int values,

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.