[知识点]
1、全屏与帧速设置stage.displayState="fullScreen";stage.frameRate=24;
2、右键设置ContextMenu
3、新增画线工具,在指定范围内画线graphics.moveTo(),graphics.lineTo()
4、 按钮文字说明跟踪 鼠标缓冲移动Tween
5、新增倒计时Timer
6、新增背景音乐音量控制soundTransform
[ 效果]
index0.swf
[代码]
1、全屏与帧速设置stage.displayState="fullScreen";stage.frameRate=24;
2、右键设置ContextMenu
3、新增画线工具,在指定范围内画线graphics.moveTo(),graphics.lineTo()
4、 按钮文字说明跟踪 鼠标缓冲移动Tween
5、新增倒计时Timer
6、新增背景音乐音量控制soundTransform
[ 效果]
index0.swf
[代码]
- //舞台设置
- stage.displayState="fullScreen";
- stage.frameRate=24;
- //右键设置
- var myContextMenu:ContextMenu = new ContextMenu();
- removeDefaultItems();
- addCustomMenuItems();
- this.contextMenu = myContextMenu;
- function removeDefaultItems():void {
- myContextMenu.hideBuiltInItems();
- var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
- }
- function addCustomMenuItems():void {
- var zuozhe:ContextMenuItem = new ContextMenuItem("制作:刘常");
- myContextMenu.customItems.push(zuozhe);
- var wangzhi:ContextMenuItem = new ContextMenuItem("琴者工作室qzgzs.51.net",true);
- myContextMenu.customItems.push(wangzhi);
- var emaile:ContextMenuItem = new ContextMenuItem("邮箱liu888chang@126.com",true);
- myContextMenu.customItems.push(emaile);
- var dizhi:ContextMenuItem = new ContextMenuItem("湖北省荆州市公安县埠河中学",true);
- myContextMenu.customItems.push(dizhi);
- var _close:ContextMenuItem = new ContextMenuItem("关闭",true);
- myContextMenu.customItems.push(_close);
- wangzhi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, wz);
- _close.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, gb);
- }
- function wz(event:ContextMenuEvent):void {
- var url:URLRequest=new URLRequest("http://qzgzs.51.net");
- navigateToURL(url,"_blank");
- }
- function gb(event:ContextMenuEvent):void {
- fscommand("quit");
- }
- //画线
- var fw:Sprite = new Sprite(
); - var xian:Sprite = new Sprite( );
- addChild(fw);
- fw.addChild(xian);
- fw.graphics.beginFill(0x000000,0);
- fw.graphics.drawRect(0, 30, 800, 540);
- fw.graphics.endFill();
- fw.addEventListener(MouseEvent.MOUSE_DOWN, ax);
- function ax(event:MouseEvent):void {
- xian.graphics.lineStyle(4,0xFF0000);
- xian.graphics.moveTo(mouseX, mouseY);
- fw.addEventListener(MouseEvent.MOUSE_MOVE, yd);
- }
- stage.addEventListener(MouseEvent.MOUSE_UP, sk);
- function sk(event:MouseEvent):void {
- fw.removeEventListener(MouseEvent.MOUSE_MOVE, yd);
- }
- function yd(event:MouseEvent):void {
- xian.graphics.lineTo(mouseX, mouseY);
- }
- //按钮文字说明
- var btnname:Array=["最前","最后","后退","播放","音乐","音乐","清除","帮助","教案","退出"];
- for (var k:uint=1; k<btnname.length+1; k++) {
- this["_btn" + k].addEventListener(MouseEvent.MOUSE_MOVE,btnjg);
- this["_btn" + k].addEventListener(MouseEvent.MOUSE_OUT,btnyc);
- btn_txt.y=this["_btn" + k].y-18;
- btn_txt.visible=false;
- }
- import fl.transitions.*;
- import fl.transitions.easing.*;
- var myTween:Tween;
- function btnjg(event:MouseEvent):void {
- var btn_xh:uint=event.currentTarget.name.split("_btn").join("");
- btn_txt.visible=true;
- myTween=new Tween(btn_txt,"x", Back.easeOut,btn_txt.x,event.currentTarget.x,0.5,true);
- btn_txt.txt.text=btnname[btn_xh-1];
- }
- function btnyc(event:MouseEvent):void {
- btn_txt.visible=false;
- myTween.stop();
- }
- var js:Timer=new Timer(1000,2700);
- var swf:Array=["1.swf","2.swf","3.swf","4.swf","5.swf"];
- var jishu:uint=0;
- var url:URLRequest=new URLRequest(swf[jishu]);
- var ldr:Loader=new Loader();
- ldr.load(url);
- ldr.mask = zezao;
- addChild(ldr);
- js_mc.js_txt.text="45:00";
- //背景音乐控制
- var _sound:Sound=new Sound();
- var surl:URLRequest=new URLRequest("bjsound.mp3");
- var scz:SoundChannel=new SoundChannel();
- _sound.load(surl);
- scz=_sound.play();
- var yl:Number=0.5;
- var syl:SoundTransform. = scz.soundTransform;
- syl.volume =yl;
- scz.soundTransform. =syl;
- _btn1.enabled=_btn3.enabled=false;
- stage.addEventListener(Event.ENTER_FRAME,gx);
- function gx(event:Event):void {
- if (jishu==0) {
-
_btn5.visible=false; -
_btn6.visible=true; -
_btn1.enabled=_btn3.enabled=false;
-
_btn2.enabled=_btn4.enabled=true;
-
_btn2.addEventListener(MouseEvent.CLICK,dj2);
-
_btn4.addEventListener(MouseEvent.CLICK,dj4);
-
_btn1.removeEventListener(MouseEvent.CLICK,dj1);
-
_btn3.removeEventListener(MouseEvent.CLICK,dj3);
- }
- if (jishu==swf.length-1) {
-
_btn5.visible=false; -
_btn6.visible=true; -
_btn1.enabled=_btn3.enabled=true;
-
_btn2.enabled=_btn4.enabled=false;
-
_btn1.addEventListener(MouseEvent.CLICK,dj1);
-
_btn3.addEventListener(MouseEvent.CLICK,dj3);
-
_btn2.removeEventListener(MouseEvent.CLICK,dj2);
-
_btn4.removeEventListener(MouseEvent.CLICK,dj4);
- }
- if (jishu<(swf.length-1)&&jishu>0) {
-
_btn5.visible=true; -
_btn6.visible=false; -
_btn1.enabled=_btn3.enabled=true;
-
_btn2.enabled=_btn4.enabled=true;
-
_btn1.addEventListener(MouseEvent.CLICK,dj1);
-
_btn3.addEventListener(MouseEvent.CLICK,dj3);
-
_btn2.addEventListener(MouseEvent.CLICK,dj2);
-
_btn4.addEventListener(MouseEvent.CLICK,dj4);
-
scz.stop(); - }
- yl=(ylhk_mc.x-390)/100;
- ylt_mc.scaleX=yl;
- syl.volume =yl;
- scz.soundTransform. =syl;
- }
- //结尾
- function dj2(event:MouseEvent):void {
- xian.graphics.clear();
- jishu=swf.length-1;
- url=new URLRequest(swf[jishu]);
- ldr.load(url);
- scz.stop();
- scz=_sound.play();
- }
- //向前
- function dj4(event:MouseEvent):void {
- xian.graphics.clear();
- jishu++;
- url=new URLRequest(swf[jishu]);
- ldr.load(url);
- scz.stop();
- if (jishu==swf.length-1) {
-
scz=_sound.play(); - }
- }
- //开始
- function dj1(event:MouseEvent):void {
- xian.graphics.clear();
- js_mc.js_txt.text="45:00";
- jishu=0;
- url=new URLRequest(swf[jishu]);
- ldr.load(url);
- scz.stop();
- scz=_sound.play();
- js.stop();
- js=new Timer(1000,2700);
- }
- //后退
- function dj3(event:MouseEvent):void {
- xian.graphics.clear();
- jishu--;
- url=new URLRequest(swf[jishu]);
- ldr.load(url);
- scz.stop();
- if (jishu==0) {
-
scz=_sound.play(); -
js.stop(); -
js=new Timer(1000,2700); -
js_mc.js_txt.text="45:00";
- }
- }
- //清除线条
- _btn7.addEventListener(MouseEvent.CLICK,dj7);
- function dj7(event:MouseEvent):void {
- xian.graphics.clear();
- }
- //背景音乐控制及倒计时
- var xkls:Sound=new Sound();
- var xklsurl:URLRequest=new URLRequest("xkls.mp3");
- var xklscz:SoundChannel=new SoundChannel();
- xkls.load(xklsurl);
- xklscz.stop();
- _btn6.addEventListener(MouseEvent.CLICK,dj6);
- function dj6(event:MouseEvent):void {
- scz.stop();
- //倒计时
- js.stop();
- js=new Timer(1000,2700);
- js.addEventListener(TimerEvent.TIMER,djs);
- js.addEventListener(TimerEvent.TIMER_COMPLETE,jswc);
- js.start();
- function djs(event:TimerEvent):void {
-
var jss:uint=2700-event.target.currentCount; -
var fen:String=""+int(jss/60); -
var miao:String=""+int(jss`); -
if (fen.length<2) { -
fen="0"+fen; -
} -
if (miao.length<2) { -
miao="0"+miao; -
} -
js_mc.js_txt.text=fen+":"+miao;
- }
- function jswc(event:TimerEvent):void {
-
js.stop(); -
js_mc.js_txt.text="END"; -
xklscz=xkls.play(); - }
- }
- _btn5.addEventListener(MouseEvent.CLICK,dj5);
- function dj5(event:MouseEvent):void {
- js_mc.js_txt.text="45:00";
- scz.stop();
- scz=_sound.play();
- js.stop();
- js=new Timer(1000,2700);
- }
- _btn10.addEventListener(MouseEvent.CLICK,tc);
- function tc(event:MouseEvent):void {
- fscommand("quit");
- }
- //音量滑块拖动控制
- var tdfw:Rectangle=new Rectangle(390,586,100,0);//拖动范围
- ylhk_mc.addEventListener(MouseEvent.MOUSE_DOWN,ylhkax);
- ylhk_mc.addEventListener(MouseEvent.MOUSE_UP,ylhksk);
- ylhk_mc.buttonMode=true;
- stage.addEventListener(MouseEvent.MOUSE_UP,ylhksk);
- function ylhkax(event:MouseEvent):void {
- ylhk_mc.startDrag(false,tdfw);
- }
- function ylhksk(event:MouseEvent):void {
- ylhk_mc.stopDrag();
- }