这是源码packagecommon.photogallery.shadow{importflash.display.Graphics;importflash.display.Mo
这是源码
package common.photogallery.shadow
{
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
import mx.controls.Alert;
import mx.controls.Image;
import mx.core.UIComponent;
import mx.events.FlexEvent;
import mx.events.MoveEvent;
import mx.events.ResizeEvent;
import spark.primitives.Ellipse;
import spark.primitives.Graphic;
public class HangingShadow extends UIComponent
{
/** This class should really be something much lighter than a UIComponent
* Perhaps even just drawn on the parent graphics layer. However, this is
* convenient for blur and scale and the point of this code is to demonstrate
* the major lifecycle methods of flex. It is not an illustration of best
* optimization practices **/
protected var blurFilter:BlurFilter = new BlurFilter(32,16,2);
override protected function updateDisplayList( uw:Number, uh:Number ):void {
super.updateDisplayList( uw, uh );
trace(uw+" "+uh);
//draw the shadow and change filter settings
var g:Graphics = graphics;
g.clear();
var matrix:Matrix = new Matrix( 200, 0, 0, 200, 0, 0 );// = {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1};
g.beginGradientFill("radial", [0x000000, 0xFFFFFF], [.7,0], [0x7F, 0x0], matrix, "reflect", "linearRGB");
g.drawEllipse( 1, 1, uw, uh );
g.endFill();
this.filters = [blurFilter];
}
private function tCircle(x:Number, y:Number, tWidth:Number, tHeight:Number):void{
graphics.clear();
var matrix:Matrix = new Matrix( 200, 0, 0, 200, 0, 0 )
//the last parameter can selete three type: SpreadMethod.PAD or SpreadMethod.REFLECT or SpreadMethod.REPEAT.
graphics.beginGradientFill("radial", [0x000000, 0xFFFFFF], [.7,0], [0x7F, 0x0], matrix, "reflect", "linearRGB");
graphics.beginFill(0xFF0000);
graphics.drawEllipse(x, y, tWidth, tHeight);
}
public function HangingShadow() {
}
}
}
5 个解决方案
自己顶一下 版本是 flex4 ,如果兼容flex3的话是可以的
override protected function updateDisplayList( uw:Number, uh:Number ):void {
super.updateDisplayList( uw, uh );
trace(uw+" "+uh);
//draw the shadow and change filter settings
var g:Graphics = graphics;
g.clear();
var matrix:Matrix = new Matrix( 200, 0, 0, 200, 0, 0 );// = {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1};
g.beginGradientFill("radial", [0x000000, 0xFFFFFF], [.7,0], [0x7F, 0x0], matrix, "reflect", "linearRGB");
g.drawEllipse( 1, 1, uw, uh ); //这里报错 下面那个方法不要管
g.endFill();
this.filters = [blurFilter];
}
我了个去, 还是自己找到方法了, 原因是Flex3和Flex4某些部分不兼容 之前用的是 百分比写的宽度和高度,写成实际高度就行了!