柳暗花明笔记

    文件加载完后自动循环播放mp3的as3代码

    所属分类:[ php&web ] 猫哲学家 发表于:2012-07-25 15:19 浏览:594

    package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.text.TextField;

    public class playmp3 extends Sprite
    {

    public var req:URLRequest = new URLRequest("mp3/01.mp3");
    public var s:Sound = new Sound(req);
    public var s1:Sound = new Sound();

    public function playmp3()
    {
    //自动播放
    s.addEventListener(Event.COMPLETE, playp);
    var req:URLRequest = new URLRequest("mp3/02.mp3");
    s1.load(req);

    var but:Sprite = new Sprite();
    but.x = 100;
    but.y = 50;
    var tex:TextField = new TextField();
    tex.htmlText = 'play';

    var stopmp3:TextField = new TextField();
    stopmp3.htmlText = 'stop';

    but.addChild(tex);
    but.addChild(stopmp3);

    tex.addEventListener(MouseEvent.CLICK,playp);
    tex.addEventListener(MouseEvent.CLICK,playp);
    stopmp3.addEventListener(MouseEvent.CLICK,stopmp3);
    addChild(but);
    }
    public function playp(e:Event):void{

    s.play(0,3);
    }
    public function stopmp3(e:Event):void{
    channel.stop();
    }
    }
    }


    上一编文章 中国省份重新划分,可能是谣言 下一编文章 Apache 基于现一个IP的多个域名的配置
    最近文章
    发表评论