4,328
社区成员
发帖
与我相关
我的任务
分享
<mx:Image horizontalAlign="center" id="image" creationComplete="imageComplete()"
width="100%" height="100%" />
private function imageComplete(): void{
if (this.data.isntCutImage == "Y" || this.data.isntTop == "Y" || this.data.isntCover == "Y"){
var _text:TextField = new TextField();
if (this.data.isntCutImage == "Y"){
_text.text = "剪切图片";
}
if (this.data.isntTop == "Y"){
_text.text = "置顶图片";
}
if (this.data.isntCover == "Y"){
_text.text = "封面图片";
}
var _sprite:Sprite = new Sprite();
_sprite.graphics.beginFill(0xffffff, 0.7);
_text.width = image.width;
var textFormat:TextFormat = new TextFormat();
textFormat.bold = true;
textFormat.italic = true;
textFormat.color = "#ff0000";
textFormat.align = "center";
textFormat.size = 13;
_text.setTextFormat(textFormat);
_sprite.graphics.drawRect(0, 0, image.width, 24);
_sprite.graphics.endFill();
_sprite.addChild(_text);
// 我想先判断一下,image时候有子对象,有的话就先删除,我用下面的方法去删除,加上这段代码后,image就不显示图片了,
if (DisplayObjectContainer(image).numChildren > 0){
image.removeChildAt(0);
}
image.source = this.data.furl;
this.image.addChild(_sprite);
}
}