デバッグ(トレース)用 SWC(ライブラリ) : debug.swc |
|
↓同じディレクトリに置く場合
|
mxmlc 対象.mxml -library-path+=debug.swc
| |
|
↓別のディレクトリに置く場合( 例: C:\user\flex3\lib )
|
mxmlc 対象.mxml -library-path+=C:\user\flex3\lib\debug.swc
| |
|
ADL ( LiveDocs )
debug.swc.bat
|
compc -source-path .\ -output debug.swc -include-classes lightbox.debug
| |
|
debug.as
|
package lightbox
{
import flash.external.*;
import mx.formatters.*;
public class debug
{
// ***************************************************
// ログ表示
// ***************************************************
public static function firebug(data:Object):void {
// 日付編集用
var fmt:DateFormatter = new DateFormatter();
fmt.formatString = "YYYY/MM/DD HH:NN:SS";
var logdt:String = fmt.format( new Date );
try {
// JavaScript の呼び出し
ExternalInterface.call(
"console.log", logdt,
data+""
);
}
catch (error:Error) {
trace( logdt + " " + data );
}
}
// ***************************************************
// 開く( firefox 以外 )
// ***************************************************
public static function open():void {
try {
ExternalInterface.call(
"console.open"
);
}
catch (error:Error) {
trace( "AIR で ExternalInterface.call は使用できません" );
}
}
}
}
| |
|
|
|
|
mxmlc password.mxml -library-path+=C:\user\flex3\lib\debug.swc
| |
|
↓例( IHash.as )
|
/**
* IHash
*
* An interface for each hash function to implement
* Copyright (c) 2007 Henri Torgemane
*
* See LICENSE.txt for full license information.
*/
package
{
import flash.utils.ByteArray;
public interface IHash
{
function getInputSize():uint;
function getHashSize():uint;
function hash(src:ByteArray):ByteArray;
function toString():String;
}
}
| |
|
ByteArray
password.mxml
|
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData();"
paddingLeft="0"
paddingTop="1"
paddingBottom="0"
paddingRight="0"
backgroundColor="0xFFFFFF"
>
<mx:Script>
<![CDATA[
import lightbox.*;
import SHA256;
private var pass_data:String = "";
// *********************************************************
// アプリケーションの初期化
// *********************************************************
public function initData():void {
// メッセージ
debug.firebug("initData() が実行されました" );
debug.open();
}
// *********************************************************
// 処理
// *********************************************************
public function ActionStart():void {
// パスワード( そのまま )
debug.firebug( pass.text );
var base1:ByteArray = new ByteArray();
base1.writeUTFBytes( pass.text );
var sha:SHA256 = new SHA256();
var base2:ByteArray;
base2 = sha.hash(base1);
debug.firebug( toHex( base2 ) );
}
// *********************************************************
// ByteArray を 16進数文字列表現に変換
// *********************************************************
public function toHex( value:ByteArray ):String {
var len:int = value.length;
var i:int;
var ret:String = "";
var target:int;
var hex:String;
value.position = 0;
for( i = 0; i < len; i++ ) {
target = value.readUnsignedByte();
hex = Number(target).toString(16);
hex = ("00" + hex.toLowerCase()).substr(-2);
ret += hex;
}
return ret;
}
]]>
</mx:Script>
<mx:HBox>
<mx:TextInput
id="pass"
displayAsPassword="true"
/>
<mx:Button
label="送信"
click="ActionStart();"
/>
</mx:HBox>
</mx:Application>
| |
|
|
|
build.wsf
|
<JOB>
<RESOURCE id="commandList">
<![CDATA[
mode con: cols=120
set PATH=C:\flex3\bin;%PATH%
prompt flex3$G
fcsh
]]>
</RESOURCE>
<OBJECT id="WshShell" progid="WScript.Shell" />
<OBJECT id="Fso" progid="Scripting.FileSystemObject" />
<SCRIPT language=VBScript>
' ***********************************************************
' 処理開始
' ***********************************************************
strPath = WScript.ScriptFullName
Set obj = Fso.GetFile( strPath )
Set obj = obj.ParentFolder
WshShell.CurrentDirectory = obj.Path
aData = Split( GetInline( "commandList" ), vbCrLf )
strCommand = "cmd.exe /k " & aData(0)
For I = 1 to Ubound( aData )
strCommand = strCommand & "&" & aData(I)
Next
Call WshShell.Run( strCommand, 3 )
' ***********************************************************
' 関数
' ***********************************************************
Function GetInline( strName )
GetInline = RegTrim( getResource( strName ) ) & vbCrLf
End Function
Function RegTrim( strValue )
Dim regEx, str
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Pattern = "^[ \s]+"
str = regEx.Replace( strValue, "" )
regEx.Pattern = "[ \s]+$"
RegTrim = regEx.Replace( str, "" )
End Function
</SCRIPT>
</JOB>
| |
|
|
|
firebug について SWFObject について
この HTML は、SHIFT_JIS です
|
<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<TITLE>デバッグ用</TITLE>
<STYLE type="text/css">
* {
font-family: "MS Pゴシック";
font-size: 12px;
}
BODY {
background-color: white;
color: black;
}
</STYLE>
<SCRIPT
language="javascript"
type="text/javascript"
src="http://homepage2.nifty.com/lightbox/firebug/firebug.js">
</SCRIPT>
<SCRIPT
language="javascript"
type="text/javascript"
src="http://homepage2.nifty.com/lightbox/swfobject.js">
</SCRIPT>
</HEAD>
<!-- *******************************************************
BODY
******************************************************** -->
<BODY>
<TABLE><TR><TD>
パスワード入力 :
</TD><TD>
<DIV id="flashcontent" style='display:inline'></DIV>
</TD></TR></TABLE>
<script type="text/javascript">
var so = new SWFObject(
"password.swf?reload=" + (new Date()).getTime(),
"idswf", "250", "25", "9", "#FFFFFF");
so.write("flashcontent");
</script>
</BODY>
</HTML>
| |
|
|
|