`
lydawen
  • 浏览: 465429 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

actionscript Number保留两位小数

    博客分类:
  • flex
阅读更多

试了几种方法:

1、

private var a:Number=3.1234;

a=a.toFixed(2) as Number;

trace(a);

 

 

输出:0

 

原因,a.toFixed(2)  倒是能保留两小数,但它得到String型,强制转型会变成0

 

2、

private var a:Number=3.1234;

a=Number(a.toFixed(2));

trace(a);

 

 

输出:3.12

 

第二种方法是可以行得通的.

分享到:
评论
2 楼 lydawen 2009-12-28  
luojunhope 写道
看这种方法有没有用
http://www.9flex.com/index.php/archives/17/


我不太明白为什么本来很简单的东西要写这么多代码来实现?官方有实现的
1 楼 luojunhope 2009-12-26  
看这种方法有没有用
http://www.9flex.com/index.php/archives/17/

相关推荐

    ActionScript开发技术大全

    3.2.4Number类型 30 3.2.5Boolean类型 32 3.2.6String类型 33 3.2.7Null类型 34 3.2.8void类型和*类型 34 3.3动态数据类型检查 35 3.4变量的类型转换 37 3.5ActionScript3.0语法 38 3.5.1大小写敏感 38 3.5.2字面量 ...

    ActionScript

    第1章 揭开ActionScript的神秘面纱 第2章 Flash MX的动作面板 第3章 ActionScript编程初步 第4章 影片播放控制 第5章 控制影片剪辑 第6章 影片剪辑属性 第7章 影片剪辑方法 第8章 响应键盘 9章 输入文本和字符串...

    actionscript3

    本书是国内第一本“面向原因式”(Why-Oriented Book)、全面系统介绍Flash ActionScript 3的书籍。全书共分为5个部分。第一部分:ActionScript 3语言基础;第二部分:ActionScript 3 面向对象编程;第三部分:...

    ActionScript基础 ActionScript基础

    ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础ActionScript基础

    ActionScript3代码规范

    ActionScript3代码规范 ActionScript3代码规范 ActionScript3代码规范

    ActionScript3.0 中文版

    ActionScript3.0 中文版 ActionScript3.0 api 中文版说明文档

    ActionScript 3 For Adobe Flash CS4 Professional

    broken down into a number of sections: Introduction: Provides a high-level introduction to ActionScript 3 Top misperceptions: Dispels some of the top misperceptions around ActionScript 3 Top benefits:...

    ActionScript Number(NaN) —> java(null) NaN —> null

    NULL 博文链接:https://lj-zhu.iteye.com/blog/702149

    ActionScript语句中文全解

    ActionScript语句中文全解

    ActionScript权威指南.pdf

    ActionScript权威指南 ActionScript权威指南

    spring actionscript 入门例子

    spring actionscript 入门例子

    actionscript

    ActionScript3[1].0完全自学手册电子教案.

    ActionScript 3.0 API文档(CHM+HTML最新中文完整)

    《ActionScript 3.0 语言和组件参考》概述 《ActionScript 3.0 语言参考》是 Flash® Player 和 Adobe AIR™ 应用程序编程接口 (API) 的参考手册。 此版本包括支持 Adobe AIR 运行时环境的新 ActionScript 类、...

    Adobe Flash 中的 ActionScript 2

    Adobe Flash 中的 ActionScript 2

    actionscript3.0开发的进度显示条项目

    actionscript3.0开发的进度显示条项目

    最专业的ActionScript 3.0

    最专业的最专业的最专业的ActionScript 3.0 ActionScript 3.0 ActionScript 3.0 ActionScript 3.0 ActionScript 3.0

    ActionScript 3.0开发技术大全(第一部分)

    第1篇 ActionScript3.0语言基础  第1章 ActionScript3.0概述  第2章 搭建ActionScript3.0开发环境  第3章 ActionScript3.0语法 第2篇 ActionScript3.0面向对象特性  第4章 ActionScript3.0面向对象编程  第...

    actionscript 3 as3 pdf

    ActionScript 3.0 是一种强大的面向对象编程语言,它标志着 Flash Player Runtime 演化过程中的一个重要阶段。设计 ActionScript 3.0 的意图是创建一种适合快速地构建效果丰富的互联网应用程序的语言,这种应用程序...

Global site tag (gtag.js) - Google Analytics