Flash ActionScript±à³ÌÖÆ×÷ÎïÀí¿Î¼þʵÀý½Ì³Ì
¡¾Àý7-2˵Ã÷¡¿
¿ÉÓëÀý5-3¶Ô±È£¬Ìå»áʹÓÃforÑ»·ºÍʹÓÃÖ¡Ñ»·µÄÇø±ð¡£
¡¾Àý7-3£ºÀñ»¨±¬Õ¨Ð§¹û¡¿
1¡¢Ð½¨FlashÎĵµ£¬´óСÉèΪ£º550*400ÏóËØ¡£
2¡¢Ð½¨Ó°Æ¬¼ô¼Ôª¼þ£ºball£¬ÔÚÖÐÐÄÊ®×Ö´¦»æÖÆÒ»Ö±¾¶10ÏóËØµÄСÇò¡£½«Ôª¼þÍÏÈëÖ÷³¡¾°(0,0)´¦£¬ÊµÀýÃû³ÆÉèΪball_mc¡£
3¡¢Ð½¨Ó°Æ¬¼ô¼Ôª¼þ£ºdot£¬ÔÚÖÐÐÄÊ®×Ö´¦»æÖÆÒ»Ö±¾¶2ÏóËØµÄÔ²¡£½«Ôª¼þÍÏÈëÖ÷³¡¾°(0,0)´¦£¬ÊµÀýÃû³ÆÉèΪdot_mc¡£
4¡¢Ð½¨Á½¸ö°´Å¥£¬·Ö±ðдÈë¡°Ëé¿éÊýÔö¼Ó¡±ºÍ¡°Ëé¿éÊý¼õÉÙ¡±¡£½«Ôª¼þÍÏÈëÖ÷³¡¾°£¬ÊµÀýÃû³Æ·Ö±ðÉèΪ£ºnum_add_btnºÍnum_sub_btn¡£
5¡¢ÔÚÖ÷³¡¾°Ð½¨Ò»¸öÆÕͨÎı¾£¬Ð´È룺¡°Ëé¿éÊý£º¡±¡£Ð½¨Ò»¸ö¶¯Ì¬Îı¾£¬±äÁ¿´¦ÌîÈ룺block_num¡£
6¡¢Ð½¨action²ã£¬ÔÚaction²ãµÚһ֡дÈëActionScript£º var block_num:Number = 6; var v_out:Number = 5; var a:Number = 0.2; var t:Number;
var depth:Number = 1; //³õʼ±äÁ¿¸³Öµ var i:Number; var vx:Number; var vy:Number; //Öмä±äÁ¿¶¨Òå
num_add_btn.onRelease = function() { //СÇò¸öÊýÔö¼Ó°´Å¥ÏìÓ¦ if (block_num<=15) { block_num++; } gotoAndPlay(2); };
num_sub_btn.onRelease = function() { //СÇò¸öÊý¼õÉÙ°´Å¥ÏìÓ¦ if (block_num>=3) { block_num--; } gotoAndPlay(2); };
µÚ 45 Ò³ ¹² 79 Ò³
Flash ActionScript±à³ÌÖÆ×÷ÎïÀí¿Î¼þʵÀý½Ì³Ì
7¡¢ÔÚaction²ãµÚ¶þ֡дÈëActionScript£º for (i=1; i<=depth; i++) { //ɾ³ý¹ì¼£Ãîµã removeMovieClip(this[\}
depth = 1;
for (i=0; i<=block_num; i++) { //ɾ³ýÔÓÐСÇò removeMovieClip(this[\}
for (i=0; i 8¡¢ÔÚaction²ãµÚÈý֡дÈëActionScript£º for (i=0; i 9¡¢ÔÚaction²ãµÚËÄ֡дÈëActionScript£º t++; gotoAndPlay(3); 10¡¢ÓÃÆÕͨ֡²¹×ãÆäËûͼ²ã£¬±£´æ£¬·¢²¼¡£ ¡¾Àý7-3˵Ã÷¡¿ ¼ÙÉèÀñ»¨ÔÚ¿ÕÖб¬Õ¨ºó£¬Ë鯬¾ùÔÈÉ¢¿ª£¬±¾ÀýÖн«Æä¼ò»¯ÎªÍ¬Ò»Æ½ÃæÄÚ´ÓÔ²ÐľùÔȽǶȡ¢ÏàͬËÙ¶ÈÉä³öµÄСÇò£¬²¢ÇÒÃè»æÐ¡ÇòµÄ¹ì¼£¡£ ʹÓÃduplicateMovieClip()º¯Êý¸´ÖƳöµÄӰƬ¼ô¼£¬¿ÉÒÔʹÓÃremoveMovieClip()º¯Êýɾ³ý£¬±¾ÀýÖÐÖØÖÃСÇòʱʹÓô˺¯Êýɾ³ýÉϴεĹ켣ÇúÏߺÍÉϴθ´ÖƳöµÄСÇò£¨±ÜÃâË鯬Êý¼õÉÙʱСÇòÈÔÈ»ÁôÔÚ³¡¾°ÄÚ£©¡£ µÚ 46 Ò³ ¹² 79 Ò³ Flash ActionScript±à³ÌÖÆ×÷ÎïÀí¿Î¼þʵÀý½Ì³Ì ¡¾Àý7-4£º²¨¶¯·½³Ì¡¿ 1¡¢Ð½¨FlashÎĵµ£¬´óСÉèΪ550*400ÏóËØ¡£ 2¡¢Ð½¨Ó°Æ¬¼ô¼Ôª¼þ£ºball£¬ÔÚÔª¼þÖÐÐÄÊ®×Ö´¦»æÖÆÖ±¾¶10ÏóËØµÄСÇò¡£½«Ôª¼þÍÏÖÁ³¡¾°(0,0)´¦£¬ÊµÀýÃû³ÆÉèΪball_mc¡£ 3¡¢Ð½¨action²ã£¬ÔÚaction²ãµÄµÚһ֡дÈëActionSctipt£º var w:Number = 0.1; //ÿ¸öСÇòÕñ¶¯µÄԲƵÂÊ var w2:Number = 0.1; //²¨ÖÐÿ¸öСÇòµÄÑÓ³Ù var l:Number = 100; var t:Number = 0; for (var i:Number = 1; i<55; i++) { duplicateMovieClip(\ this[\ this[\} 4¡¢ÔÚaction²ãµÚ¶þ֡дÈëActionScript£º for (i=1; i<55; i++) { this[\} 5¡¢ÔÚaction²ãµÚÈý֡дÈëActionScript£º t++; gotoAndPlay(2); 6¡¢±£´æ£¬·¢²¼¡£ ¡¾Àý7-5£º²¨µÄµþ¼Ó¡¿ 1¡¢ÔÚÀý7-4»ù´¡ÉϼÌÐø½øÐÐÐ޸ġ£ 2¡¢ÔÚactionµÚÒ»Ö¡×·¼ÓActionScript£º var w_r:Number = 0.15; var w_r2:Number = 0.25; var l_r:Number = 50; 3¡¢½«actionµÚ¶þÖ¡ActionScript¸ÄΪ£º i = 1; while (i<55) { this[\ i++; } 4¡¢Áí´æÎªÀý7-5£¬·¢²¼¡£ µÚ 47 Ò³ ¹² 79 Ò³ Flash ActionScript±à³ÌÖÆ×÷ÎïÀí¿Î¼þʵÀý½Ì³Ì ¡¾Àý7-5˵Ã÷¡¿ ±¾ÀýÖн«µÚ¶þÖ¡ÖеÄforÑ»·»»³ÉÁËwhileÑ»·£¬Ð§¹ûÊǵȼ۵ģ¬Í¬Ñ§ÃÇ¿ÉÒԱȽÏÒ»ÏÂÕâÁ½ÖÖÑ»·Ð´·¨µÄÇø±ð¡£whileÑ»·µÄÒ»°ãÐÎʽΪ£º while(Ìõ¼þ){ Óï¾ä; } do¡whileÑ»·µÄÒ»°ãÐÎʽΪ£º do{ Óï¾ä }while(Ìõ¼þ); ×¢Òâ¼ÓÁ˻ҵ׵Äi++; ÊDZØÐëµÄ£¬Èç¹ûûÓеϰwhileÑ»·½«»áһֱѻ·ÏÂÈ¥£¬µ¼ÖÂflash¶¯»µÄÔËÐÐËÙ ¶È·Ç³£»ºÂý¡£Flash²¥·ÅÆ÷½«»áÒò´Ë¶ø±¨¾¯Ìáʾ£¨Èçͼ£©¡£ whileÑ»·Èç¹ûʹÓÃÀàËÆforÑ»·ÖÐiÕâÑùµÄÑ»·±äÁ¿¿ØÖÆÑ»·´ÎÊýµÄ»°£¬ÐèÒª½«Ñ»·±äÁ¿µÄÐÞ¸Ä×÷ΪÓï¾äÖеÄÒ»²¿·Ö£¬Òò´ËÓÐʱ²»ÈçforÑ»··½±ã¡£µ«ÊÇÔÚÓÐÊÂÎÞÐèµ¥¶ÀµÄÑ»·±äÁ¿Ê±£¬»òÕßÑ»·´ÎÊýÄÑÓÚÔ¤ÏȹÀ¼ÆÊ±£¬whileºÍdo¡whileÑ»·¾Í·Ç³£µÄ·½±ãÁË¡£Àý7-2ÖлæÖƵIJ¿·ÖÇúÏßÒѾÔÚflashÏÔʾ·¶Î§Ö®ÍâÁË£¨y>400£©£¬ËùÒÔ¿ÉÒÔ½«³ÌÐòÐÞ¸ÄΪÀý7-6£º var vx:Number = 5; var vy:Number = 10; var a:Number = 0.2; var i:Number = 0; do { i++; duplicateMovieClip(\ this[\ this[\} while (this[\ ¡¾ÆäËûºÍÑ»·Ïà¹ØµÄһЩÄÚÈÝ¡¿ for(¸´Êö±äÁ¿in¶ÔÏó){¶¯×÷} for?inÊǺÜÓÐȤµÄÒ»ÖÖÑ»·»úÖÆ£¬for?inÑ»·²»ÐèÒªÌõ¼þÓï¾ä£¬ÕâÖÖÑ»·ÀûÓÃÒ»¸ö²éÕÒ¡ªÌæ»»¹Ø¼ü×ֵĻúÖÆ½øÐй¤×÷¡£ Àý7-7¶¯»ÖÐÓÐ10¸öСÇò£¬ÊµÀýÃû·Ö±ðÊÇclip_1¡¢Clip_2??£¬ÎÒÃǵ±È»¿ÉÒÔʹÓÃ×Ö·û´®±í´ïʽ¼ÆËãʵÀýÃû³Æ£¬Ò²¿ÉÒÔʹÓÃfor?inÑ»·£¬ÕâÔÚʵÀýÃû²»ÖªµÀ»òÕßʵÀýÃûÄÑÒÔÓÃÒ»¸ö×Ö·û´®±í´ïʽ±íÊ¾Ê±ÌØ±ðÓÐÓô¦¡£²»¹ý£¬for?inÑ»·Ö»ÄÜÓÃÓÚ¶ÔÏóºÍÊý×飬²¢ÇÒ²»ÊǶÔÔªËØµÄËùÓÐÊôÐÔ¶¼¿ÉÒÔÕâÑù½øÐС£ µÚ 48 Ò³ ¹² 79 Ò³
Ïà¹ØÍÆ¼ö£º