zoukankan      html  css  js  c++  java
  • 加载声音

    private var sound:Sound;

    private var soundChannel:SoundChannel;

    private var soundTrans:SoundTransform;

    private function playMusic():void

    {

    sound = new Sound(new URLRequest("resource/music/wangfei.mp3"));//resouce文件夹和SWF文件同级都在bin-debug文件夹中

    //*只有在未将有效的 URLRequest 对象传递到 Sound 构造函数或传递了 null 值的情况下,才需要自己调用 Sound.load()。 这时通过load(new URLRequest("resource/music/wangfei.mp3"))来达到上句代码的功能。

    soundChannel = sound.play();

    //Sound类的play()方法的返回类型规定为SoundChannel类,那这里就生成一个SoundChannel对象来回放该声音

    soundTrans = soundChannel.soundTransform;

    soundTrans.volume = o.5//这句设置音量,不写也行,音量范围是0~1,默认为1;

    soundChannel.soundTransform = soundTrans;

    要停掉声音通过soundchannel

    if(!bgMusic)
    {
    bgMusic = new BGMusicSound();
    channel = new SoundCHanner();
    }

    chanle = bgMUsic.play();

    channel.stop();

  • 相关阅读:
    Mybatis入门
    java开发七大原则
    常用的一些实用类
    sql语句大全
    jsp中9个隐含对象
    解决POST和GET方式的中文乱码问题
    Servlet跳转页面的重定向和转发
    通用增删改查的方式
    IDEA 部署spring Cloud
    Oracle基础语法
  • 原文地址:https://www.cnblogs.com/kuailezoe/p/2749942.html
Copyright © 2011-2022 走看看