FLASH-as3.0常用代码_第1页
FLASH-as3.0常用代码_第2页
FLASH-as3.0常用代码_第3页
FLASH-as3.0常用代码_第4页
FLASH-as3.0常用代码_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

FLASH as3 0 常用代码 1 按钮事件 新版 步骤 实现第一帧暂停 右击第一帧 点动作 写代码 stop 实现点按钮开始 放一个按钮 可以在窗口菜单 公用库 按钮里找一个 在第一帧的舞台上 属性面板 里给按钮取名 实例名称 bt1 右击第一帧 点动作 写代码 bt1 addEventListener MouseEvent CLICK f1 function f1 evt MouseEvent gotoAndPlay 2 补充 as2 老版 中的按钮事件 实现第一帧暂停 右击第一帧 点动作 写代码 stop 实现点按钮开始 放一个按钮 可以在窗口菜单 公用库 按钮里找一个 在第一帧的舞台上 右击 按钮 点动作 写代码 on release gotoAndPlay 2 2 按钮超链接 linkButton addEventListener MouseEvent CLICK gotoAdobeSite function gotoAdobeSite event MouseEvent void var adobeURL URLRequest new URLRequest navigateToURL adobeURL 3 随机数 Math random 输出时间 var time1 Date new Date t1 text time1 toLocaleTimeString 4 画线 1 graphics lineStyle 3 0 xff0000 0 3 graphics moveTo 300 100 graphics lineTo 200 300 画线 2 graphics lineStyle 1 0 xff0000 1 for var i int 0 i 100 i graphics lineTo Math random 600 Math random 400 5 画三角形 var m1 MovieClip new MovieClip 声明一个新的 mc 类 bt1 并用 new 来构造它 m1 graphics lineStyle 2 0 x990000 75 使用 bt1 的 graphics 属性设置线条粗细 颜色 透明度 m1 graphics beginFill 0 x00FF00 以下的代码是用 graphics 画三角形 m1 graphics moveTo 100 200 m1 graphics lineTo 200 100 m1 graphics lineTo 0 100 m1 graphics lineTo 100 200 this addChild m1 6 影片剪辑属性设置 aa x aa x 20 aa y aa y 20 aa rotation aa rotation 10 aa scaleX aa scaleX 1 1 aa scaleY aa scaleY 1 1 aa alpha 0 5 7 复制影片剪辑 影片剪辑 属性 高级 类名 snow var mc MovieClip new snow addChild mc mc x 300 Math random mc y 200 Math random 8 变量定义 赋值 var n1 Number 9 n1 n1 2 var s1 String n1 toString 9 输入文本 密码框 按钮 输出框 stop bt1 addEventListener MouseEvent CLICK f1 function f1 evt MouseEvent var s1 String s1 2 if String a text s1 b text right else b text wrong 10 数学运算 function f1 evt MouseEvent var str String String aa text var n Number 10 n Number str 1 bb text String n 11 不同的帧传递文本 第一帧 stop var s1 String s1 abc bt1 addEventListener MouseEvent CLICK f1 function f1 evt MouseEvent s1 this a text gotoAndPlay 2 第二帧 this b text s1 stop 12 数组使用 var s Array new Array 4 var i s 0 8 s 1 4 s 2 7 s 3 9 a text String s 0 s 1 13 组件 单选按钮 r1 文本框 t1 按钮 bt1 bt1 addEventListener MouseEvent CLICK f1 function f1 evt MouseEvent if r1 selected true t1 text right else t1 text fasle 14 下雨 新键一个影片剪辑 在里面作出来一滴雨落下得效果 然后设置元件属性 链接类 为 snow 在第 2 3 帧上面插入关键帧 在第一帧动作里面写上 var i i 1 在第 2 帧上面写上 var mc MovieClip new snow if i 50 mc x 550 Math random mc y 450 Math random mc alpha Math random 1 addChild mc i i 1 第 3 贞上面写上 gotoAndPlay 2 15 声音控制 声音 属性 类名 cc var song SoundChannel var mysound Sound mysound new cc var po Number 0 开始 song mysound play 0 暂停 bt2 addEventListener MouseEvent CLICK f2 function f2 evt MouseEvent po song position song stop 继续播放 bt3 addEventListener MouseEvent CLICK f3 function f3 evt MouseEvent song mysound play po 16 临时输出 trace aa 17 类的定义与对象的声明 import s2 var ss s2 new s2 var n Number n ss a trace n package public class s2 public var a Number public var b Number public function s2 this a 2 this b 3 public function f n Number Number return 10 FLASH as2 0 常用代码 1 暂停 stop 2 按钮开始 on release gotoAndPlay 2 3 数组的用法 var s new Array 4 s 0 8 s 1 4 s 2 7 s 3 9 for i 0 i s length i a text a text s i 4 鼠标隐藏 root m x root xmouse root m y root ymouse Mouse hide 5 声音的控制代码 myMusic new Sound 建立一个名为 myMusic 的声音对象 myMusic attachSound m1 将链接标识符为 mySound 的音乐捆绑到 myMusic 对象上 on release myMusic start myMusic position 1000 从当前位置开始播放 play on release myMusic stop on release myMusic start 0 play 6 动态文本变量 Flash8 用法 b text Number a text 1 a b 为实例名称 低版本用法 b Number a 1 a b 为变量名称 7 随机数用法 int Math random 1000 30 1 8 按钮控制对象属性用法 on release a1 getProperty d1 x a2 getProperty d1 y a3 getProperty d1 rotation setProperty d1 x a1 20 setProperty d1 y a2 20 setProperty d1 rotation a3 45 9 if 语句用法 on release if a text abc bb right else bb false gotoandplay 2 10 下雨 新键一个影片剪辑 在里面作出来一滴雨落下得效果 然后设置实例名称为 CC 然后返回到场景 1 在之后就是从库里面把影片剪辑拖到舞台上 在之后在第 2 3 帧上面插入关键帧 在第一帧动作里面 写上 var i i 1 在第 2 帧上面写上 duplicateMovieClip CC CC i i m this CC i m x random 550 m y random 450 m alpha random 80 20 i i 1 if i 50 i 10 第 3 贞上面写上 gotoAndPlay 2 11 下雪 一帧代码 无需其他操作 function addMasker root createEmptyMovieClip masker 2 with masker lineStyle 1 13421772 100 beginFill 0 100 moveTo sideDisWidth sideDisHeight lineTo sideDisWidth sceneWidth sideDisHeight lineTo sideDisWidth sceneWidth sideDisHeight sceneHeight lineTo sideDisWidth sideDisHeight sceneHeight endFill End of with createSnow End of the function function createSnow var l1 0 while l1 snow x snow x sideDisWidth sceneWidth end if if sideDisWidth sceneWidth snow x snow x sideDisWidth end if if sideDisHeight sceneHeight 500 this clear this onEnterFrame undefined this removeMovieClip work play caput function path this path createEmptyMovieClip play caput 2000 tellTarget this path play caput lineStyle 0 25 0 x000000 100 beginFill 0 x000000 100 moveTo 0 10 curveTo 10 8 10 0 curveTo 8 10 0 10 curveTo 10 8 10 0 curveTo 8 10 0 10 work play1 run function x y xscale yscale this createEmptyMovieClip play1 run 1000 work play caput play1 run play1 run xscale xscale play1 run yscale yscale play1 run x x play1 run y y tellTarget play1 run play caput xscale 65 play caput yscale 65 play time 0 this play1 run onEnterFrame function this play time tellTarget this if play time 1 clear play caput x 17 play caput y 5 lineStyle 3 0 x000000 100 moveTo 15 10 lineTo 7 15 lineTo 2 22 moveTo 15 10 lineTo 20 17 lineTo 28 17 moveTo 15 10 lineTo 12 20 lineTo 12 28 moveTo 12 28 lineTo 7 40 lineTo 0 45 lineTo 3 48 moveTo 12 28 lineTo 20 35 lineTo 15 40 lineTo 16 42 else if play time 3 clear play caput x 23 play caput y 5 lineStyle 3 0 x000000 100 moveTo 21 11 lineTo 10 14 lineTo 5 20 moveTo 21 11 lineTo 27 18 lineTo 35 15 moveTo 21 11 lineTo 18 20 lineTo 16 30 moveTo 16 30 lineTo 10 35 lineTo 1 40 lineTo 0 43 moveTo 16 30 lineTo 22 33 lineTo 27 41 lineTo 30 43 else if play time 5 clear play caput x 25 play caput y 5 lineStyle 3 0 x000000 100 moveTo 22 11 lineTo 10 16 lineTo 8 24 moveTo 22 11 lineTo 25 20 lineTo 32 18 moveTo 22 11 lineTo 18 21 lineTo 18 30 moveTo 18 30 lineTo 10 35 lineTo 2 35 lineTo 0 36 moveTo 18 30 lineTo 22 36 lineTo 25 47 lineTo 30 47 else if play time 7 clear play caput x 18 play caput y 6 lineStyle 3 0 x000000 100 moveTo 15 11 lineTo 13 18 lineTo 16 20 moveTo 15 11 lineTo 11 18 lineTo 14 25 moveTo 15 11 lineTo 12 20 lineTo 11 25 moveTo 11 25 lineTo 16 36 lineTo 9 36 lineTo 10 38 moveTo 11 25 lineTo 12 35 lineTo 10 45 lineTo 13 45 else if play time 8 play time 0 work play2 arise function this createEmptyMovieClip play2 arise 2000 work play caput play2 arise tellTarget play2 arise play caput x 2 play caput y 20 lineStyle 4 0 x000000 100 moveTo 7 5 lineTo 6 7 moveTo 4 9 lineTo 5 3 moveTo 1 11 lineTo 0 10 moveTo 0 10 lineTo 1 23 lineTo 3 35 lineTo 2 35 moveTo 0 10 lineTo 6 21 lineTo 4 29 lineTo 1 33 player run function clear lineStyle 5 0 x000000 100 moveTo sx sy lineTo zs1x zs1y lineTo zs2x zs2y moveTo sx sy lineTo ys1x ys1y lineTo ys2x ys2y moveTo sx sy lineTo st1x st1y lineTo st2x st2y moveTo st2x st2y lineTo zj1x zj1y lineTo zj2x zj2y lineTo zj3x zj3y moveTo st2x st2y lineTo yj1x yj1y lineTo yj2x yj2y lineTo yj3x yj3y setProperty tou2 x toux2 setProperty tou2 y touy2 lineStyle 5 0 x930093 100 moveTo sx2 sy2 lineTo zs1x2 zs1y2 lineTo zs2x2 zs2y2 moveTo sx2 sy2 lineTo ys1x2 ys1y2 lineTo ys2x2 ys2y2 moveTo sx2 sy2 lineTo st1x2 st1y2 lineTo st2x2 st2y2 moveTo st2x2 st2y2 lineTo zj1x2 zj1y2 lineTo zj2x2 zj2y2 lineTo zj3x2 zj3y2 moveTo st2x2 st2y2 lineTo yj1x2 yj1y2 lineTo yj2x2 yj2y2 lineTo yj3x2 yj3y2 new load data tree play time 0 tree NO 0 play time 0 work play caput play caput visible false start play trees play function 每当播放速度值达到 15 时 复制一棵树 if tree play time 15 随机产生每一棵树的大小及移动的速度 speed time int random 50 30 制造树 work tree tree NO speed time tree NO tree play time 0 tree play time this onEnterFrame function play time 放置人物 1 跑动 if play time 1 work play1 run 319 94 150 150 树移动 trees play 课件制作 一 封面上制作一个按钮 an 实例名 按下播放 an01 addEventListener MouseEvent CLICK f1 gotoAndStopframe function f1 gotoAndStopframe event MouseEvent void play 二 剪辑上放播放 停止按钮 bf tz 剪辑 mc import flash events MouseEvent bf addEventListener MouseEvent CLICK bf function bf event MouseEvent void mc play tz addEventListener MouseEvent CLICK tz function tz event MouseEvent void mc stop 三 画面上设置上一步 下一步按钮使课件返回或前进 xyb syb syb addEventListener MouseEvent CLICK fl ClickToGoToPreviousFrame function fl ClickToGoToPreviousFrame event MouseEvent void prevFrame 单击以转到下一帧并停止 单击指定的元件实例会将播放头移动到下一帧并停止此影片 xyb addEventListener MouseEvent CLICK fl ClickToGoToNextFrame function fl ClickToGoToNextFrame event MouseEvent void nextFrame 四 点击到剪辑的哪一帖放 an mc an addEventListener MouseEvent CLICK fl ClickToGoToAndStopAtFrame m function fl ClickToGoToAndStopAtFrame m event MouseEvent void mc gotoAndStop 2 五 import flash events MouseEvent 单击以转到帧并停止 单击指定的元件实例会将播放头移动到时间轴中的指定帧并停止影片 可在主时间轴或影片剪辑时间轴上使用 说明 1 单击元件实例时 用希望播放头移动到的帧编号替换以下代码中的数字 5 an5 addEventListener MouseEvent CLICK fl ClickToGoToAndStopAtFrame a function fl ClickToGoToAndStopAtFrame a event MouseEvent void sm play sm x 80 sm y 40 sm scaleX 0 8 sm scaleY 0 8 ps alpha 0 hz alpha 0 an7 alpha 0 an8 alpha 0 an5 x 650 15 an5 y 469 40 an6 x 702 3 an6 y 469 4 an6 addEventListener MouseEvent CLICK f1 ClickToGoToAndStopAtFrame b function f1 ClickToGoToAndStopAtFrame b event MouseEvent void sm stop sm x 30 sm y 141 55 sm scaleX sm scaleY 0 45 ps alpha 1 hz alpha 1 an7 alpha 1 an8 alpha 1 an5 x 290 35 an5 y 364 75 an6 x 342 5 an6 y 364 75 an7 addEventListener MouseEvent CLICK fl ClickToGoToAndStopAtFrame c function fl ClickToGoToAndStopAtFrame c event MouseEvent void ps play ps x 80 ps y 40 ps scaleX 0 8 ps scaleY 0 8 sm alpha 0 hz alpha 0 an5 alpha 0 an6 alpha 0 an7 x 650 15 an7 y 469 40 an8 x 702 3 an8 y 469 4 an8 addEventListener MouseEvent CLICK

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论