05

闲来无事,发个as效果

类别: 作品鼠标炸弹 @ 2009.09.05 11:34 已阅1,753次
标签: ,

需要 Flash Player 10
代码:

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package org.mousebomb.effectlab.flyParticle 
{
	import flash.display.GradientType;	
	import flash.display.BlendMode;	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;		
 
	[SWF(width = 900, height = 600, frameRate = 50)]
 
	/**
	 * @author Mousebomb
	 * @date 2009-9-4
	 */
	public class Main extends Sprite 
	{
		private	var scont : Sprite = new Sprite();
 
		public function Main()
		{
			scont.x = 450;
			scont.y = 300;
			addChild(scont);
			scont.rotationY = 90;
			for(var i : int = 0 ;i < 48; i++)
			{
				var s : Shape = new Shape();
				s.graphics.beginFill((0xcc0000 + (i % 16) * 0x10000),.6);
				//s.graphics.drawCircle(Math.floor(i / 3) * 15, i, 25);
				s.graphics.drawRect(Math.floor(i / 3) * 15 - 25, i - 25, 50,50);
				s.graphics.endFill();
				scont.addChild(s);
			}
 
 
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
 
		private function onEnterFrame(event : Event) : void
		{
			for(var i : int = 0 ;i < 48;i++)
			{
				var s : Shape = scont.getChildAt(i) as Shape;
				s.rotation += (i / 6) * .7;
			}
			scont.rotation+=.7;
			scont.rotationY += .3;
		}
	}
}

flash地址
虽然电闪雷鸣之类的更逼真更常用,但我自己玩的时候还是比较喜欢这样抽象的效果。
万事万物的道理都在这个旋转的flash里体现了。

本文对您有用吗? 何不留下评论继续交流, 或者在您的博客上引用本文继续探讨.
您可以订阅读者对本文的回应或者订阅本博客以在您的阅读器中自动获取更新.

本文居然还有同伙!有兴趣不?

才 7 条评论 - “闲来无事,发个as效果”

  1. Hobo Windows other version Firefox 3.5.2 说:

    效果挺好

    [回复]

  2. 無名指 Windows XP Internet Explorer 8.0 说:

    NB,佩服得不得了!!

    [回复]

  3. A.shun Windows XP Opera 9.80 说:

    真厉害。。看得我头晕

    [回复]

  4. 三七八蛋 Windows XP Internet Explorer 8.0 说:

    很少读闪客高手的博客,以后要常来。哈

    [回复]

  5. snail Windows XP Firefox 3.5.3 说:

    像魔术牌。

    [回复]

  6. 望乡叔叔 Windows XP Internet Explorer 7.0 说:

    hi 我是AS3初学者,蜗牛的同学
    关于这段代码有些问题请教下:

    1. public class Main extends Sprite 
    2.     {
    3.         private    var scont : Sprite = new Sprite();
    4.  
    5.         public function Main()
    6.         {
    7.             scont.x = 450;
    8.             scont.y = 300;
    9.             addChild(scont);
    10.             scont.rotationY = 90;//这里的rotationY 和最下面的rotationY的区别
    11.             for(var i : int = 0 ;i &lt; 48; i++)  
    12.             {
    13.                 var s : Shape = new Shape();
    14.                 s.graphics.beginFill((0xcc0000 + (i % 16) * 0x10000),.6);
    15.                               
    16.                                 //填充颜色这两个眼色值的作用是什么?我查看了F1帮助,没有介绍用两个值的
    17.  
    18.                 //s.graphics.drawCircle(Math.floor(i / 3) * 15, i, 25);
    19.                 s.graphics.drawRect(Math.floor(i / 3) * 15 - 25, i - 25, 50,50);
    20.                 s.graphics.endFill();
    21.                 scont.addChild(s);
    22.             }
    23.  
    24.  
    25.             addEventListener(Event.ENTER_FRAME, onEnterFrame);
    26.         }
    27.  
    28.         private function onEnterFrame(event : Event) : void
    29.         {
    30.             for(var i : int = 0 ;i &lt; 48;i++)
    31.             {
    32.                 var s : Shape = scont.getChildAt(i) as Shape;
    33.                 s.rotation += (i / 6) * .7;
    34.             }
    35.             scont.rotation+=.7;
    36.             scont.rotationY += .3;
    37.         }
    38.     }
    39. }

    [回复]

    鼠标炸弹 Windows Vista Firefox 3.5.4
    1. public class Main extends Sprite 
    2.     {
    3.         private    var scont : Sprite = new Sprite();
    4.  
    5.         public function Main()
    6.         {
    7.             scont.x = 450;
    8.             scont.y = 300;
    9.             addChild(scont);
    10.             scont.rotationY = 90;//这里的rotationY 和最下面的rotationY的区别//回答:这里确定的是最初的值,而下面是动画中不断改变这个值。
    11.             for(var i : int = 0 ;i &lt; 48; i++)  
    12.             {
    13.                 var s : Shape = new Shape();
    14.                 s.graphics.beginFill((0xcc0000 + (i % 16) * 0x10000),.6);
    15.                               
    16.                                 //填充颜色这两个眼色值的作用是什么?我查看了F1帮助,没有介绍用两个值的
    17. //回答:这个函数第一个参数是颜色,第二个参数是不透明度。 我这里颜色是(0xcc0000 + (i % 16) * 0x10000),alpha是0.6,并没有两个颜色。
    18.  
    19.                 //s.graphics.drawCircle(Math.floor(i / 3) * 15, i, 25);
    20.                 s.graphics.drawRect(Math.floor(i / 3) * 15 - 25, i - 25, 50,50);
    21.                 s.graphics.endFill();
    22.                 scont.addChild(s);
    23.             }
    24.  
    25.  
    26.             addEventListener(Event.ENTER_FRAME, onEnterFrame);
    27.         }
    28.  
    29.         private function onEnterFrame(event : Event) : void
    30.         {
    31.             for(var i : int = 0 ;i &lt; 48;i++)
    32.             {
    33.                 var s : Shape = scont.getChildAt(i) as Shape;
    34.                 s.rotation += (i / 6) * .7;
    35.             }
    36.             scont.rotation+=.7;
    37.             scont.rotationY += .3;
    38.         }
    39.     }
    40. }

    [回复]

您再来一条评论吧?