Image 动作脚本3。30次使用一个图像,6次使用另一个图像

Image 动作脚本3。30次使用一个图像,6次使用另一个图像,image,actionscript-3,flash,class,actionscript,Image,Actionscript 3,Flash,Class,Actionscript,好的,我正在制作闪存游戏。在这个游戏中,你需要找到2张相等的牌并发现它们。这里总共有36张卡(6x6) 我有两个不同的图像卡时,它产生。1.png我需要使用30次,2.png我需要使用6次。 示例(其中星号应为2.png): 可能吗 这是我的名片。作为电影剪辑 package { import flash.display.MovieClip; import flash.events.MouseEvent; public class Card extends Movie

好的,我正在制作闪存游戏。在这个游戏中,你需要找到2张相等的牌并发现它们。这里总共有36张卡(6x6)

我有两个不同的图像卡时,它产生。1.png我需要使用30次,2.png我需要使用6次。 示例(其中星号应为2.png):

可能吗

这是我的名片。作为电影剪辑

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    public class Card extends MovieClip
    {
        public var _type:*;

        public function Card()
        {
            this.buttonMode = true;
            this.addEventListener(MouseEvent.CLICK, onClick);
        }

        private function onClick(event:MouseEvent):void
        {
            if(this.currentFrame == 1)
            {
                this.play();
            }
        }

        public function setType(type:*):void
        {
            _type = type;
            loader_mc.addChild(_type);
        }
    }
}

非常感谢。

使用Loader或URLLoader加载文件后,您需要将加载的内容转换为可重用对象

private var starsVec:Vector.<Bitmap >  = new Vector.<Bitmap >   ;
private var starBitmapData:BitmapData;

public function shiiiit()
{
    var loader:Loader = new Loader  ;
    var url:URLRequest = new URLRequest("plik.png");
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);
    loader.load(url);
}

private function onLoaded(e:Event):void
{
    //saves loaded graphic file into BitmapData object
    starBitmapData = new BitmapData(e.target.content.width,e.target.content.height,true,0);
    starBitmapData.draw(e.target.content);
    createTable();
}

private function createTable():void
{
    for (var i:uint=0; i<6; i++)
    {
        //now use BitmapData object to create new Bitmap object and add it to stage
        starsVec.push(new Bitmap(starBitmapData));
        var starsVecTopElem:Bitmap = starsVec[starsVec.length - 1];
        addChild(starsVecTopElem);
    }
}
private var starsVec:Vector.=新向量;
私有var starBitmapData:BitmapData;
公共职能部门
{
变量加载器:加载器=新加载器;
var url:URLRequest=newurlRequest(“plik.png”);
loader.contentLoaderInfo.addEventListener(事件.完成,已加载);
loader.load(url);
}
已加载私有函数(e:事件):无效
{
//将加载的图形文件保存到BitmapData对象中
starBitmapData=新的BitmapData(e.target.content.width,e.target.content.height,true,0);
starBitmapData.draw(如target.content);
createTable();
}
私有函数createTable():void
{

对于(var i:uint=0;i loader\u mc看起来像什么?更简单的是:如果加载PNG,
内容
的类型是
位图
,则可以执行
starBitmapData=e.target.content.bitmapdata;
,仅此而已。