好的,我知道这几乎听起来很简单,但我不明白我在这里做的不正确。
我绘制一个简单的圆角矩形
backing1.graphics.beginFill(bgColor);
backing1.graphics.lineStyle(borderSize, borderColor1);
backing1.graphics.drawRoundRect(position1, position1, sizeW-1, sizeH-1, cornerRadius1);
backing1.graphics.endFill();
//backing1.alpha = .1; //<-- tried setting alpha here didn't work
然后尝试将其添加到movieClip
中bgHolder = new MovieClip;
bgHolder.alpha = 0.1;
bgHolder.addChild(backing1);
addChild(bgHolder);
我使用的颜色仍显示为100%:(
package display{
import flash.display.DisplayObject;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.utils.Timer;
import flash.text.TextField;
import flash.events.TimerEvent;
import model.*;
public class Background extends Sprite {
private const position1:Number=0;
private const position2:Number=1;
public static var instance:Background;
private var vTitle :TextField = new TextField();
private var tStorm :TextField = new TextField();
private var backing1 :Shape = new Shape();
private var backing2 :Shape = new Shape();
private var bgColor:uint=0xE8E7E7;
private var borderColor1:uint=0xCCCCCC;
private var borderColor2:uint=0xFFFFFF;
private var borderSize:uint=1;
private var cornerRadius1:uint=3;
private var cornerRadius2:uint=1;
private var sizeW:uint;
private var sizeH:uint;
private var bgHolder:MovieClip;
public var titleString:String="";
public function Background():void {
if (stage) {
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
}
instance=this;
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
bgHolder=new MovieClip ;
bgHolder.alpha=0.1;
bgHolder.addChild(backing1);
addChild(bgHolder);
addChild(backing2);
addChild(vTitle);
addChild(tStorm);
}
public function drawBackground(w, h, mainTitle, color, otherText):void {
sizeW=w;
sizeH=h;
bgColor=color;
titleString=mainTitle;
vTitle.defaultTextFormat=Fonts.PlayingTitle;
vTitle.border=false;
vTitle.embedFonts=false;
vTitle.gridFitType="SUBPIXEL";
vTitle.sharpness=100;
vTitle.antiAliasType=flash.text.AntiAliasType.ADVANCED;
vTitle.selectable=false;
vTitle.mouseEnabled=false;
vTitle.x=5;// 8-3=5 to align copy to video player
vTitle.y=8;
vTitle.width=sizeW-16;
vTitle.height=30;
vTitle.text=titleString;
tStorm.defaultTextFormat=Fonts.TouchStormR;
tStorm.border=false;
tStorm.embedFonts=false;
tStorm.gridFitType="SUBPIXEL";
tStorm.sharpness=100;
tStorm.antiAliasType=flash.text.AntiAliasType.ADVANCED;
tStorm.selectable=false;
tStorm.mouseEnabled=false;
tStorm.x=8;
tStorm.y=sizeH-20;
tStorm.width=sizeW-16;
tStorm.height=20;
tStorm.text=otherText;
backing1.graphics.beginFill(bgColor, 0.1);
//backing1.graphics.beginFill(bgColor);
backing1.graphics.lineStyle(borderSize, borderColor1);
backing1.graphics.drawRoundRect(position1, position1, sizeW-1, sizeH-1, cornerRadius1);
backing1.graphics.endFill();
backing1.alpha=0.5;
backing2.graphics.beginFill(bgColor);
backing2.graphics.lineStyle(borderSize, borderColor2);
backing2.graphics.drawRoundRect(position2, position2, sizeW-3, sizeH-3, cornerRadius2);
backing2.graphics.endFill();
}
public function switchTitle(sentText):void {
titleString=sentText;
vTitle.text=titleString;
}
}
}
答案 0 :(得分:3)
我不知道为什么设置alpha不适合你,但你可以在beginFill调用中设置alpha:
backing1.graphics.beginFill(bgColor, 0.1);
答案 1 :(得分:1)
我尝试了你的源代码,问题似乎是由backing2-Shape引起的。那个精灵没有获得任何alpha,并且被放在支持1上面,因此apearing不透明。删除
时addChild(backing2);
您将看到alpha。