• Flex 笔记之—音乐控制(SoundChannel, SoundTransform, volume)


    //首先将一个mp3导入了库中,给声音文件设置了music类
    //
    在场景中建立3个按钮buttonplay,Continuebotton,stopbotton
    var musicstar:SoundChannel=new SoundChannel();
    var StopPlayPosition:Number;//停止播放的位置
    var soundLoopPlay:Boolean=true;//是否循环播放
    var soundTF:SoundTransform = new SoundTransform();//控制声音的音量
    var music_play:music = new music();

    soundTF.volume = 0.5;//控制声音的音量现在是原来音量的一半
    musicstar.soundTransform = soundTF;
    stopbotton.visible=true;
    Continuebotton.visible=false;
    function playLoop():void {

    if (soundLoopPlay) {//循环播放
    musicstar = music_play.play();
    musicstar.addEventListener(Event.SOUND_COMPLETE, onSoundPlay);
    } else {
    musicstar = music_play.play();
    }

    }
    function onSoundPlay(evt:Event):void {
    musicstar.stop();//停止播放
    playLoop();
    }

    buttonplay.addEventListener(MouseEvent.CLICK,PLAY_1);

    function PLAY_1(e:MouseEvent):void {
    stopbotton.visible=true;
    Continuebotton.visible=false;
    musicstar.stop();
    playLoop();
    }

    stopbotton.addEventListener(MouseEvent.CLICK,STOP_1);

    function STOP_1(e:MouseEvent):void {
    stopbotton.visible=false;
    Continuebotton.visible=true;
    StopPlayPosition=musicstar.position;
    musicstar.stop();
    }

    Continuebotton.addEventListener(MouseEvent.CLICK,Continue_1);

    function Continue_1(e:MouseEvent):void {
    stopbotton.visible=true;
    Continuebotton.visible=false;
    musicstar=music_play.play(StopPlayPosition);
    musicstar.addEventListener(Event.SOUND_COMPLETE, onSoundPlay);
    }
  • 相关阅读:
    数据库的数据同步
    IDEA连接数据库自动生成实体类
    异常日记(一)
    高16位,低16位是什么
    springboot整合rabbitmq
    springBoot使用教程
    分布式框架Dubbo入门
    Spring注解驱动开发04(给容器中注册组件的方式)
    Spring注解驱动开发03(按照条件注册bean)
    Spring注解驱动开发02(作用域和懒加载)
  • 原文地址:https://www.cnblogs.com/liangle/p/2512524.html
Copyright © 2020-2023  润新知