Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Class for background gradient

 
Jump to:  
 
brian914
PostPosted: Tue Jun 03, 2008 1:13 am    Post subject: Class for background gradient
       
I am new to writing classes, but am trying to learn. I want to write a class
that creates a gradient for the whole stage. I want to be able to pass in the
two color values in the beginning.

Like I said, I am new to this, but here is what I have. Obviously, it is not
working yet. What do I need to change?



In my Fla, I have the following:
myBG = new BgColor(0x000000, 0xCCCCCC);
They are not in the same directory. How do I do that? I have a class path to a
folder on my desktop. But there is a structure within that. Using the import it
would look like this: import com.brianf.BgColor



My class looks like this:

class BgColor
{
public var color01:Number;
public var color02:Number;

private var fillType:String = "linear";
private var colors:Array = [color01, color02];
private var alphas:Array = [100, 100];
private var ratios:Array = [0, 255];
private var matrix:Object = {matrixType:"box", x:0, y:0, w:Stage.width,
h:Stage.height, r:(90/180)*Math.PI};
private var spreadMethod:String = "pad";
private var interpolationMethod:String = "linearRGB";
private var focalPointRatio:Number = 1;


public function BgColor()
{
beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod,
interpolationMethod, focalPointRatio);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
endFill();
}
}



What do I need to change to make this work? Right now, the class does not even
get instantiated.

Thank you so much for the help!
 

 
Ankur Arora
PostPosted: Tue Jun 03, 2008 12:26 pm    Post subject: Re: Class for background gradient
       
Brian,
are you getting some error like "Class or interface could not be loaded"?



[HR]
Thanks & Regards
Ankur Arora
Project Leader(Flash and Flex)
LINK
[H]let your thoughts fly to others... you will become rich.[/H]
[HR]
 

 
David Stiller
PostPosted: Tue Jun 03, 2008 2:07 pm    Post subject: Re: Class for background gradient
       
Brian,

If your import statement would be com.brianf.BgColor, then you'll need
to use that package in your class declaration, like this:

class com.brianf.BgColor
{
public var color01:Number;
public var color02:Number;
// etc.

.... but not in the constructor function, which only needs the class name:

public function BgColor()
{
beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod,
interpolationMethod, focalPointRatio);
// etc.


David Stiller
Adobe Community Expert
Dev blog, LINK
"Luck is the residue of good design."
 

 
brian914
PostPosted: Tue Jun 03, 2008 2:17 pm    Post subject: Re: Class for background gradient
       
No, I get no error. But the class does not get called I think. I put a trace
inside the BgColor() function and it does not get triggered, so I am pretty
sure the class simply does not even get instantiated.

Thanks a lot for the help!
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

artykuły biurowe pierścionek zaręczynowy Boksy reklamowe sypialnia odżywki