[Flash] Type Checking

  • Type Checking
  • 在ActionScript 3.0 裡如果要做型態檢驗,可以透過 isas 這兩個operator來達成,下面是一個簡單的範例:

    import com.xinyu.geom.Ball;
    import com.xinyu.geom.Triangle;

    var ball:Ball = new Ball();
    addChild(ball);

    trace(ball is Ball);
    trace(ball is Triangle);
    trace(ball is Sprite);
    trace(ball as Ball);
    trace(ball as Triangle);
    trace(ball as Sprite);

    輸出畫面如下:

    true
    false
    true
    [object Ball]
    null
    [object Ball]

No comments:

Post a Comment

Orange - data analysis tool

Installation pip install orange3 Run orange python -m Orange.canvas