In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

トランプ

トランプ生成
  トランプゲームが作りたい。。。書き方がカス!
もともとのカードサイズは100x150。
createCard(番号,種類)でBitmap生成。
Get Adobe Flash player
by Dorara 10 Mar 2010
/**
 * Copyright Dorara ( http://wonderfl.net/user/Dorara )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gXH0
 */

//トランプ生成
//  トランプゲームが作りたい。。。書き方がカス!
//
//  もともとのカードサイズは100x150。
//  createCard(番号,種類)でBitmap生成。
package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;

	[SWF(width="465", height="465",backgroundColor=0x00000000,frameRate=60)]
	public class createCARD extends Sprite
	{
		private var mycard:myCARD;
		
		public function createCARD()
		{
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			this.stage.align = StageAlign.TOP_LEFT;
			
			
			mycard = new myCARD();
			for(var i:int = 0; i<4; i++){
				for(var j:int = 1; j<14; j++){
					//カードの生成createCard(番号(1-13), 種類(0:スペード,1:クローバー,2:ダイア,3:ハート))
					var card:Bitmap = mycard.createCard(j, i);
					//表示
					card.scaleX = 0.34;
					card.scaleY = 0.34;
					card.x = (j-1) * (100 * card.scaleX + 1);
					card.y = i * (150 * card.scaleY + 1);
					addChild(card);
				}
			}
			
			var normalsize:Bitmap = mycard.createCard(1,1);
			normalsize.x = 100;
			normalsize.y = 300;
			addChild(normalsize);
		}
	}
	
}


import flash.display.Sprite;
import flash.text.TextField;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.text.TextFormat;

class myCARD {
	private var cardtype:Array = ["♠", "♣", "♦", "♥"];
	private var cardnumb:Array = ["-","A","2","3","4","5","6","7","8","9","10","J","Q","K"];
	//中の記号の配置、15個の配置のうち配置するかしないかをビットで指定
	private var pn:Array = [0,0x4000,0x3000,0x4c00,0x2d0,0x42d0,0x3f0,0x23f0,0x2df,0x22df,0x32df];
	//中の記号の配置の場所(px,py)
	private var px:Array = [40,40,40,40,40,20,20,20,60,60,60,20,20,60,60];
	private var py:Array = [75,45,105,25,125,25,75,125,25,75,125,60,95,60,95];
	//カード生成
	public function createCard(number:int, type:int):Bitmap {
		var ret:Sprite = new Sprite();
		var retBitmap:Bitmap = new Bitmap();
		var retBitmapD:BitmapData = new BitmapData(100, 150, true, 0x000000);
		var tmpbmpD:BitmapData = new BitmapData(100, 150, true, 0x000000);
		var tmpbmp:Bitmap = new Bitmap();
		var tmpsp:Sprite = new Sprite();
		var textFormat:TextFormat = new TextFormat();
		textFormat.size = 23;
		if(type == 0 || type == 1){textFormat.color = 0x000000;}
		else {textFormat.color = 0xff0000;}
		
		//どっちも0の時は裏面を表示、ということにしておこう
		if(type == 0 && number == 0){
			tmpsp.graphics.beginFill(0xcccccc);
			tmpsp.graphics.drawRoundRect(0, 0, 100, 150, 20, 20);
			tmpsp.graphics.endFill();
			retBitmapD.draw(tmpsp);
			retBitmap.bitmapData = retBitmapD;
			return retBitmap;
		}
		
		
		
		//外枠
		tmpsp.graphics.beginFill(0xffffff);
		tmpsp.graphics.drawRoundRect(0, 0, 100, 150, 20, 20);
		tmpsp.graphics.endFill();
		tmpbmpD.draw(tmpsp);

		{//右下のナンバーと記号
			var ntext1:TextField = new TextField();
			ntext1.defaultTextFormat = textFormat;
			ntext1.text = cardnumb[number] + "\n" + cardtype[type];
			ntext1.x = 0;
			ntext1.y = 0;
			tmpbmpD.draw(ntext1);
			tmpbmp.bitmapData = tmpbmpD;
			tmpbmp.rotation = 180;
			tmpbmp.x = 100;
			tmpbmp.y = 150;
			ret.addChild(tmpbmp);
		}
		//カード内部
		if(1 <= number && number <= 10){
			var b:uint = pn[number];
			var comp:uint = 0x4000;
			var cmped:uint;
			for(var i:int = 0; i<15; i++){
				cmped = b & comp;
				if(cmped > 0){
					var kigou:TextField = new TextField();
					kigou.defaultTextFormat = textFormat;
					kigou.text = cardtype[type];
					kigou.x = px[i] - 3;
					kigou.y = py[i] - 10;
					ret.addChild(kigou);
				}
				comp = comp >> 1;
			}

		}
		else if(11 <= number && number <= 13){
			var gara:Sprite = new Sprite();
			gara.graphics.beginFill(0xcccccc);
			gara.graphics.drawRect(25,25,50,100);
			gara.graphics.endFill();
			ret.addChild(gara);
		}
		
		{//左上のナンバーと記号
			var ntext2:TextField = new TextField();
			ntext2.defaultTextFormat = textFormat;
			ntext2.text = cardnumb[number] + "\n" + cardtype[type];
			ntext2.x = 0;
			ntext2.y = 0;
			ret.addChild(ntext2);
		}

		retBitmapD.draw(ret);
		retBitmap.bitmapData = retBitmapD;
		return retBitmap;
	}
}