仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1126|回复: 6
打印 上一主题 下一主题

[学习教程] 来看看:Flash CS4教程:AS3制造十分大度的曲线-Flash实例教程

[复制链接]
活着的死人 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-15 20:46:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
ActionScript是一种程序语言的简单文本文件.FLA档案能够直接包含ActionScript。
poluoluo中心提醒:本教程是利用FlashCS4大概FlexBuilder3内里的Actionscript3.0完成的一种十分大度的曲线殊效!
本教程是利用FlashCS4大概FlexBuilder3内里的Actionscript3.0完成的一种十分大度的曲线殊效!
最后的效果:
[media=wmv,545,396][/media]

上面大抵先容下制造的流程,文章的最初供应源码下载。个中的一些英文没有给人人翻译啊!呵呵
创建一个ActionScript3.0项目大概类

假如你用的是FlexBuilder那末你就创立一个新的ActionScript3.0项目,定名为LineEffect。假如你利用的是FlashCS3orCS4创立一个新的文档(ActionScript3.0)定名为LineEffect.as。
package{
        importflash.display.Sprite;
SameImports

Again,ifyouuseFlexBuilder(FlexBuilderIusetoo),itisnotmandatorytowritethisstep,becauseFlexBuilderautomaticallyimportswhenitseessomethingunknown.ButifyouuseFlashCS3orCS4isrequiredtowritethisstep.
  1.         importflash.display.Graphics;importflash.display.MovieClip;importflash.display.Sprite;importflash.events.Event;importflash.events.MouseEvent;importflash.filters.BlurFilter;importflash.filters.DropShadowFilter;importflash.filters.GlowFilter;importflash.text.TextField;importflash.utils.getTimer;[SWF(width="600",height="400",frameRate="30",backgroundColor="#000000",pageTitle="LineEffect")]
复制代码
Ifyouareconfusedaboutthislineofcode:
  1. [SWF(width="600",height="400",frameRate="30",backgroundColor="#000000",pageTitle="LineEffect")]
复制代码
Well,herewesetthewidth,height,framerate,backgroundColorandthetitleoftheSWFfile.
DeclaringVariables

Tobeeasierforyourfuturereference,I’vedeclaredvariablesforeachcolorline.ButbeforecolorsweneedtodeclareaSpritebecausewewanttodrawaline,andapplyaneffecttoit.AfterthatwewilldeclareanArraythatwillhelptoanimatetheline.Attheendwewilldeclarethebuttonswithtextasalsolinecolors.ThelinecolorsconsistsinaBlurFilter,twoGlowFilterandaDropShadowFilter.Thecodelookslikethat:
  1.         publicclassLineEffectextendsSprite{privatevarsp:Sprite=newSprite();privatevarpoints:Array=newArray();privatevarprevmouseX:Number=0;privatevarprevmouseY:Number=0;privatevarfireBtn:MovieClip=newMovieClip();privatevarfireTF:TextField=newTextField();privatevarskyBtn:MovieClip=newMovieClip();privatevarskyTF:TextField=newTextField();privatevargrassBtn:MovieClip=newMovieClip();privatevargrassTF:TextField=newTextField();privatevarsunBtn:MovieClip=newMovieClip();privatevarsunTF:TextField=newTextField();privatevarbf:BlurFilter=newBlurFilter(3,3,1);privatevargrowFilter:GlowFilter=newGlowFilter(0xff3300,2,20,10,2,3,true,false);privatevargrowFilter_b:GlowFilter=newGlowFilter(0xfff000,2,16,10,3,9,false,false);privatevardropShadow:DropShadowFilter=newDropShadowFilter(0,360,0xC11B17,1,70,70,5,3,false,false,false);privatevargrowFilter_2:GlowFilter=newGlowFilter(0x00ffff,2,20,10,2,3,true,false);privatevargrowFilter_b_2:GlowFilter=newGlowFilter(0x00ffff,2,16,10,3,9,false,false);privatevardropShadow_2:DropShadowFilter=newDropShadowFilter(0,360,0x000fff,1,70,70,5,3,false,false,false);privatevargrowFilter_3:GlowFilter=newGlowFilter(0x4AA02C,2,20,10,2,3,true,false);privatevargrowFilter_b_3:GlowFilter=newGlowFilter(0x4AA02C,2,16,10,3,9,false,false);privatevardropShadow_3:DropShadowFilter=newDropShadowFilter(0,360,0x4AA02C,1,70,70,5,3,false,false,false);privatevargrowFilter_4:GlowFilter=newGlowFilter(0xFDD017,2,20,10,2,3,true,false);privatevargrowFilter_b_4:GlowFilter=newGlowFilter(0xFDD017,2,16,10,3,9,false,false);privatevardropShadow_4:DropShadowFilter=newDropShadowFilter(0,360,0xFDD017,1,70,70,5,3,false,false,false);
复制代码
Whateventswehavehere?

Firstweaddthesp(Sprite)tothestage,thenweaddanEnter_FrameeventtoourSprite,draweachbuttonandcreateaClickeventforeachoneinordertochangefromcolorandeffect.
  1. publicfunctionLineEffect(){this.addChild(sp);this.addEventListener(Event.ENTER_FRAME,onEnter);drawFireBtn(fireBtn);drawSkyBtn(skyBtn);drawGrassBtn(grassBtn);drawSunBtn(sunBtn);fireBtn.addEventListener(MouseEvent.CLICK,makeFire);skyBtn.addEventListener(MouseEvent.CLICK,makeSky);grassBtn.addEventListener(MouseEvent.CLICK,makeGrass);sunBtn.addEventListener(MouseEvent.CLICK,makeSun);sp.filters=[bf,dropShadow];}}}
复制代码
EnterFrameFunction

ThefollowingEnterFramefunctionwilltrackthemousecoordinatesandshowtheeffectonthestage.
  1. privatefunctiononEnter(e:Event):void{varline:Graphics=sp.graphics;line.clear();line.lineStyle(2,0xffffff);line.moveTo(mouseX,mouseY);vardx:Number=this.mouseX-prevmouseX;varvx:Number=dx?dx:Math.random()*randSet(-1,1);vardy:Number=this.mouseY-prevmouseY;varvy:Number=dy?dy:Math.random()*randSet(-1,1);varpLen:Number=points.push({x:this.mouseX,y:this.mouseY,vx:vx/20,vy:vy/20,life:getTimer()});for(vari:Number=0;i<pLen;i++){if(!points[i]){continue}if(getTimer()-points[i].life>1000){points.splice(i--,1)}else{if(i!=0&&points[i]){points[i].x+=points[i].vx;points[i].y+=points[i].vy;varcx:Number=points[i-1].x;varcy:Number=points[i-1].y;line.curveTo(cx,cy,(points[i].x+cx)*0.5,(points[i].y+cy)*0.5);}else{line.moveTo(points[i].x,points[i].y);}}}prevmouseX=this.mouseX;prevmouseY=this.mouseY;}privatefunctionrandSet(p_min:Number,p_max:Number):Number{returnMath.floor(Math.random()*2);}}}
复制代码
Drawthebuttonsandmaketheclickevents

Nowwewriteafunctionforeachbuttonthatappliesthecolorsandeffectswehavecreatedinthebeginning.Oneachfunctionweinsertthetextbuttonsintothestagebydrawingitwithactionscript3.0usingthedrawRectclassandwechoosetherectanglefillcolor.ThenwecreateasecondfunctioninsidethisonewhichcallstheMouseEventwehavementionedaboveandwillstarttheeffect.
  1. privatefunctiondrawFireBtn(obj:MovieClip):void{with(obj.graphics){beginFill(0x0000ff,0);drawRect(0,0,20,20);endFill();}fireTF.text="Fire"fireTF.textColor=0x666666;fireTF.mouseEnabled=false;fireTF.selectable=false;this.addChild(obj);obj.buttonMode=true;obj.addChild(fireTF);obj.x=20;obj.y=380;}privatefunctionmakeFire(E:MouseEvent):void{sp.filters=[bf,growFilter,growFilter_b,dropShadow];}privatefunctiondrawSkyBtn(obj:MovieClip):void{with(obj.graphics){beginFill(0x0000ff,0);drawRect(0,0,20,20);endFill();}skyTF.text="Sky"skyTF.textColor=0x666666;skyTF.mouseEnabled=false;skyTF.selectable=false;this.addChild(obj);obj.buttonMode=true;obj.addChild(skyTF);obj.x=70;obj.y=380;}privatefunctionmakeSky(e:MouseEvent):void{sp.filters=[bf,growFilter_2,growFilter_b_2,dropShadow_2];}privatefunctiondrawGrassBtn(obj:MovieClip):void{with(obj.graphics){beginFill(0x0000ff,0);drawRect(0,0,25,20);endFill();}grassTF.text="Grass"grassTF.textColor=0x666666;grassTF.mouseEnabled=false;grassTF.selectable=false;this.addChild(obj);obj.buttonMode=true;obj.addChild(grassTF);obj.x=120;obj.y=380;}privatefunctionmakeGrass(e:MouseEvent):void{sp.filters=[bf,growFilter_3,growFilter_b_3,dropShadow_3];}privatefunctiondrawSunBtn(obj:MovieClip):void{with(obj.graphics){beginFill(0x0000ff,0);drawRect(0,0,20,20);endFill();}sunTF.text="Sun"sunTF.textColor=0x666666;sunTF.mouseEnabled=false;sunTF.selectable=false;this.addChild(obj);obj.buttonMode=true;obj.addChild(sunTF);obj.x=170;obj.y=380;}privatefunctionmakeSun(e:MouseEvent):void{sp.filters=[bf,growFilter_4,growFilter_b_4,dropShadow_4];}}}
复制代码
ThiswastheLineEffecttutorial.Ihopeitwillbeusefullformanyofyou.Nowyoucantrytocreateyourownlineeffectsanddropacommentmentioningtheurlofyourexperiments.Wearealwayslookingfortheresultsofourtutorials.
源文件下载:http://www.webjx.com/files/soft/1_090619181757.zip

Flash8支持一种新的编码格式(On2的VP6),这种编码格式与Flash7的视频编码格式相比,有了很大的提高。
只想知道 该用户已被删除
沙发
发表于 2015-1-21 10:08:30 | 只看该作者
作为奖赏,你可以使用关键祯动画支持和tweening- 两个最主要的节省时间的方式。本质上,关键祯是动画中显著事件发生的位置。
蒙在股里 该用户已被删除
板凳
发表于 2015-1-30 14:50:51 | 只看该作者
富媒体广告的概念:富媒体 Rich Media,是由英文翻译而来,从字面上很难理解Rich Media到底是什么。
地板
发表于 2015-2-6 13:40:15 | 只看该作者
时间期限本身就是一个优点,因为它可以让你确定一个祯率。电视每秒刷新屏幕30次,电影每秒刷新屏幕24次。Flash的祯率是可变的。
莫相离 该用户已被删除
5#
发表于 2015-2-16 09:20:08 | 只看该作者
矢量图形相对于位图的另一个优势是可以随意缩放的能力。这是对动画进程的奖赏,对用户来说也是一个很酷的特征。在Flash之前,Web上没有这种功能。
若天明 该用户已被删除
6#
发表于 2015-3-5 05:44:16 | 只看该作者
只要用心 只要努力 在加上你无限的创意和想象。FLASH无敌了
精灵巫婆 该用户已被删除
7#
发表于 2015-3-11 23:53:48 | 只看该作者
在Web上只好把动画做得很小。即使最简单的动画也需要较长的下载时间。Flash的流技术和矢量图形对这种情况做了改变。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-4 08:15

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表