actionscript 3 - Action Script 3. 30 times use one image and 6 times other -
ok, i'm creating flash memory game. in game need find 2 equal card , discover them. @ here 36 cards (6x6).
i have 2 different images card when spawns. 1.png need use 30 times , 2.png need use 6 times. example(where stars should 2.png):

is possible?
here card.as movie clip
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); } } } thank much.
after loading files using loader or urlloader need convert loaded content reusable object.
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 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 { (var i:uint=0; i<6; i++) { //now use bitmapdata object create new bitmap object , add stage starsvec.push(new bitmap(starbitmapdata)); var starsvectopelem:bitmap = starsvec[starsvec.length - 1]; addchild(starsvectopelem); } }
Comments
Post a Comment