1.actionscript 3.0çTamarin
actionscript 3.0çTamarin
Tamarin 项ç®çç®æ æ¯å®ç°ä¸ä¸ªé«æ§è½çå¼æ¾æºç ç ECMAScript 第åçï¼ES4ï¼è¯è¨è§èå®ç°ãMozilla å¨SpiderMonkeyä¸ä½¿ç¨ Tamarin Virtual Machineï¼SpiderMonkey æ¯ Firefox åå ¶ä»åºäº Mozilla ç产åä¸åµå ¥çæ ¸å¿ JavaScript å¼æãAdobe å°ç»§ç»å¨ Adobe Flash Player ä¸ç ActionScript Virtual Machine ä¸ä½¿ç¨è¿äºä»£ç ãTamarin Virtual Machine å½åå®ç° ECMAScript 第ä¸çè¯è¨æ åï¼è¿æ¯ JavaScriptãAdobe ActionScript å Microsoft Jscript éç¨çæ åï¼ï¼è¿æ¯æ ES4 ä¸å»ºè®®çä¸äºæ°è¯è¨ç¹æ§ã社åºæ£å¨å¼å ES4 çå¼æ¾æºç å®ç°ï¼Adobe å Mozilla å¸æ以æ¤ä¿è¿è¿ç§å建 Web åºç¨ç¨åºçæ ååè¯è¨çæ¨å¹¿ãTamarin 项ç®çç®æ æ¯å¸®å©å¼å人åå建å¯ä»¥è·¨å¤ä¸ªå¹³å°çææ丰å¯çé«åº¦äº¤äºæ§çç¨æ·ä½éªã Tamarin å°æ¯æ ECMAScript 第åçï¼æè 说 âJavaScript 2âï¼è¯è¨ï¼å¹¶å°éæè¿ Mozilla 2 项ç®ä¸çSpiderMonkeyï¼é¢æå¨ å¹´åå¸ã
Mozilla çå¼æ¾æºç 项ç®å¢éååå¼å§å¼å Tamarinï¼å®çä¸äºç®æ ææ¯å æ¬ï¼
å° Tamarin VM ååå¾æ¶éå¨éæè¿SpiderMonkeyä¸
ä½¿ç¨ SpiderMonkeyç¼è¯å¨çæ Tamarin ç代ç
å°å³æ¶ç¼è¯å¨ç§»æ¤å°æ°ç硬件平å°
å®æ ECMAScript 4ç¼è¯å¨
ä½¿ç¨ ActionScript 3 çç®å示ä¾
è¿ä¸ª ActionScript 示ä¾æ¾ç¤ºæ¬¢è¿æ¶æ¯ âHello <Username>âãç¨æ·å¯ä»¥å¨ææ¬æ¡ä¸è¾å ¥ç¨æ·åãæå车æ¶ï¼å°±ä¼æ¾ç¤ºæ¬¢è¿æ¶æ¯ã
æ¸ å 1. 示ä¾ä»£ç
package {
public class Greeter {
/
*** Defines the names that should receive a proper greeting.
*/
public static var validNames:Array = [Sammy,游戏源码游戏源码随机提问源码 Frank, Dean];
/
*** Builds a greeting string using the given name
*/
public static function sayHello (userName:String = ):String {
var greeting:String = Hello World;
if (userName == ){
greeting = Hello, please type your name and then press the enter key;
}
else if(validName(userName)){
greeting = Hello, + userName + .;
}
else {
greeting = Sorry, + userName + Your name is not present in the list.;
}
return greeting;
}
/
*** Check whether a name is in the validNames list
*/
public static function validName(inputName:String = ):Boolean {
if validNames.indexOf(inputName) > -1 {
return true;
}
else {
return false;
}
}
}
}
å¾ 1 æ¾ç¤ºæ¸ å 1 çåå§çªå£ãå®æ¾ç¤ºæåç欢è¿æ¶æ¯ âHello, please type your name and then press the enter keyâï¼ç¶åçå¾ ç¨æ·å¨æ ç¾ä¸º User Name çææ¬æ¡ä¸è¾å ¥ç¨æ·åã
å¾ 1. ActionScript 3 ä¸ç欢è¿ç¤ºä¾
å½ç¨æ·å¨ User Name æ¡ä¸è¾å ¥ âFrankâ æ¶ï¼èæ¬ä¼å¨é¢å®ä¹ç validNamesæ°ç»ä¸å¯»æ¾è¿ä¸ªç¨æ·åãå 为 âFrankâ å¨ validNamesæ°ç»ä¸ï¼æ以å¨æ¬¢è¿åºåä¸ä¼æ¾ç¤º âHello Frankâï¼è§å¾ 2ã
å¾ 2. ç¨æ·è¾å ¥ç¨æ·å
å¦æç¨æ·è¾å ¥çç¨æ·åä¸å¨ validNamesæ°ç»ä¸ï¼ä¾å¦ âAnithaâï¼é£ä¹æ¾ç¤ºæ¶æ¯ âSorry, Anitha, your name is not present in the listâã
å¨ä¸é¢ï¼ææä¾äºå ³äº ActionScriptç¼ç¨çåºè²çåèèµæãè¿å¯ä»¥æ¾å°ä¸ä¸ªè®ºåçé¾æ¥ï¼ä½¿ç¨ ActionScript çå¼å人åå¨è¿éç´æ¥åçä»»ä½é®é¢ãæ°ç ActionScript Virtual Machine å Flash Player æ许å¤ä»¤äººå ´å¥çæ¹è¿ï¼ä½æ¯è¿è¶ åºäºæ¬æçèå´ãå¦ææ¨è¿æ²¡æä¸è½½ææ°ç Flash Player çæ¬ï¼å°±è¯·ä¸è½½å®ï¼ä½ä¼ä¸ä¸å®çä¼å¤ä¼ç¹ã