Flex mp3播放
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="myInit()">
<mx:Script>
<![CDATA[
import flash.events.*;
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.Timer;
import flash.events.TimerEvent;
import mx.controls.Alert;
//mp3 的 url 地址
private var soundURL:String = "asflex.mp3";
//访问 url 上的东西都用 URLRequest 了
private var request:URLRequest = new URLRequest(soundURL);
private var my_sound:Sound=new Sound(); // 新建 Sound 对象
//声明 SoundChannel 类型的变量 my_channel
private var my_channel:SoundChannel;
//新建 myTimer 对象并定义循环的时间间隔为10毫秒,循环次数为无限次(参数中的0表示无限次)
private var myTimer:Timer = new Timer(10, 0);
private function myInit():void{
my_sound.load(request); // 载入外部 mp3: She is my sin.mp3
}
//播放音乐:
private function playSound(): void{
Alert.show(my_sound.length.toString());
my_channel = my_sound.play(); // 音乐正式开始播放
//添加事件侦听器, 功能: 循环执行 timerHandler 函数(但这里还没有开始循环执行)
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.start(); // 这里才开始循环执行 timerHandler 函数
}
//停止音乐:
private function stopSound():void{
//停止对函数 timerHandler 的循环执行, 因为音乐开始时 myTimer 对象就对函数 timerHandler 循环执行了
myTimer.stop();
my_channel.stop(); // 正式停止音乐
progress_hs.value = 0; // 使那"播放进度"条的值回到0,即回到最左端
}
//定义被 myTimer 循环执行的函数 timerHandler
private
相关文档:
在Flex中,利用state进行状态和页面的迁移与变换,中间的AddChild IOverride有一个creationPolicy,这个属性有三种设置,分别如下:
AUTO:默认设置,只有在状态改变的时候,即时的生成新增组件;
ALL:在Application加载的时候,就加载了新增的组件,在状态改变的时候显示;
NONE:需要手动的调用该addChild Instance c ......
.treeStyte{
selectionColor: #417597;
/* 去掉默认图标 */
folderClosedIcon: ClassReference(null);
folderOpenIcon: ClassReference(null);
&nbs ......
--------web.xml文件
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
--------Java代码
public class GetSeesion {
/**
* 设置session
* */
public ......
Top 10 things new Flex developers should know
By Michael Portuesi | Published: November 27, 2009
While helping a coworker get started with Flash and Flex development, I thought it would be a good time to cover the list of things that I have found pretty essential to know about Flex development, co ......
DataGrid组件样式属性
backgroundColor 背景色
backgroundAlpha &nb ......