2011年1月11日

Sounds类 外部调用音乐示例有三个音乐sound/musicNum 可以控制声音大小

摘要: package { import flash.display.*; import flash.media.*; //import fl.controls.*; import fl.events.*; //import fl.controls.*; import flash.events.*; import flash.net.*; import flash.text.*; import flash.ui.*; public class Sounds extends Sprite { private var soundChannel:SoundChannel; private var _soun 阅读全文
posted @ 2011-01-11 16:56 602147629 阅读(314) 评论(0) 推荐(0) 编辑

保存数据到本地

摘要: var topNum:int;var topList:Array;//提交成绩function submitScore():void{ if (_txt.text != "") { readScore(); var newRecord:Object = {player:_txt.text,score:Number(_txt1.text)}; topList.push(newRecord); topList.sortOn("score",Array.NUMERIC|Array.DESCENDING); saveScore(); }}//保存排行榜funct 阅读全文
posted @ 2011-01-11 16:50 602147629 阅读(260) 评论(0) 推荐(0) 编辑
2011年1月10日

运用递归随机出与上一个数不重复的数

摘要: var count:int=0;var randomNum:int;function recursion():void{ randomNum = Math.round(Math.random() * 2 + 1); if (count != randomNum) { count = randomNum; } else { recursion(); }} 阅读全文
posted @ 2011-01-10 17:42 602147629 阅读(165) 评论(0) 推荐(0) 编辑
2011年1月7日

flash全屏代码

摘要: //打开就全屏Stage.focus设置焦点fscommand("fullscreen","true");//关闭代码fscommand("quit");//或者添加右键菜单控制:var myMenu:ContextMenu = new ContextMenu();myMenu.hideBuiltInItems();var item:ContextMenuItem = new ContextMenuItem("全屏");myMenu.customItems.push(item);function fullScree 阅读全文
posted @ 2011-01-07 19:10 602147629 阅读(1902) 评论(0) 推荐(0) 编辑
2011年1月6日

键盘按下 子弹射击 (有间隔)

摘要: /*文档类*/package { import flash.display.Sprite; import flash.events.KeyboardEvent; import flash.events.Event; import flash.ui.Keyboard; public class Main extends Sprite { private var flag:Boolean = true; private var bulletArr:Array = new Array ; private var bullet:Bullet; private var time:int; public 阅读全文
posted @ 2011-01-06 16:19 602147629 阅读(256) 评论(0) 推荐(0) 编辑

画图

摘要: import flash.display.Shape;var shape:Shape = new Shape ;shape.graphics.lineStyle(1,0,1);shape.graphics.beginFill(0xff0000);//填充;shape.graphics.moveTo(-50,-25);shape.graphics.lineTo(0,-25);shape.graphics.lineTo(0,-50);shape.graphics.lineTo(50,0);shape.graphics.lineTo(0,50);shape.graphics.lineTo(0,25) 阅读全文
posted @ 2011-01-06 11:23 602147629 阅读(182) 评论(0) 推荐(0) 编辑

物体跟随鼠标移动并旋转角度

摘要: /*库中有元件Ball标识为Ball假如想让物体以每帧3像素的速度向45度的位置移动,这里要用到三角学。 已知角度为45度,斜边长为3像素,就可以应用 Math.cos 和 Math.sin 求出 vx 和 vy 的长度。角的邻边长度为 vx,因为角的余弦值等于邻边/斜边。也可以说,邻边等于角的余弦值乘以斜边。同样,对边长为 vy 的边,因为角的正弦值等于对边/斜边,或是对边等于正弦乘以斜边。实际应用的代码:vx = Math.cos(angle) * speed; vy = Math.sin(angle) * speed; */package { import flash.display.S 阅读全文
posted @ 2011-01-06 11:05 602147629 阅读(502) 评论(0) 推荐(0) 编辑

getBounds

摘要: /*用法:目标显示对象.getBounds(参照显示对象)//返回一个矩形显示对象区域A(x,y,width,height),这个A就是目标显示对象的显示区域;宽度,高度就没啥好说的了,就是这个A的宽和高;坐标x,y为参照显示对象在A的左上角的坐标值(属于本地坐标);如果要获得全局坐标参照显示对象应为root。*/ var container:Sprite = new Sprite();container.x = 150;container.y = 150;container.graphics.beginFill(0xfff000);container.graphics.drawCircle( 阅读全文
posted @ 2011-01-06 10:36 602147629 阅读(719) 评论(0) 推荐(0) 编辑

调用库中的位图图片

摘要: /*库中有个图片 类定义为Image使用getDefinitionByName掉用库中的元件,生成指定的库元件实例,这样的代码在其他的IDE中也能够很好的使用*/import flash.display.Bitmap;import flash.display.BitmapData;var Image:String = "Image";var image:Class = getDefinitionByName(Image) as Class;var bitmapData:BitmapData = new image() as BitmapData;var headBitmap 阅读全文
posted @ 2011-01-06 10:19 602147629 阅读(262) 评论(0) 推荐(0) 编辑
2010年12月30日

标签跟随鼠标移动

摘要: /*建mc1放在舞台 mc2放在库中*/import flash.events.MouseEvent;var mc2:Mc2;mc1.addEventListener(MouseEvent.ROLL_OVER,mc1OverHandler);mc1.addEventListener(MouseEvent.ROLL_OUT,mc1OutHandler);function mc1OverHandler(e:MouseEvent):void{ mc2 = new Mc2 ; mc2.x = mouseX; mc2.y = mouseY; addChild(mc2); stage.addEventLi 阅读全文
posted @ 2010-12-30 16:57 602147629 阅读(231) 评论(0) 推荐(0) 编辑