|
Tim, I saw you had the same problem with
Gradient background too with container components. I’m also trying
to skin the background of a container (“VBOX”). But I’m not
having any luck with it. Here is an example of my code. I am using
Flex Builder 2.0 final. //MXML code <?xml version="1.0"
encoding="utf-8"?> <mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"> <mx:VBox
x="65" y="60"
borderSkin="utils.skins.BackgroundGradientFill"
width="100%" height="100%"
backgroundColor="#00ff00"> </mx:VBox> </mx:Application> //Skin Class package utils.skins { import
mx.skins.RectangularBorder; import
flash.geom.Rectangle; import
flash.geom.Matrix; import
flash.display.DisplayObjectContainer; import
mx.core.IUIComponent; import
flash.events.Event; import
mx.managers.ISystemManager; import
flash.display.Sprite; import
flash.display.DisplayObject; import
flash.display.GradientType; import
flash.display.SpreadMethod; public
class BackgroundGradientFill extends RectangularBorder { private
var _fillColors:Array; private
var _fillAlphas:Array; private
var _fillRatios:Array; private
var _fillMatrix:Matrix; private
var _fillType:String; private
var _fillCornerRadius:Number; private
var _fillRotation:Number; private
var _spreadMethod:String; public
function BackgroundGradientFill() { super(); } override
protected function updateDisplayList(w:Number, h:Number):void{ super.updateDisplayList(w,h); graphics.clear(); _fillCornerRadius
= getStyle("cornerRadius") ? undefined : 0; //var
rota = getStyle("backgroundGradientRotation") ? undefined : 2; _fillRatios
= getStyle("backgroundGradientRatios") ? undefined : [0xCC,0xFF]; _fillColors
= getStyle("backgroundGradientColors") ? undefined :
[0x000000,0xFFFFFF]; _fillAlphas
= getStyle("backgroundGradientAlphas") ? undefined : [1.0,.50]; _fillType
= getStyle("backgroundGradientType") ? undefined :
GradientType.LINEAR; _fillMatrix
= new Matrix(); _fillMatrix.createGradientBox(w,h,0,0,0); _spreadMethod
= SpreadMethod.PAD; _fillRotation
= 2*Math.PI*(90/360); _fillMatrix.rotate(_fillRotation); graphics.beginGradientFill(_fillType,_fillColors,_fillAlphas,_fillRatios,_fillMatrix,_spreadMethod); //or
this but I don't get anywhere. graphics.beginFill(0xFFFFFF,1.0); if(_fillCornerRadius){ var
cr = _fillCornerRadius; graphics.drawRoundRectComplex(0,0,w,h,cr,cr,cr,cr); } graphics.endFill(); } } } From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hoff Hi Mike, I used
your code example and was able to create a skin class that can be applied to
the background of a container. I added/changed the highlighted code
to make the skin class use more of the container's CSS properties. This
is a useful technique! While playing around with this, I stumbled on
something. If you change the first ration to an invalid setting (like
ox140), the rectangle isn't drawn. However, the original background is
also gone. This creates a transparent background without using
alphas. The child controls/components are displayed as if they are
floating. Too cool! I'm starting to believe that you can do just
about anything with Flex, as long you know how. Thanks
again, // CSS ------------------------------------------------------------------------------ .myPanel
{ package
extendedComponents import
flash.geom.Matrix; public
class ContainerBackgroundFillColors extends RectangularBorder
-- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- RE: [flexcoders] Re: Flex2B3: Container fillColors Geoffrey.Rogers
- [flexcoders] Re: Flex2B3: Container fillColors Tim Hoff
- RE: [flexcoders] Re: Flex2B3: Container fillColor... Geoffrey.Rogers

