<colgroup>
<col width="40%">
<col width="25%"> <col width="35%"> </colgroup>



<tr style="visibility:collapse;">
<th style="width:50px;"></th>
<th style="width:130px;"></th>
<th style="width:130px;"></th>
<th style="width:50px;"></th>
<th style="width:80px;"></th>
<th style="width:100px;"></th>
<th style="width:80px;"></th>
</tr>
10px 77%
12px 92.4%
14px 107.8%
16px 123.1%
18px 138.5%


Font10px の行の高さ(line-height)
12px 1.2
14px 1.401
16px 1.6
18px 1.801

Font12px の行の高さ(line-height)
14px 1.167
16px 1.335
18px 1.5
20px 1.666

Font14px の行の高さ(line-height)
16px 1.143
18px 1.286
20px 1.429


Font16px の行の高さ(line-height)
18px 1.124
20px 1.244
22px 1.374



Beginner-Flasherの覚書き-HDR D51_2 Beginner-Flasherの覚書き-HDR D51

HDRなるものを試してみる。

なかなか楽しい。
  1. package 
  2. {
  3. import flash.display.DisplayObjectContainer;
  4. import flash.text.TextField;
  5. import flash.events.Event;
  6.  
  7. public class RandomText
  8. {
  9. private var sourceTxt:String = "_/-=+%&$#!?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
  10. private var content:DisplayObjectContainer;
  11. private var targetFld:TextField;
  12. private var targetText:String;
  13. private var sliceCnt:int;
  14. private var playTime:uint;
  15.  
  16. public function RandomText(content:DisplayObjectContainer, targetFld:TextField, time:uint)
  17. {
  18. this.content = content;
  19. this.targetFld = targetFld;
  20. playTime = time;
  21. targetText = targetFld.text;
  22. }
  23.  
  24. public function start():void 
  25. {
  26. targetFld.text = "";
  27. sliceCnt = 0;
  28. content.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  29. }
  30.  
  31. private function onEnterFrame(e:Event):void 
  32. {
  33. ++sliceCnt;
  34. var randomTxt:String = "";
  35.  
  36. for (var i = 0; i < targetText.length; ++i)
  37. {
  38. if (sliceCnt - playTime < i)
  39. {
  40. randomTxt = randomTxt+sourceTxt.charAt(Math.floor(Math.random()*sourceTxt.length));
  41. continue;
  42. }
  43. randomTxt = randomTxt+targetText.charAt(i);
  44. }
  45.  
  46. targetFld.text = randomTxt;
  47. if (randomTxt == targetText)
  48. {
  49. content.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
  50. }
  51. }
  52.  
  53. }
  54.  
  55. }


使用時は下記
  1. package 
  2. {
  3. import flash.display.MovieClip;
  4. import flash.events.MouseEvent;
  5. import flash.text.TextField;
  6.  
  7. public class Main extends MovieClip
  8. {
  9. private var randomText:RandomText;
  10.  
  11. public function Main()
  12. {
  13. randomText = new RandomText(this, test_txt, 10);
  14. randomText.start();
  15. test_txt.addEventListener(MouseEvent.ROLL_OVER, onRollover);
  16. }
  17.  
  18. private function onRollover(e:MouseEvent):void 
  19. {
  20. randomText.start();
  21. }
  22. }
  23.  
  24. }

var loader_obj : Loader = new Loader();

// ローダーインフォを取得
var info : LoaderInfo = loader_obj.contentLoaderInfo;

info.addEventListener (Event.OPEN,LoaderInfoOpenFunc);
function LoaderInfoOpenFunc (event : Event) {
trace ("読み込みを開始した");
}

info.addEventListener (ProgressEvent.PROGRESS,LoaderInfoProgressFunc);
function LoaderInfoProgressFunc (event : ProgressEvent) {
trace ("読込:" + event.bytesLoaded);
trace ("全体:" + event.bytesTotal);
trace ("パーセント:" + Math.floor(event.bytesLoaded/event.bytesTotal*100));
}

info.addEventListener (Event.INIT,LoaderInfoInitFunc);
function LoaderInfoInitFunc (event : Event) {
trace ("読み込んだコンテンツの初期化が行われプロパティにアクセス可能");
}

info.addEventListener (Event.COMPLETE,LoaderInfoCompleteFunc);
function LoaderInfoCompleteFunc (event : Event) {
trace ("読み込みを完了");
}

info.addEventListener (IOErrorEvent.IO_ERROR,LoaderInfoIOErrorFunc);
function LoaderInfoIOErrorFunc (event : IOErrorEvent) {
trace ("ファイル入出力のエラー");
}

// 読み込み開始
var url : URLRequest = new URLRequest("test.swf");
loader_obj.load(url);
var info : LoaderInfo = root.loaderInfo;

stage.addEventListener(Event.ENTER_FRAME,EnterFrameFunc);
function EnterFrameFunc(event){
trace("読込数 : " + info.bytesLoaded);
trace("総数 : " + info.bytesTotal);
trace("パーセント : " + Math.floor(info.bytesLoaded / info.bytesTotal * 100));

if(info.bytesLoaded == info.bytesTotal){
trace("ロード完了");
stage.removeEventListener(Event.ENTER_FRAME,EnterFrameFunc);
}
}
1.ドキュメントクラスでBgクラスをインスタンス化
2.Bgクラスでjpeg画像読み込み
3.画像読み込み中は進捗をテキストで0~100%表示

Bg.as



package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;
public class Bg extends Sprite{
// プロパティ
private var _loading:Loading = new Loading();
private var _imgUrl:String = "img/bg.jpg";
private var _imgUrlReq:URLRequest = new URLRequest(_imgUrl);
private var _imgLdr:Loader = new Loader();
// コンストラクタ
public function Bg():void {
// ローディングセット
addChild(_loading);
// 画像読込
_imgLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressHandler);
_imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
_imgLdr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
_imgLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
_imgLdr.load(_imgUrlReq);
}
// 画像読込中
private function progressHandler(evt:Event):void{
var _rate:String=Math.floor((evt.bytesLoaded*100)/evt.bytesTotal) + "%";
_loading.loadingText(_rate);
}
// 画像読込完了
private function completeHandler(evt:Event):void{
var _loadFile:Bitmap = evt.target.content;
_loading.loadingText("complete!");
removeChild(_loading);// ローディング削除
addChild(_loadFile);// 画像セット
removeEvent();
}
// セキュリティエラー
private function securityErrorHandler(evt:Event):void{
_loading.loadingText("security error");
removeEvent();
}
// IOエラー
private function ioErrorHandler(evt:Event):void{
_loading.loadingText("io error");
removeEvent();
}
// イベントリスナー解放
private function removeEvent():void{
_imgLdr.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progressHandler);
_imgLdr.contentLoaderInfo.removeEventListener(Event.COMPLETE,completeHandler);
_imgLdr.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
_imgLdr.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
}
}
}


Loading.as

package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class Loading extends Sprite{
// プロパティ
private var _testF:TextField = new TextField();
// コンストラクタ
public function Loading():void {
this.addChild(_testF);
_testF.autoSize = TextFieldAutoSize.LEFT;
_testF.textColor = "0xFF3300";
_testF.text = "読込開始";
}
// パーセント表示
public function loadingText(_loadingText:String):void{
_testF.text = _loadingText;
}
}
}


var timer:Timer = new Timer(ミリ秒);

//間隔ごとに発生するイベントをキャッチするリスナーを登録
timer.addEventListener(TimerEvent.TIMER, xGo);

//リスナーで呼び出される関数
function xGo(event:TimerEvent):void{
//関数
}

//タイマーの開始
timer.start();