`
燮羽天翔
  • 浏览: 110358 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flex with 关键字用法

    博客分类:
  • Flex
阅读更多

以下示例首先设置 someOther_mc 实例的 _x_y 属性,然后指示 someOther_mc 转到第 3 帧并停止。

 

同时访问一个作用域链列表中的多个项时,with 语句会很有用。在以下示例中,内置 Math 对象位于作用域链之前。将 Math 设置为默认对象可将标识符 cossinPI 分别解析为 Math.cosMath.sinMath.PI 。标识符 axyr polar() 的对象激活范围中,所以将解析为相应的局部变量。 不是 Math 对象的方法或属性,但由于它们位于函数

function polar(r:Number):void { 
    var a:Number, x:Number, y:Number; 
    
with

 (Math) { 
        a = PI * pow(r, 2); 
        x = r * cos(PI); 
        y = r * sin(PI / 2); 
    } 
    trace("area = " + a); 
    trace("x = " + x); 
    trace("y = " + y); 
} polar(3);
/* 
area = 28.2743338823081 
x = -3 
y = 3
*/
转载:http://xiejiangbo.iteye.com/blog/459350
with

 (someOther_mc) { 
    _x = 50; 
    _y = 100; 
    gotoAndStop(3); 
}

以下代码段显示在不使用 with 语句的情况下如何编写先前的代码。

someOther_mc._x = 50; 
someOther_mc._y = 100; 
someOther_mc.gotoAndStop(3);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics