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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:11:29+00:00 2026-05-13T22:11:29+00:00

Hey everyone, my first time trying to draw a multi-color gradient in actionscript 3.

  • 0

Hey everyone, my first time trying to draw a multi-color gradient in actionscript 3.

So I got this code from the help docs, but I can’t seem to get a vertical gradient, whatever formula or number I use for rotate, it stays stuck on the default horizontal gradient 🙁

My Code:

You can see in the traces the rotation code I tried…

package
{
import flash.display.DisplayObject;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.Shape;
import flash.geom.Matrix;
import flash.events.*;

public class MyGradient extends MovieClip
{
    private var colorHolder:MovieClip = new MovieClip();
    private var colorGrad:MovieClip = new MovieClip();
    private var fillType:String     = GradientType.LINEAR;
    private var colors:Array        = [0xFF0000, 0x4F8EEC];
    private var alphas:Array        = [1, 1];
    private var ratios:Array        = [0x00, 0xFF];
    private var matr:Matrix         = new Matrix();
    private var spreadMethod:String = SpreadMethod.PAD;


    public function MyGradient():void
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init():void
    {
        colorHolder = new MovieClip();
        colorGrad   = new MovieClip();

        //matr.rotate(30*Math.PI/180);
        //matr.rotate(45);
        //matr.rotate(90);
        //matr.rotate(Math.PI/90);
        matr.rotate(Math.PI/9);
        matr.createGradientBox(200, 200, 0, 0, 1);
        colorGrad.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);        
        colorGrad.graphics.drawRect(0,0,200,200);

        colorHolder.addChild(colorGrad);
        addChild(colorHolder);
        }

    }

}

Updated Fix by Heavily involved:

matr.createGradientBox(200, 200, Math.PI/2, 0, 0);

alt text

  • 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-13T22:11:29+00:00Added an answer on May 13, 2026 at 10:11 pm

    This line of code sets the rotation value back to zero:

    matr.createGradientBox(200, 200, 0, 0, 1);
    

    If you look at the parameters accepted by the function you’ll see that the third parameter is rotation. So, try the following:

    matr.createGradientBox(200, 200, Math.PI/9, 0, 1);
    

    Also, is there any reason you are translating the y value by 1 pixel?

    Hope this helps. Good luck!

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

Sidebar

Ask A Question

Stats

  • Questions 363k
  • Answers 363k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Instead of forcefully sending the user/bot why not just make… May 14, 2026 at 3:23 pm
  • Editorial Team
    Editorial Team added an answer When you call a method, you call it for a… May 14, 2026 at 3:23 pm
  • Editorial Team
    Editorial Team added an answer thanks ctacke i got it already. Here it is :)… May 14, 2026 at 3:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.