Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

In Flash MX2004, how do I turn this linear gradient box into a radial gradient circle?

Posted on 2007-11-28
6
Medium Priority
?
237 Views
Last Modified: 2008-02-01
How do I modify this action script so that it produces a circle with a concentric radial gradient, instead of a box with a linear gradient?

Thanks,
John
import flash.geom.*
//
var mc:MovieClip = this.createEmptyMovieClip("grad", 1);
 
var colors = [0x79986B, 0xDCE0B6, 0x79986B, 0x000000];
var alphas = [100, 100, 100,100];
var ratios = [0, 15, 30,45];
var matrix = {matrixType:"box", x:100, y:100, w:200, h:200, r:(45/180)*Math.PI};
mc.beginGradientFill("linear",colors,alphas,ratios,matrix);
mc.moveTo(100,100);
mc.lineTo(100,300);
mc.lineTo(300,300);
mc.lineTo(300,100);
mc.lineTo(100,100);
mc.endFill();

Open in new window

0
Comment
Question by:gabrielPennyback
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 20367595
Just change "linear" to "radial"

you can also play with "ratios" array, to change the size of gradient circle.
for example, try replacing existing "radios" array with following:
var ratios = [0, 50, 100, 200];

here is the updated code:
import flash.geom.*;
//
var mc:MovieClip = this.createEmptyMovieClip("grad", 1);
 
var colors = [0x79986B, 0xDCE0B6, 0x79986B, 0x000000];
var alphas = [100, 100, 100, 100];
var ratios = [0, 15, 30, 45];
 
var matrix = {matrixType:"box", x:100, y:100, w:200, h:200, r:(45/180)*Math.PI};
mc.beginGradientFill("radial",colors,alphas,ratios,matrix);
mc.moveTo(100,100);
mc.lineTo(100,300);
mc.lineTo(300,300);
mc.lineTo(300,100);
mc.lineTo(100,100);
mc.endFill();

Open in new window

0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 20368510
Hi aneesh,

Yes that was the first thing i tried, but I still get a 200x200 black box around the much smaller circle gradient.bIs "box" an ActionScript defined term?  I thought maybe "circle" would get rid of the black box, but that produces no shape at all.

John
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 20371147
as I already mentioned

"
you can also play with "ratios" array, to change the size of gradient circle.
for example, try replacing existing "radios" array with following:
var ratios = [0, 50, 100, 200];
"

ratios defines the area each gradient color will occupy

ratio value must be in between 0 to 255

to get rid of black color you can set last color alpha to 0

just try follwoing code and see the output:
import flash.geom.*;
//
var mc:MovieClip = this.createEmptyMovieClip("grad", 1);
 
var colors = [0x79986B, 0xDCE0B6, 0x79986B, 0x000000];
var alphas = [100, 100, 100, 0];
var ratios = [0, 50, 150, 200];
 
var matrix = {matrixType:"box", x:100, y:100, w:200, h:200, r:(45/180)*Math.PI};
mc.beginGradientFill("radial",colors,alphas,ratios,matrix);
mc.moveTo(100,100);
mc.lineTo(100,300);
mc.lineTo(300,300);
mc.lineTo(300,100);
mc.lineTo(100,100);
mc.endFill();

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 20371179
another point,
"ratios" Array value should be set in incremental to each previous element of the array
and value should be inbetween 0 to 255

0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 20374870
Thanks, aneesh. The main key was making that last alpha zero. Thanks for the continuing education.

Please take a look at this related quesion. If you have the time to post an answer now that would be awesome.

http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_22990904.html
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 20375432
welcome,
I just say the linked question and it has already been answered.

secondly,
if you are satisfy with my comment on this question.
Please close this question by accepting the appropriate comment


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question