| Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact | |
BackGround |
|
|
| Property | Defined By |
|---|---|
|
focalPointRatio
: Number
To set the ratio of the focal point. |
BackGround |
| Method | Defined By |
|---|---|
| BackGround(color1:uint, color2:uint, fiType:String="linear", spMethod:String="pad", r1:int=0, r2:int=255, grSize:int=0, grHeight:int=0, grRot:int=0, grX:int=0, grY:int=0) | BackGround |
|
removChild()
Removes an existing background. |
BackGround |
|
fadeBGOut()
Fades out a background. |
BackGround |
|
fadeBGIn()
Fades in a background. |
BackGround |
| Event | Defined By |
|---|---|
| All inherited events for the Sprite class. | N/A |
| Property Detail |
|---|
|
focalPointRatio
property
focalPointRatio:Number [read-write] A number that controls the location of the focal point of the gradient. A value of 0 sets the focal point in the center. A value of 1 means that the focal point is at one border of the gradient circle.A value of -1 sets the focal point at the other border of the gradient circle. The default value is 1. Implementationpublic function get focalPointRatio():Numberpublic function set focalPointRatio(value:Number):void |
| Constructor Detail |
|---|
|
BackGround () Constructor
public function BackGround(color1:uint, color2:uint, fiType:String="linear", spMethod:String="pad", r1:int=0, r2:int=255, grSize:int=0, grHeight:int=0, grRot:int=0, grX:int=0, grY:int=0) |
| Intializes a new BackGround instance. |
Parameters
|
| Method Detail |
|---|
|
removChild() method
public function removChild():void |
| This method will remove the background. |
|
fadeBGOut() method
public function fadeBGOut():void |
| This method will fade out the background. |
|
fadeBGIn() method
public function fadeBGIn():void |
| This method will fade in a background. |
| Examples |
|---|
Create a new fla file and name it Background.fla. Place the fla in the same folder as the biz folder. Create a rectangle MovieClip (Clip) with a red border and no fill and export for Actionscript. Then create an Actionscript file, name it Background.as and place this script. You should see a gradient colored background. Pressing the MovieClip will change the background.
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import biz.flashscript.background.BackGround;
public class Background extends Sprite
{
private var bg:BackGround;
private var mc:Clip;
public function Background ():void
{
var bgt:BackGround = new BackGround (0xFFFFFF,0x000000,"linear","pad",0,255,0,0);
addChild(bgt);
bgt.focalPointRatio = -1;
mc = new Clip();
mc.x = 100;
mc.y = 100;
addChild (mc);
bg = new BackGround (0xFF0000,0xFFFF00,"linear","pad",0,255,mc.width,mc.height);
mc.addChild(bg);
addEventListener (MouseEvent.CLICK, cHandler);
}
private function cHandler (e:Event):void
{
bg.removChild();
bg.fadeBGOut ();
bg.focalPointRatio = -1;
bg = new BackGround (0xFFFF00,0xFF0000,"radial","pad",150,255,mc.width,mc.height,0,20,0);
mc.addChild(bg);
bg.fadeBGIn ();
}
}
}
|