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

ifを使わないで表示内容をかえる

元ネタ http://togetter.com/li/140355
AS3でもやってみました。
Get Adobe Flash player
by shohei909 27 May 2011
    Embed
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pN8b
 */

package {
    import com.actionscriptbible.Example;
    public class FlashTest extends Example{
        private var n:Namespace
        namespace t = "true";
        t var a:String = "正解"
        namespace f = "false";
        f var a:String = "不正解"
        
        public function FlashTest() {
            var a:Boolean;
            a = true;
            trace( ["不正解","正解"][int(a)] );
            a = false;
            trace( ["不正解","正解"][int(a)] );
            trace( "------------" );
            
            a = true;
            trace( "不正解".substr( int(a),3 ) );
            a = false;
            trace( "不正解".substr( int(a),3 ) );
            trace( "------------" );
            
            a = true;
            trace( { "false":"不正解", "true":"正解" }[ a ] );
            a = false;
            trace( { "false":"不正解", "true":"正解" }[ a ] );
            trace( "------------" );
            
            a = true;
            trace( <>不</>.(!a) + "正解" );
            a = false;
            trace( <>不</>.(!a) + "正解" );
            trace( "------------" );
            
            a = true;
            trace( (n = new Namespace( a ))::a );
            a = false;
            trace( (n = new Namespace( a ))::a );
            trace( "------------" );
        }
    }
}