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 523019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:24:50+00:00 2026-05-13T08:24:50+00:00

I am trying to construct an equilateral triangle with the following code, but I

  • 0

I am trying to construct an equilateral triangle with the following code, but I am not seeing what I would expect to.
I would expect to see a triangle drawn to the stage, but I don’t see one.
I think there must be something wrong in terms of the location of the tri sprite on the screen.

public class test_drawing_triangle extends Sprite
{
    public function test_drawing_triangle()
    {
        var tri:Sprite = new Sprite;    
        var nextx:int;
        var nexty:int;
        var prevx:int;
        var prevy:int;
        var angle:Number;
        var radius:Number;
        var deg:int;
        var i:int;

        radius = 10;
       // tri.x = stage.stageWidth / 2;
        tri.y = 50;

        tri.graphics.clear();
        tri.graphics.beginFill(0x000000, 0.5);
        tri.graphics.moveTo(0,0);

        for(deg = 0; deg < 360; deg += 120)
        {
            angle = deg * Math.PI / 180;
            nextx = Math.cos(angle) * radius;
            nexty = Math.sin(angle) * radius;
            tri.graphics.lineTo(nextx, nexty);
        }
        tri.graphics.endFill();
        addChild(tri);
    }
}

UPDATE:

I can now see the triangle but it is not filled in.
It seems to have the generally-correct shape, but I would expect for it be 3 sided, rather than 4.
If anyone could take a sec to compile this and look at what I am describing it would really help.

  • 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-13T08:24:51+00:00Added an answer on May 13, 2026 at 8:24 am

    I’m not sure if I understand what you’re trying to do, but if you want to have the circles at the corners of the triangle. than you need to change the

    tri.graphics.drawCircle(0, 0, 2);

    to

    tri.graphics.drawCircle(nextx, nexty, 2);

    drawCircle takes absolute x,y and doesn’t care about the moveTo

    EDIT – use this code in place of your loop

    deg = 30;
    angle = (deg * Math.PI) / 180.0;
    nextx = Math.cos(angle) * radius;
    nexty = Math.sin(angle) * radius;
    (tri.graphics as Graphics).moveTo(nextx, nexty);
    for(deg = 150; deg < 420; deg += 120)
    {
     angle = (deg * Math.PI) / 180.0;
     nextx = Math.cos(angle) * radius;
     nexty = Math.sin(angle) * radius;   
     (tri.graphics as Graphics).lineTo(nextx, nexty);     
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying construct a PostgreSQL query that does the following but so far my
Trying to construct a helper class that will return an arraylist, but I'm getting
Trying to construct a date: CAST('9/1/' + YEAR(GETDATE()) AS Datetime) AS test2 But it
I'm trying to construct a find command to process a bunch of files in
I'm trying to construct a query that will include a column indicating whether or
I am trying to construct a way to keep certain hard drive partitions/usb drives
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
Im trying to construct a regular expression to just match if the length of
I'm trying to construct a CABasicAnimation to animate the backgroundColor property of a Core
I'm trying to programmatically set the constructor sting of a COM+ component from a

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.