
学号:20119195
作品名称:图片浏览器
部件功能介绍:
1、播放按钮——第一次点击,缓冲显示,加载到100%时,关闭缓冲,和广告,播放音乐,图片。
后面的点击就是播放音乐和图片没关闭暂停弹出的广告;
2、暂停按钮——弹出广告,停止播放音乐和图片;
3、声音控制按钮——调节大小;
代码:
package
{
import flash.display.MovieClip;
import flash.media.SoundTransform;
import flash.display.Sprite;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.utils.Timer;
import flash.text.TextField;
import flash.net.*;
//载入声音 控制声音
public class SoundControl extends Sprite
{
private var url:String = "5.mp3";
private var mysound:Sound;
private var song:SoundChannel;
private var po:Number = 0;
private var sj:Timer = new Timer(1000);
private var xsj:TextField = new TextField ;
public function SoundControl()
{
sj.start();
var request:URLRequest = new URLRequest(url);
mysound = new Sound ;
mysound.load(request);
btn_play.addEventListener(MouseEvent.CLICK,playsound);
btn_zt.addEventListener(MouseEvent.CLICK,ztsound);
slider.addEventListener(Event.CHANGE,changeVolue);
lo.addEventListener(MouseEvent.CLICK,link);
zz.addEventListener(Event.ENTER_FRAME,gd);
}
function gd(e:Event){
zz.x=mouseX;
zz.y=mouseY;
}
var g:int = 0;
var b:int = 1;
function xh(the:TimerEvent)//用时间调用它播放
{
g++;
if(s1==0){
if (g == 5)
{
a_mc.gotoAndPlay(1);
g = 1;
}
else
{
a_mc.nextFrame();
}
}
}
private function changeVolue(evt:Event):void
{
var trans:SoundTransform = new SoundTransform ;
trans.volume = evt.target.value;
song.soundTransform = trans;
}
var q:Number = 0;
var w:Number = 0;
private function playsound(event:MouseEvent):void//播放
{
s1=0;
cs++;
if (cs == 1)
{
sj.addEventListener(TimerEvent.TIMER,sjfun);
addChild(xsj);
}
else
{
song = mysound.play(po);
removeChild(lo);
sj.addEventListener(TimerEvent.TIMER,xh);
}
q++;
if (q == 1)
{
w = 0;
}
}
private function ztsound(event:MouseEvent):void
{
w++;
po = song.position;
song.stop();
s1=1;
if (w == 1)
{
addChild(lo);
q = 0;
}
}
var time:Number = 0;
var s:Number = 0;
var s1:Number = 0;
var cs:Number = 0;
function sjfun(the:TimerEvent):void
{
time++;
s = time;
if (s > 1500)
{
s = 1500;
}
xsj.text = String("已加载了" + time * 10 + "%");
if (time == 11)
{
sj.addEventListener(TimerEvent.TIMER,xh);//第一次调用相册
removeChild(xsj);
removeChild(lo);
song = mysound.play(po);
}
xsj.x = 600;
xsj.y = 100;
}
public function link(et:MouseEvent) {
var url:URLRequest=new URLRequest("http://www.baihe.com");
navigateToURL(url);
}
}
}
