1 / 16

第四节 AS 创建动画、外部创建 AS

第四节 AS 创建动画、外部创建 AS. FLASH 最新消息:. Flash Player 10.1

damien
Télécharger la présentation

第四节 AS 创建动画、外部创建 AS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第四节 AS创建动画、外部创建AS

  2. FLASH最新消息: Flash Player 10.1 很多新特性比如: Http协议的视频流(HTTP video streaming),内容保护( content protection),全局错误处理( global error handling), 还有就是多点触摸支持( multi-touch).目前支持的手机系统包括Symbian S60,Android,Palm和Windows Mobile 6.5,采用H.264标准,支持高通的SnapDragon和NVIDIA GeForce,Atom和Tegra,支持多触摸和加速计以及视频硬件加速. Flash to iphone的发布 Adobe公司日前宣布了将大举挺进智能手机市场的Flash Player 10.1,其面向Windows、Mac OS、Linux以及Windows Mobile和Palm WebOS的Beta版本将于年内问世,明年则提供对Google Android和Symbian的支持,此后还有黑莓,却独缺iPhone。 在日前召开的Adobe MAX 2009展会上,Adobe展示了Flash Professional CS5软件,它可以直接编译iPhone原生应用软件。开发者在Flash Professional CS5中完成所有Flash制作工作后,不需要经过iPhone SDK,就可以直接选择输出为.ipa格式。 AMD/ATI GPU 加速支持lash Player 10.1 Flash将支持多点触摸

  3. 据Adobe统计,Flash运用在网络75%的视频和70%的游戏上,普及率高达93%,而Flash Player 10也高达81%,远超对手Silverlight和Sun. Adobe在下一个版本的Flash也就是 Flash 10.1中就会完全支持GPU,GPU将完全替代CPU的角色,全程负责Flash的处理以及渲染 。

  4. 4.1 控制MC的属性 MC的常用属性: X、y、rotation、alpha、scaleX、scaleY、visible 改变属性: MC.属性 = 值; 增加和减少属性: star_mc.addEventListener(MouseEvent.CLICK,rotateStar); function rotateStar(e:MouseEvent):void { star_mc.rotation += 5; }

  5. 4.1 控制MC的属性 • 使用ENTER_FRAME控制影片属性创建动画 addEventListener(Event.ENTER_FRAME, starMove); function starMove(e:Event):void { if (star_mc.x < stage.stageWidth) { star_mc.x += 2; } else { star_mc.x = 0; } } • 取消ENTER_FRAME事件: removeEventListener(Event.ENTER_FRAME, starMove);

  6. 4.1 控制MC的属性 • 保存影片剪辑的引用 var instrument:MovieClip = banjo; instrument_txt.text = "The Banjo has been selected."; violin.addEventListener(MouseEvent.CLICK,onViolin); banjo.addEventListener(MouseEvent.CLICK,onBanjo); trumpet.addEventListener(MouseEvent.CLICK,onTrumpet); glock.addEventListener(MouseEvent.CLICK,onGlock); function onViolin(e:MouseEvent):void { instrument = violin; instrument_txt.text = "The Violin has been selected."; } function onTrumpet(e:MouseEvent):void { instrument = trumpet; instrument_txt.text = "The Trumpet has been selected."; } function onBanjo(e:MouseEvent):void { instrument = banjo; instrument_txt.text = "The Banjo has been selected."; } function onGlock(e:MouseEvent):void { instrument = glock; instrument_txt.text = "The Glockenspiel has been selected."; }

  7. 使用按钮更改MC属性 grow_btn.addEventListener(MouseEvent.CLICK, grow); shrink_btn.addEventListener(MouseEvent.CLICK, shrink); rotate_btn.addEventListener(MouseEvent.CLICK, rotate); hide_btn.addEventListener(MouseEvent.CLICK, hideClip); show_btn.addEventListener(MouseEvent.CLICK,showClip); fadeOut_btn.addEventListener(MouseEvent.CLICK,fadeOut); fadeIn_btn.addEventListener(MouseEvent.CLICK,fadeIn); function grow(e:MouseEvent):void { Instrument.scaleX += .1; Instrument.scaleY += .1; } function shrink(e:MouseEvent):void { Instrument.scaleX -= .1; Instrument.scaleY -= .1; } function rotate(e:MouseEvent):void { Instrument.rotation += 5; } function hideClip(e:MouseEvent):void { instrument.visible = false; } function showClip(e:MouseEvent):void { instrument.visible = true; } function fadeOut(e:MouseEvent):void { instrument.alpha = .5; } function fadeIn(e:MouseEvent):void { instrument.alpha = 1; } 4.1 控制MC的属性

  8. 4.2 使用AS补间和缓动类创建动画 • 创建Tween类的实例 var growX:Tween = new Tween(instrument, "scaleX", Elastic.easeOut, .2, 2, 3, true); • 导入补间和缓动类 import fl.transitions.Tween; import fl.transitions.easing.*;

  9. function grow(e:MouseEvent):void { var growX:Tween = new Tween(instrument, "scaleX", Elastic.easeOut, .2, 2, 3, true); var growY:Tween = new Tween(instrument, "scaleY", Elastic.easeOut, .2, 2, 3, true); } function shrink(e:MouseEvent):void { var shrinkX:Tween = new Tween(instrument, "scaleX", Elastic.easeOut, 2, .5, 3, true); var shrinkY:Tween = new Tween(instrument, "scaleY", Elastic.easeOut, 2, .5, 3, true); } function rotate(e:MouseEvent):void { var spin:Tween = new Tween(instrument, "rotation", Elastic.easeOut, 0, 360, 5, true) } function hideClip(e:MouseEvent):void { instrument.visible = false; } function showClip(e:MouseEvent):void { instrument.visible = true; } function fadeOut(e:MouseEvent):void { var tweenfadeOut:Tween = new Tween(instrument, "alpha", None.easeOut, 1, 0, 3, true); } function fadeIn(e:MouseEvent):void { var tweenfadeIn:Tween = new Tween(instrument, "alpha", None.easeIn, instrument.alpha, 1, 3, true); } 4.2 使用AS补间和缓动类创建动画

  10. 4.3 创建独立AS文件 • 菜单:新建,ActionScript文件,与fla文件放到一起。 • 类的创建: 类名、as文件名、构造函数名必须一致。 • package 、public、class、extends • 类、构造函数必须是public package { import flash.display.MovieClip; public class Ellipse extends MovieClip { public function Ellipse(w:Number=40,h:Number=40, color:uint=0xff0000) { graphics.beginFill(color); graphics.drawEllipse(0, 0, w, h); graphics.endFill(); } } }

  11. 4.3 创建独立AS文件 • 函数的参数:可选参数和必要参数 • public function Ellipse(w:Number=40,h:Number=40, color:uint=0xff0000) • 绘制椭圆 • graphics.beginFill(color); • graphics.drawEllipse(0, 0, w, h); • graphics.endFill(); • 颜色值:16进制,0xFFFFFF (0xRGB)

  12. 4.4 FLASH中创建类文件实例 • var ellipse:Ellipse = new Ellipse(10, 10, color); • addChild(ellipse); • New关键字 • addChild() • removeChild()

  13. 4.4 FLASH中创建类文件实例 • 复杂效果:涂鸦 • var color:Number; • stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing); • function startDrawing(e:MouseEvent):void { • var ellipse:Ellipse = new Ellipse(); • addChild(ellipse); • ellipse.x = mouseX; • ellipse.y = mouseY; • }

  14. 4.4 FLASH中创建类文件实例 • 复杂效果:涂鸦 • var color:Number; • stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing); • stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing); • function startDrawing(e:MouseEvent):void { • stage.addEventListener(MouseEvent.MOUSE_MOVE, makeShapes); • color = Math.random() * 0xFFFFFF; • } • function stopDrawing(e:MouseEvent):void { • stage.removeEventListener(MouseEvent.MOUSE_MOVE, makeShapes) • } • function makeShapes(e:MouseEvent):void { • var ellipse:Ellipse = new Ellipse(10, 10, color); • addChild(ellipse); • ellipse.x = mouseX; • ellipse.y = mouseY; • }

  15. 本节作业:

  16. See you

More Related