sink100のFlashな日々
「 メッセージボックスクラスを作ってみた 」
ADMIN
|
WRITE
カレンダー
03
2024/04
05
S
M
T
W
T
F
S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
リンク
HOBBY ROOM
管理画面
新しい記事を書く
E-store
カテゴリー
未選択 ( 1 )
更新履歴 ( 0 )
Flash ( 1 )
ナンバープレース ( 3 )
独り言 ( 1 )
flash備忘録 ( 1 )
as3備忘録 ( 4 )
javascript備忘録 ( 2 )
フリーエリア
最新コメント
最新記事
test
(06/26)
IcellRendererでコンポーネント内にボタンを表示するクラス
(12/01)
メッセージボックスクラスを作ってみた
(10/16)
Cookieの読み込み
(10/08)
Cookieの保存
(10/08)
最新トラックバック
プロフィール
HN:
sink100
HP:
HOBBY ROOM
性別:
男性
趣味:
映画鑑賞
自己紹介:
仕事やら趣味やら色々と
忙しい毎日を送っています。
RSS
RSS 0.91
RSS 1.0
RSS 2.0
ブログ内検索
アーカイブ
2010 年 06 月 ( 1 )
2007 年 12 月 ( 1 )
2007 年 10 月 ( 5 )
2007 年 03 月 ( 1 )
2007 年 02 月 ( 2 )
最古記事
ブログ開始!
(01/14)
Almost Locked Sets
(01/17)
だいぶ解読できた。
(01/19)
なかなか進まない・・・
(02/08)
ナンプレ新パターン
(02/28)
カウンター
OTHERS
Powered by
忍者ブログ
Templated by
TABLE ENOCH
△ PAGE TOP
[PR]
2024/04/30 (Tue)
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
メッセージボックスクラスを作ってみた
2007/10/16 (Tue)
as3備忘録
Trackback()
Comment(0)
package{ import fl.controls.Button; import flash.display.Sprite; import flash.text.TextField; import flash.events.MouseEvent; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; public class msgbox extends Sprite{ var bgc:uint=0xffffff; var bgAlpha:Number=0.5 var mainc:uint=0xcccccc; var mainAlpha:Number=0.5; var mainLineColor:uint=0x666666; var mainLineWeight:uint=2; var mainLineAlpha:Number=1; public var select:Boolean; var label:TextField=new TextField(); ; var rootDy:Object; var ok:Button=new Button(); var yes:Button=new Button(); var no:Button=new Button(); var format:TextFormat = new TextFormat(); function msgbox(dy:Object):void{ rootDy=dy; format.font ="_ゴシック" ; format.color =0x000000; format.size = 15; label.defaultTextFormat = format; yes.label='Yes'; yes.width=50; no.label='No'; no.width=50; ok.label='OK'; ok.width=50; addChild(ok); addChild(label); addChild(no); addChild(yes); ok.visible=false; yes.visible=false; no.visible=false; } public function bgColor(color:uint,Alpha:Number):void{ bgc=color; bgAlpha=Alpha; } public function textFont(size:uint,color:uint,...rest):void{ format.size=size; format.color=color; if(rest.length==1){ format.font=rest[0]; } label.defaultTextFormat = format; } public function mainColor(nuriColor:uint,nuriAlpha:Number,...rest){ mainc=nuriColor; mainAlpha=nuriAlpha; switch(rest.length){ case 3: mainLineAlpha=rest[2]; case 2: mainLineColor=rest[1]; case 1: mainLineWeight=rest[0]; } } public function Message1(moji:String,...rest):void{ ok.visible=true; with(label){ width=170; wordWrap=true; autoSize=TextFieldAutoSize.CENTER; text=moji; if(numLines==1){ wordWrap=false; } x=(rootDy.stage.stageWidth-label.width)/2; y=(rootDy.stage.stageHeight-label.height-50)/2; } with(graphics){ clear(); beginFill(bgc,bgAlpha); drawRect(0,0,rootDy.stage.stageWidth,rootDy.stage.stageHeight); beginFill(mainc,mainAlpha); lineStyle(mainLineWeight,mainLineColor,mainLineAlpha); } roundSquareLine((rootDy.stage.stageWidth-200-mainLineWeight)/2,(rootDy.stage.stageHeight-label.height-70-mainLineWeight)/2, 200+mainLineWeight,label.height+70+mainLineWeight,10); ok.x=(rootDy.stage.stageWidth-50)/2; ok.y=(rootDy.stage.stageHeight+label.height-20)/2; ok.addEventListener(MouseEvent.CLICK,okClick); var thisObj:Object=rootDy.addChild(this); function okClick(event:MouseEvent):void{ if(rest.length==1){ rest[0].call(); } ok.visible=false; rootDy.removeChild(thisObj); ok.removeEventListener(MouseEvent.CLICK,okClick); } } public function Message2(moji:String,func:Function):void{ yes.visible=true; no.visible=true; with(label){ width=170; wordWrap=true; autoSize=TextFieldAutoSize.CENTER; text=moji; if(numLines==1){ wordWrap=false; } x=(rootDy.stage.stageWidth-label.width)/2; y=(rootDy.stage.stageHeight-label.height-50)/2; } with(graphics){ clear(); beginFill(bgc,bgAlpha); drawRect(0,0,rootDy.stage.stageWidth,rootDy.stage.stageHeight); beginFill(mainc,mainAlpha); lineStyle(mainLineWeight,mainLineColor,mainLineAlpha); } roundSquareLine((rootDy.stage.stageWidth-200-mainLineWeight)/2,(rootDy.stage.stageHeight-label.height-70-mainLineWeight)/2, 200+mainLineWeight,label.height+70+mainLineWeight,10); yes.x=(rootDy.stage.stageWidth-200)/2+30; no.x=(rootDy.stage.stageWidth-200)/2+120; yes.y=no.y=(rootDy.stage.stageHeight+label.height-20)/2; yes.addEventListener(MouseEvent.CLICK,yesClick); no.addEventListener(MouseEvent.CLICK,noClick); var thisObj:Object=rootDy.addChild(this); function yesClick(event:MouseEvent):void{ yes.visible=false; no.visible=false; select=true; func.call(); rootDy.removeChild(thisObj); yes.removeEventListener(MouseEvent.CLICK,yesClick); no.removeEventListener(MouseEvent.CLICK,noClick); } function noClick(event:MouseEvent):void{ yes.visible=false; no.visible=false; select=false; func.call(); rootDy.removeChild(thisObj); yes.removeEventListener(MouseEvent.CLICK,yesClick); no.removeEventListener(MouseEvent.CLICK,noClick); } } function roundSquareLine(px:uint,py:uint,haba:uint,takasa:uint,hankei:uint):void{ graphics.moveTo(px+hankei,py); graphics.lineTo(px+haba-hankei,py); graphics.curveTo(px+haba,py,px+haba,py+hankei); graphics.lineTo(px+haba,py+takasa-hankei); graphics.curveTo(px+haba,py+takasa,px+haba-hankei,py+takasa); graphics.lineTo(px+hankei,py+takasa); graphics.curveTo(px,py+takasa,px,py+takasa-hankei); graphics.lineTo(px,py+hankei); graphics.curveTo(px,py,px+hankei,py); } } }
新しくメッセージボックスオブジェクトを作る
msgbox(表示リストに追加する所);
外側の背景色を変える
bgcolor(色,アルファ);
中央の背景色を変える
mainColor(色,アルファ,[線の太さ,線の色,線のアルファ]);
フォントなどを変える
textFont(大きさ,色,[フォント]);
OKだけのメッセージボックス
Message(メッセージ,関数名);
2択のメッセージボックス
Message(メッセージ,関数名); ※yesの場合selectがtrue、noの場合selectがfalse
PR
COMMENTS
TITLE
NAME
MAIL
HOME
PASS
COMMENT
SECRET ?
TRACKBACKS
PREV |
15
14
13
12
11
10
9
6
| NEXT
- HOME -
[PR]