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

Progression 4 - LoadURL のリトライ

/**
 * Copyright nium ( http://wonderfl.net/user/nium )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bI7M
 */

// forked from nium's Progression 4 BasicAppConfig
package {
	import flash.display.*;
	import jp.progression.config.*;
	import jp.progression.debug.*;
	import jp.progression.*;
	
    public class FlashTest extends Sprite {
        
        public var manager:Progression;
        
        public function FlashTest() {
			Progression.initialize( new BasicAppConfig() );
            manager = new Progression( "index", stage, IndexScene );
            
            //Debugger.addTarget( manager );
                        
            manager.goto( manager.root.sceneId );
        }
    }
}

import flash.net.URLRequest;
import flash.system.Security;
import jp.progression.casts.*;
import jp.progression.commands.display.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.net.*;
import jp.progression.commands.tweens.*;
import jp.progression.commands.*;
import jp.progression.data.*;
import jp.progression.events.*;
import jp.progression.scenes.*;

class IndexScene extends SceneObject {
	
	public function IndexScene() {
	}
	
	protected override function atSceneLoad():void {
		var count:int = 0;
		
		Security.loadPolicyFile("http://5ivestar.org/proxy/crossdomain.xml");
		
		addCommand(
		    // この読み込みは失敗する
			new LoadURL( new URLRequest( "unexist.xml" ), {
				catchError:function():void {
					trace( "retry", count );
					
					// 5 回までリトライする
					if ( count < 5 ) {
						count++;
						
						// initObject にコマンドインスタンスを設定すると各種設定をコピーできる
						this.parent.insertCommand( new LoadURL( new URLRequest( "http://5ivestar.org/proxy/http://d.hatena.ne.jp/hotkeyword?mode=rss" ), this ) );
						this.executeComplete();
					}
				}
			} ),
			function():void {
				trace( "読み込み成功" );
			}
		);
	}
}