Flash CS3輕松制作一個簡單的彈性跟隨鼠標特效_Flash教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:Flash AS實現顏色漸變光線旋轉特效
      旋轉特效效果代碼如下:varpMaxSize:Number=150;varpCenterX:Number=275;varpCenterY:Number=200;varpNumTraces:Number=20;varpNumLayers:N

      這個動畫非常簡單,只是有一個圓永遠跟隨鼠標,而且還有彈性!Flash CS3輕松制作一個簡單的彈性跟隨鼠標特效。

      在寫教程之前在給大家說說我下載Flash CS3 Professional的過程,我在baidu搜到有下載的地方了!大概是400M以上,但是下載后解壓總是出錯,一晚上白浪費了!建議大家最好去Adobe官方網站去下載,是單線程的,假如大家網速快就能下載完的!

      看下演示吧!

      源文件下載:點擊這里下載源文件

      具體制作說明,使用Flash CS3來實現,用的也是ActionScript 3.0,您假如不懂可以查看本站相關教程。

      新建立一個文檔(File > New > ActionScript 3.0),然后保存為mb5u_com.fla,然后按Ctrl F3打開屬性面板,設置幀頻為30fps,document class主類為Sproingdemo。

      Flash CS3輕松制作一個簡單的彈性跟隨鼠標特效

      然后設置as,打開文本編輯,把下面代碼保存為Sproingdemo.as。

      package {
      import flash.display.Shape;
      import flash.display.Sprite;
      import flash.events.Event;
      import flash.ui.Mouse;

      public class SproingDemo extends Sprite {
      private var orb1:Shape;
      private var orb2:Orb;
      private var lineCanvas:Shape;
      private var spring:Number = .1;
      private var damping:Number = .9;

      // Constructor
      public function SproingDemo() {
      init();
      }

      private function init():void {
      // Set up the small orb
      orb1 = new Shape();
      orb1.graphics.lineStyle(1, 0x6633CC);
      orb1.graphics.beginFill(0x6699CC);
      orb1.graphics.drawCircle(0, 0, 10);

      // Set up the large orb
      orb2 = new Orb(25, 0x00CCFF, 1, 0x0066FF);

      // Set up the drawing canvas for the line drawn between the orbs
      lineCanvas = new Shape();

      // Add lineCanvas, orb1 and arb2 to this object's display hierarchy
      addChild(orb2);
      addChild(orb1);
      addChild(lineCanvas);

      // Register for Event.ENTER_FRAME events
      addEventListener(Event.ENTER_FRAME, enterFrameListener);

      // Hide the mouse pointer
      Mouse.hide();
      }

      private function enterFrameListener(e:Event):void {
      // Set orb1's position to current mouse position
      orb1.x = mouseX;
      orb1.y = mouseY;

      // Spring orb2 to orb1
      orb2.vx = (orb1.x - orb2.x) * spring;
      orb2.vy = (orb1.y - orb2.y) * spring;
      orb2.vx *= damping;
      orb2.vy *= damping;
      orb2.x = orb2.vx;
      orb2.y = orb2.vy;

      // Draw a line between the two orbs
      drawLine();
      }

      private function drawLine():void {
      with (lineCanvas) {
      graphics.clear();
      graphics.moveTo(orb1.x, orb1.y);
      graphics.lineStyle(1, 0x4C59D8);
      graphics.lineTo(orb2.x, orb2.y);
      }
      }
      }
      }

      然后再建立一個Orb.as,內容如下。

      package {
      import flash.display.Shape;

      public class Orb extends Shape {
      internal var radius:int;
      internal var vx:Number = 0;
      internal var vy:Number = 0;

      // Constructor
      public function Orb(radius:int = 20, fillColor:int = 0x00FF00, lineThickness:int = 1, lineColor:int = 0) {
      this.radius = radius;
      graphics.lineStyle(lineThickness, lineColor);
      graphics.beginFill(fillColor);
      graphics.drawCircle(0, 0, radius);
      }
      }
      }

      這時要注重上面三個文件一個要保存在同一個目錄下,這時就可以測試影片了!

      分享:Flash聯合粒子特效軟件打造超酷浪漫動畫特效
      看到閃吧某網友在學習這個的過程中碰到一些問題,就幫解答一下。在此寫寫教程,有不足之處,還請大家指點。粒子特效軟件的功能還很多,有愛好的可以自行研究下

      來源:網頁教學網//所屬分類:Flash教程/更新時間:2008-03-05
      相關Flash教程