来看看:Flash CS4教程:AS3制造十分大度的曲线-Flash实例教程
ActionScript是一种程序语言的简单文本文件.FLA档案能够直接包含ActionScript。poluoluo中心提醒:本教程是利用FlashCS4大概FlexBuilder3内里的Actionscript3.0完成的一种十分大度的曲线殊效!
本教程是利用FlashCS4大概FlexBuilder3内里的Actionscript3.0完成的一种十分大度的曲线殊效!
最后的效果:
上面大抵先容下制造的流程,文章的最初供应源码下载。个中的一些英文没有给人人翻译啊!呵呵
创建一个ActionScript3.0项目大概类
假如你用的是FlexBuilder那末你就创立一个新的ActionScript3.0项目,定名为LineEffect。假如你利用的是FlashCS3orCS4创立一个新的文档(ActionScript3.0)定名为LineEffect.as。
package{
importflash.display.Sprite;
SameImports
Again,ifyouuseFlexBuilder(FlexBuilderIusetoo),itisnotmandatorytowritethisstep,becauseFlexBuilderautomaticallyimportswhenitseessomethingunknown.ButifyouuseFlashCS3orCS4isrequiredtowritethisstep.
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;Ifyouareconfusedaboutthislineofcode:
Well,herewesetthewidth,height,framerate,backgroundColorandthetitleoftheSWFfile.
DeclaringVariables
Tobeeasierforyourfuturereference,I’vedeclaredvariablesforeachcolorline.ButbeforecolorsweneedtodeclareaSpritebecausewewanttodrawaline,andapplyaneffecttoit.AfterthatwewilldeclareanArraythatwillhelptoanimatetheline.Attheendwewilldeclarethebuttonswithtextasalsolinecolors.ThelinecolorsconsistsinaBlurFilter,twoGlowFilterandaDropShadowFilter.Thecodelookslikethat:
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.
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=;}}}EnterFrameFunction
ThefollowingEnterFramefunctionwilltrackthemousecoordinatesandshowtheeffectonthestage.
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){continue}if(getTimer()-points.life>1000){points.splice(i--,1)}else{if(i!=0&&points){points.x+=points.vx;points.y+=points.vy;varcx:Number=points.x;varcy:Number=points.y;line.curveTo(cx,cy,(points.x+cx)*0.5,(points.y+cy)*0.5);}else{line.moveTo(points.x,points.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.
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=;}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=;}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=;}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=;}}}ThiswastheLineEffecttutorial.Ihopeitwillbeusefullformanyofyou.Nowyoucantrytocreateyourownlineeffectsanddropacommentmentioningtheurlofyourexperiments.Wearealwayslookingfortheresultsofourtutorials.
源文件下载:http://www.webjx.com/files/soft/1_090619181757.zip
Flash8支持一种新的编码格式(On2的VP6),这种编码格式与Flash7的视频编码格式相比,有了很大的提高。 作为奖赏,你可以使用关键祯动画支持和tweening- 两个最主要的节省时间的方式。本质上,关键祯是动画中显著事件发生的位置。 富媒体广告的概念:富媒体 Rich Media,是由英文翻译而来,从字面上很难理解Rich Media到底是什么。 时间期限本身就是一个优点,因为它可以让你确定一个祯率。电视每秒刷新屏幕30次,电影每秒刷新屏幕24次。Flash的祯率是可变的。 矢量图形相对于位图的另一个优势是可以随意缩放的能力。这是对动画进程的奖赏,对用户来说也是一个很酷的特征。在Flash之前,Web上没有这种功能。 只要用心 只要努力 在加上你无限的创意和想象。FLASH无敌了 在Web上只好把动画做得很小。即使最简单的动画也需要较长的下载时间。Flash的流技术和矢量图形对这种情况做了改变。
页:
[1]