屏幕图像不会出现在屏幕上

时间:2010-04-15 22:58:44

标签: flash actionscript-3

我已经向库中导入了两个图像,并为它们提供了自定义类名MaskImage和MaskedImage。然后我写代码:

package { import flash.display.*;

public class MaskDemo extends Sprite
{
    // Properties

    private var sprMaskedImage:Sprite;
    private var sprMaskImage:Sprite;
    private var bmMaskedImage:Bitmap;
    private var bmMaskImage:Bitmap;

    // Constructor

    public function MaskDemo()
    {
        do_magic();
    }

    // Methods
    private function do_magic():void
    {
        bmMaskedImage = new Bitmap(new MaskedImage(0, 0));
        bmMaskImage = new Bitmap(new MaskImage(0, 0));

        sprMaskedImage = new Sprite();
        sprMaskedImage.addChild(bmMaskedImage);

        sprMaskImage = new Sprite();
        sprMaskImage.addChild(bmMaskImage);

        sprMaskedImage.mask = sprMaskImage;
        this.addChild(sprMaskImage);
    }
}

}

public class MaskDemo extends Sprite { // Properties private var sprMaskedImage:Sprite; private var sprMaskImage:Sprite; private var bmMaskedImage:Bitmap; private var bmMaskImage:Bitmap; // Constructor public function MaskDemo() { do_magic(); } // Methods private function do_magic():void { bmMaskedImage = new Bitmap(new MaskedImage(0, 0)); bmMaskImage = new Bitmap(new MaskImage(0, 0)); sprMaskedImage = new Sprite(); sprMaskedImage.addChild(bmMaskedImage); sprMaskImage = new Sprite(); sprMaskImage.addChild(bmMaskImage); sprMaskedImage.mask = sprMaskImage; this.addChild(sprMaskImage); } }

但它在显示屏上没有显示任何内容。任何想法为什么会发生?

1 个答案:

答案 0 :(得分:0)

我并不完全肯定我明白你要做什么。您是否只想使用一个图像来屏蔽另一个图像?

我看到的一件事是sprMaskedImage没有添加到显示列表中。尝试做addChild(sprMaskedImage);