asÖÆ×÷СÇòÁ¬Ïß´úÂë [ ÍøÕ¾µØÍ¼ ]

·¢±íÓÚ:2010-1-12 ä¯ÀÀ:39 ×÷Õß: À´Ô´:»¥ÁªÍø

¹Ø¼ü×Ö:as,СÇòÁ¬Ïß

ÃèÊö:ºÜ¼òµ¥µÄЧ¹û,ÊÇÔÚÊܵ½ÊéÖÐÆô·¢×ö³öÀ´µÄ,²»¹ýЧÂʲ»¸ß,»ØÍ·¿´¿´ÊéÉÏÊÇÔõôʵÏÖµÄ,´úÂë¶¼ÊÇ×Ô¼ºÐ´µÄ,·¢ÏÖÕâ¸öЧ¹ûºÜ¼òµ¥Æäʵ ¡¡¡¡Ð¡Çò´úÂë package{¡¡¡¡¡¡¡¡import¡¡flash.display.CapsStyle;¡¡¡¡¡¡¡¡imp

ºÜ¼òµ¥µÄЧ¹û,ÊÇÔÚÊܵ½ÊéÖÐÆô·¢×ö³öÀ´µÄ,²»¹ýЧÂʲ»¸ß,»ØÍ·¿´¿´ÊéÉÏÊÇÔõôʵÏÖµÄ,´úÂë¶¼ÊÇ×Ô¼ºÐ´µÄ,·¢ÏÖÕâ¸öЧ¹ûºÜ¼òµ¥Æäʵ


¡¡¡¡Ð¡Çò´úÂë

package
{
¡¡¡¡¡¡¡¡import¡¡flash.display.CapsStyle;
¡¡¡¡¡¡¡¡import¡¡flash.display.JointStyle;
¡¡¡¡¡¡¡¡import¡¡flash.display.Sprite;
¡¡¡¡¡¡¡¡import¡¡flash.events.TimerEvent;
¡¡¡¡¡¡¡¡import¡¡flash.display.Shape;
¡¡¡¡¡¡¡¡public¡¡class¡¡Ball¡¡extends¡¡Shape
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡var¡¡radius=10;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡var¡¡vx=0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡var¡¡vy=0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡function¡¡Ball()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.draw();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.x=this.radius;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.y=this.radius;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡function¡¡draw()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.graphics.beginFill(0x336FE9,.7)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.graphics.drawCircle(0,0,this.radius);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.graphics.endFill();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡trace("square¡¡innit");
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡function¡¡move()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.x+=this.vx;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.y+=this.vy;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(this.x>this.stage.stageWidth||this.x<0)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.vx=-this.vx;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(this.y>this.stage.stageHeight||this.y<0)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.vy=-this.vy;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡}
}

myASÀà,ÎÒ×Ô¼ºÐ´µÄÀà

package¡¡{
¡¡¡¡¡¡¡¡import¡¡flash.display.Sprite;

¡¡¡¡¡¡¡¡public¡¡class¡¡myAS¡¡extends¡¡Sprite
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡function¡¡myAS()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡for(var¡¡i=0;i<10;i++)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡rand(5);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//·µ»ØÒ»¸öËæ»úÖµ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡static¡¡function¡¡rand(x)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡returnvar=Math.ceil(Math.random()*(x));
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡trace(returnvar);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡returnvar;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//²úÉú´øÓиºÏóÏÞµÄËæ»úÖµ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡static¡¡function¡¡randNeg(x){
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(Math.random()<0.5)¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡Math.ceil(Math.random()*x)*(-1);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡else¡¡return¡¡Math.ceil(Math.random()*x);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡}
}

Ö÷´úÂë

package¡¡{
¡¡¡¡¡¡¡¡import¡¡flash.display.Sprite;
¡¡¡¡¡¡¡¡import¡¡flash.display.StageAlign;
¡¡¡¡¡¡¡¡import¡¡flash.display.StageScaleMode;
¡¡¡¡¡¡¡¡import¡¡flash.events.TimerEvent;
¡¡¡¡¡¡¡¡import¡¡flash.utils.Timer;


[SWF(width=640,¡¡height=480,¡¡backgroundColor=0x111111,¡¡frameRate=30)]
¡¡¡¡¡¡¡¡public¡¡class¡¡ball_demo¡¡extends¡¡Sprite
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public¡¡function¡¡ball_demo()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.stage.scaleMode¡¡=¡¡StageScaleMode.NO_SCALE;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.stage.align¡¡=¡¡StageAlign.TOP_LEFT;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡ballCount=100;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡ballArray=new¡¡Array();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡for(var¡¡i=0;i<ballCount;i++)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i]=new¡¡Ball();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.addChild(ballArray[i]);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].x=myAS.rand(600)+20;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].y=myAS.rand(440)+20;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡scale=myAS.rand(5)*0.1;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].scaleX=scale;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].scaleY=scale;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].vx=myAS.randNeg(5);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].vy=myAS.randNeg(5);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡this1=this;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡function¡¡move()
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this1.graphics.clear();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡for(var¡¡i=0;i<ballCount;i++)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ballArray[i].move();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡for(var¡¡j=0;j<ballCount;j++)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡lengthx=ballArray[i].x-ballArray[j].x;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡lengthy=ballArray[i].y-ballArray[j].y;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡length=Math.sqrt(lengthx*lengthx+lengthy*lengthy);

//µ±¾àÀëСÓÚ60ʱ,»­Á¬Ïß
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(length<60){
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this1.graphics.lineStyle(1,0xffffff,1/(length*0.1));
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this1.graphics.moveTo(ballArray[i].x,ballArray[i].y);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡this1.graphics.lineTo(ballArray[j].x,ballArray[j].y);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡time1:Timer=new¡¡Timer(20)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡time1.addEventListener(TimerEvent.TIMER,move);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡time1.start();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡}
}


Õ¾³¤×ÊÑ¶Íø ×öÖйú×î·á¸»µÄ×ÊÑ¶ÍøÕ¾ »¦ICP±¸05004089ºÅ