0 0

as3.0 canvas的更换背景方法20

我用了this.setStyle("backgroundImage","Image/wood.jpg");
方法但是不好使,什么都没有
package at
{
import flash.display.Bitmap;
import flash.display.BitmapData;

import mx.containers.Canvas;
import mx.controls.Alert;
import mx.controls.Image;

public class a extends Canvas
{ [Bindable]
[Embed(source="Image/wood.jpg")]
public var logoSource:Class;
public function a()


super.height=550;
super.width=600;
this.setStyle("backgroundImage","Image/wood.jpg");
//this.setStyle( "skin",logoSource );
this.visible=true;
Alert.show("eeeeeeeeee");

问题补充:
remoteJavaSky 写道
this.setStyle( "backgroundImage",logoSource );
this.setStyle("backgroundImage","Image/wood.jpg");

我试了,这两个写法都是可以的。flex中设置容器背景色可以是Class,也可以是相对地址或绝对地址,如果是Class则直接new出来,如果是地址,则用Loader进行加载。

你可以看看这个类RectangularBorder的源码

你怎么试出来的?给个源码看看呗,canvas有这两个属性么?我用的是flex4不是3
2011年1月18日 11:20

3个答案 按时间排序 按投票排序

0 0

你既然已经是flex4, 那就用spark.components.BorderContainer

2011年1月24日 10:15
0 0

我用的是Flex3,源码FlexBuilder里面有,按住Ctrl键鼠标点击那个类或方法,字段就会进去了。

backgroundImage不是Canvas的属性而是继承自Container的样式,在Flex3中可以Flex4中也应该可以.因为用的都是AS3.0,文档上写着backgroundImage的设置方法,如果路径不对是没有显示的。

2011年1月18日 17:42
0 0

this.setStyle( "backgroundImage",logoSource );
this.setStyle("backgroundImage","Image/wood.jpg");

我试了,这两个写法都是可以的。flex中设置容器背景色可以是Class,也可以是相对地址或绝对地址,如果是Class则直接new出来,如果是地址,则用Loader进行加载。

你可以看看这个类RectangularBorder的源码

2011年1月18日 16:35

相关推荐

Global site tag (gtag.js) - Google Analytics