如何在Actionscript 3中的矩形内创建灯光效果?

时间:2010-05-24 10:10:29

标签: actionscript-3

我试图在这里http://wonderfl.net/c/9Kdv尝试这样做,但我想要的不是这个

alt text http://reboltutorial.com/images/flash-banner-trial.png

而是相当于此。因为我是闪光新手,我不知道如何:

alt text http://reboltutorial.com/files/2010/05/create-free-banner.png

动作脚本3代码如下:

package {
    import flash.display.*;
    import flash.text.*;
    import flash.net.URLRequest;
    import flash.filters.*;

    import flash.geom.Rectangle;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var mc:MovieClip = new MovieClip();
            mc.graphics.beginFill(0x400000);
            mc.graphics.drawRoundRect(0, 0, 278, 170,25,25);
            mc.graphics.endFill();
            mc.x = 80;
            mc.y = 60;
            addChild(mc);  

            //from tut http://blog.0tutor.com/post.aspx?id=116
            var filt:GlowFilter = new GlowFilter();  
            var filt_shadow:DropShadowFilter = new DropShadowFilter();              
            //here we add some properties to the two filters, the glow filter we give a color.   
             filt.color = 0xFF0000;  

             //and how much it should blur.   
             filt.blurX = 7;  
             filt.blurY = 7;  

             //then the dropshadow filter, also how much it should blur on the object.   
             filt_shadow.blurX = 4;  
             filt_shadow.blurY = 4;  

             //and finally an alpha, the alpha goes from 1 to 0, 1 being fully visible and 0 is transparent, then of cause .5 is just in between.   
             filt_shadow.alpha = .4;  


             mc.filters =  [filt,filt_shadow];

            var theTextField:TextField = new TextField();
            theTextField.border = false;
            theTextField.x = 30;
            theTextField.y = 50;
            theTextField.autoSize = TextFieldAutoSize.LEFT;
            theTextField.text = "Experiment";

            var myformat:TextFormat = new TextFormat();
            myformat.color = 0xFFFFFF;
            myformat.size =24;
            myformat.align="center";                
            myformat.font = "Impact";

            theTextField.setTextFormat(myformat);   
            mc.addChild(theTextField);      

            var url:String = "//www.rebol.com/graphics/reb-logo.gif";
            var urlReq:URLRequest = new URLRequest(url);

            var ldr:Loader = new Loader();
            ldr.load(urlReq);
            ldr.x=30;
            ldr.y=88;
            mc.addChild(ldr);


        }
    }
}

1 个答案:

答案 0 :(得分:1)

而不是这一行:

mc.graphics.beginFill(0x400000);

您可以使用beginGradientFill并将fillType设置为GradientType.RADIAL。您只需要调整focalPointRatio以使其偏离中心。查看文档中有关如何执行此操作的示例。