AS 3瓷砖背景

时间:2009-09-22 02:42:07

标签: flash actionscript-3

如何在动作3中制作平铺背景? 我一直在输入我在互联网上找到的代码,但它似乎弄乱了我的幻灯片专业版....所以我想尝试其他一些观点

2 个答案:

答案 0 :(得分:1)

加载位图,使用位图填充将其绘制到形状上,并将形状添加到显示列表的底部。

public function applyTiledBkg(imgURL:String):void
{
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
    //listen to the ioError and other events of the loader here
    loader.load(new URLRequest(imgURL));
}
public function onLoad(e:Event):void
{
    var bmpData:BitmapData = Bitmap(LoaderInfo(e.target).content).bitmapData;
    var bkg:Shape = new Shape();
    bkg.graphics.beginBitmapFill(bmpData);
    bkg.graphics.drawRect(0, 0, bkgWidth, bkgHeight);
    addChildAt(bkg, 0);
}

答案 1 :(得分:0)

相关问题