var INI_PATH = "c:\\windows\\FlashView.ini"
var INI_SECKEY = "List"
var INI_VARNAME = "list"
var arr_IniPath :Array = new Array();
var int_CurrImgPos :int = 0;
var int_ImgCount :int = 0;
var timer :Timer;
var loader :Loader = new Loader();
var urlReq :URLRequest = new URLRequest( INI_PATH );
var urlLoad :URLLoader = new URLLoader( urlReq );
urlLoad.addEventListener( Event.COMPLETE, iniLoaded );
this.stage_attach.addChild( loader );
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////// function Define Section /////////////////////////////
function iniLoaded( evt :Event ) :void
{
var strTemp :String;
var delay :int;
strTemp = ParsingString( evt.target.data, INI_SECKEY );
delay = parseInt( GetIniValueString( strTemp, "delay" ) );
int_ImgCount = parseInt( GetIniValueString( strTemp, "count" ) );
for( var i :int = 1; i <= int_ImgCount; i++ ) {
arr_IniPath.push( GetIniValueString( strTemp, INI_VARNAME + i ) );
// trace( "" + (INI_VARNAME + i) + " : " + GetIniValueString( strTemp, INI_VARNAME + i ) );
}
timer = new Timer( delay * 1000 );
timer.addEventListener( TimerEvent.TIMER, onTick );
timer.start();
}
function onTick( evt :TimerEvent ) :void
{
loader.unload();
loader.load( new URLRequest( arr_IniPath[int_CurrImgPos++] ) );
// trace( arr_IniPath[int_CurrImgPos] );
if( int_CurrImgPos == int_ImgCount )
int_CurrImgPos = 0;
}
function GetIniValueString( argStr_Source :String, argStr_Var :String ) :String
{
var sp :Number = -1;
var rp :Number = -1;
sp = argStr_Source.indexOf( argStr_Var ) + argStr_Var.length + 1;
rp = argStr_Source.indexOf( "\n", sp ) - 1;
if( sp == -1 || rp == -1 )
return null;
else
return argStr_Source.substring( sp, rp );
}
function ParsingString( argStr_Source :String, argStr_SpStr :String, argStr_RpStr :String = "[" ) :String
{
var sp :Number = -1;
var rp :Number = -1;
sp = argStr_Source.indexOf( argStr_SpStr + "=" ) + argStr_SpStr.length;
rp = argStr_Source.indexOf( argStr_RpStr, sp );
if ( rp == -1 ) rp = argStr_Source.length;
if( sp == -1 || rp == -1 )
return null;
else
return argStr_Source.substring( sp, rp );
}
'Programming > ActionScript' 카테고리의 다른 글
[AS 3.0] 강좌 (0) | 2012.04.13 |
---|---|
한글깨짐 방지코드 (0) | 2012.03.13 |
[AS 3.0] 1172: Definition flash.filesystem:File Could not be found. (0) | 2011.10.11 |
[AS 3.0] Reading Text From INI File (0) | 2011.10.11 |
[AS 3.0] LocallConnection Class를 사용하여 SWF간 이벤트 주고받기 (0) | 2011.09.05 |