ActionScript 3.0算术运算符

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3.0算术运算符相关的知识,希望对你有一定的参考价值。

This snippet is used for the blog post called Arithmetic Operators in Flash and ActionScript 3.0, which can be found at http://www.brettwidmann.com/2010/10/arithmetic-operators-in-flashactionscript-3-0 which is set to publish on November 1, 2010.
  1. /* Each trace function demonstrates the type
  2.   of Arithmetic operators in Flash.
  3.   Commented out trace() functions demonstrate
  4.   an easier to read example while the verbose
  5.   versions represent cleaner formatting in
  6.   the console.*/
  7.  
  8. //Addition
  9. trace("The sum of 15 + 6 is: " + (15 + 6));
  10. //trace(15 + 6);
  11. trace(" ");
  12.  
  13. //Subtraction
  14. trace("The difference of 15 and 6 is: " + (15 - 6) );
  15. //trace(15 - 6);
  16. trace(" ");
  17.  
  18. //Multiplication
  19. trace("The product of 15 and 6 is: " + (15 * 6));
  20. //trace(15 * 6);
  21. trace(" ");
  22.  
  23. //Division
  24. trace("The quotient of 15 and 6 is: " + (15 / 6));
  25. //trace(15 / 6);
  26. trace(" ");
  27.  
  28. //Modulo
  29. trace("The modulus (remainder) of 15 and 6 is: " + (15 % 6));
  30. //trace(15 % 6);
  31. trace(" ");
  32.  
  33. //Order of Operations Example 1
  34. trace("Parentheticals take precedence in Arithmetic!");
  35. trace("(4 * 2) + 6 = " + ((4 * 2) + 6));
  36. //trace((4 * 2) + 6);
  37. trace(" ");
  38.  
  39. //Order of Operations Example 2
  40. trace("(10 + 6) * 3 = " + ((10 + 6) * 3));
  41. trace(" ");
  42.  
  43. //String Concatenation Example
  44. var concatSentence:String = "This is an example of " + "string concatenation.";
  45. trace(concatSentence);

以上是关于ActionScript 3.0算术运算符的主要内容,如果未能解决你的问题,请参考以下文章

获取 badarith,[erlang,'+',[error,0],[],同时使用 Erlang 片段在 TSUNG 中执行算术运算

[ActionScript 3.0] as3处理xml的功能和遍历节点

动作脚本 3.0;循环音频文件

Actionscript 3.0 - 缓动拖拽

(ActionScript 3.0)我的函数没有通过按钮事件更新全局变量

算术运算符与算术表达式