flex-mp3
Mp3Player.as
package ddw.adobe
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.Timer; import mx.controls.Alert;
import mx.events.FlexEvent; import org.osmf.events.TimeEvent; import spark.components.Label;
import spark.components.SkinnableContainer;
import spark.components.ToggleButton;
import spark.components.mediaClasses.ScrubBar;
import spark.components.mediaClasses.VolumeBar;
import spark.events.TrackBaseEvent; public class Mp3Player extends SkinnableContainer
{ /**
* 播放(暂停)按钮默认24×24
*/
public function Mp3Player()
{
super(); setStyle("skinClass", Class(ddw.adobe.Mp3PlayerSkin)); timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, handleTime);
} [SkinPart]
public var playPauseButton:ToggleButton;
[SkinPart]
public var scrubBar:ScrubBar;
[SkinPart]
public var currentTimeDisplay:Label;
[SkinPart]
public var durationDisplay:Label;
[SkinPart]
public var volumeBar:VolumeBar; override protected function partAdded(partName:String, instance:Object):void {
super.partAdded(partName, instance)
switch (instance){
case playPauseButton:
playPauseButton.addEventListener(MouseEvent.CLICK, playSound)
playPauseButton.selected = isPlaying;
break;
case scrubBar:
// add thumbPress and thumbRelease so we pause the video while dragging
scrubBar.addEventListener(TrackBaseEvent.THUMB_PRESS, scrubBar_thumbPressHandler);
scrubBar.addEventListener(TrackBaseEvent.THUMB_RELEASE, scrubBar_thumbReleaseHandler);
// add change to actually seek() when the change is complete
scrubBar.addEventListener(Event.CHANGE, scrubBar_changeHandler);
// add changeEnd and changeStart so we don't update the scrubbar's value
// while the scrubbar is moving around due to an animation
scrubBar.addEventListener(FlexEvent.CHANGE_END, scrubBar_changeEndHandler);
scrubBar.addEventListener(FlexEvent.CHANGE_START, scrubBar_changeStartHandler);
updateScrubBar();
break;
case volumeBar:
volumeBar.minimum = 0;
volumeBar.maximum = 1;
volumeBar.value = 1;
volumeBar.addEventListener(Event.CHANGE, volumeBar_changeHandler);
volumeBar.addEventListener(FlexEvent.MUTED_CHANGE, volumeBar_mutedChangeHandler);
volumeBar.value = volume
volumeBar.muted = muted;
break; }
} private var _autoPlay:Boolean = false; public function get autoPlay():Boolean
{
return _autoPlay;
} public function set autoPlay(value:Boolean):void
{
_autoPlay = value; if (_source && _autoPlay)play(); } private var _source:String; public function get source():String
{
return _source; } /**
* 修正更换地址时,如果修改当前地址,autoPlay=true;
* 如果第一次设置地址,那么autoPlay由设置决定;
* */
public function set source(value:String):void{
if(_source==value)return;
if(_source)
{
_source=null;
autoPlay=true;
}
_source = value;
if (_source)
loadSound();
if (autoPlay)
play();
} // ********************* PLAYBACK private var mySound:Sound;
private var myChannel:SoundChannel;
private var soundPosition:Number = 0;
private var isPlaying:Boolean = false;
private var timer:Timer; private function loadSound():void{
if (myChannel) myChannel.stop()
soundPosition = 0;
isPlaying = false;
timer.stop(); if (playPauseButton)
playPauseButton.selected = false mySound = new Sound()
mySound.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
mySound.addEventListener(ProgressEvent.PROGRESS, progressHandler); var request:URLRequest = new URLRequest(_source);
mySound.load(request) updateDisplay()
updateScrubBar()
} private function errorHandler(event:IOErrorEvent):void{
Alert.show(event.text, "Sound error");
} private function progressHandler(event:ProgressEvent):void{
updateDisplay()
updateScrubBar()
} private function updateScrubBar():void {
if (!scrubBar || !mySound) return; if (!scrubBarMouseCaptured && !scrubBarChanging){
scrubBar.minimum = 0;
scrubBar.maximum = mySound.length/1000;
scrubBar.value = soundPosition/1000
} if (mySound.bytesTotal == 0)
scrubBar.loadedRangeEnd = 0;
else
scrubBar.loadedRangeEnd = (mySound.bytesLoaded/mySound.bytesTotal)*scrubBar.maximum;
} private function updateDisplay():void{
if (currentTimeDisplay)
currentTimeDisplay.text = formatTimeValue(soundPosition/1000)
if (durationDisplay)
durationDisplay.text = formatTimeValue(mySound.length/1000);
} private function playSound(event:MouseEvent):void{
if (isPlaying){
pause();
if ((mySound.length-soundPosition)<500)
rewind();
}
else
play();
} public function play():void{
myChannel = mySound.play(soundPosition);
myChannel.addEventListener(Event.SOUND_COMPLETE,soundCompleteHandler)
volume = _volume;
muted = _muted; if (playPauseButton)
playPauseButton.selected = true
isPlaying = true timer.start()
} protected function soundCompleteHandler(event:Event):void
{
// TODO Auto-generated method stub
pause();
soundPosition = 0;
scrubBar.value = soundPosition/1000
updateDisplay();
} public function pause():void{
if (myChannel){
soundPosition = myChannel.position;
myChannel.stop();
}
if (playPauseButton)
playPauseButton.selected = false;
isPlaying = false; timer.stop();
} public function rewind():void{
soundPosition = 0;
updateScrubBar();
updateDisplay(); if (isPlaying){
myChannel.stop();
}
} public function seek(time:Number):void
{
soundPosition = time;
if (isPlaying){
myChannel.stop();
myChannel = mySound.play(soundPosition);
volume = _volume;
muted = _muted;
} } private function handleTime(event:TimerEvent):void{
if (!isPlaying) return;
soundPosition = myChannel.position;
updateDisplay();
updateScrubBar();
} protected function formatTimeValue(value:Number):String{
// default format: hours:minutes:seconds
value = Math.round(value); var hours:uint = Math.floor(value/3600) % 24;
var minutes:uint = Math.floor(value/60) % 60;
var seconds:uint = value % 60; var result:String = "";
if (hours != 0)
result = hours + ":"; if (result && minutes < 10)
result += "0" + minutes + ":";
else
result += minutes + ":"; if (seconds < 10)
result += "0" + seconds;
else
result += seconds; return result;
} // *************** SCRUBBAR /**
* @private
* When someone is holding the scrubBar, we don't want to update the
* range's value--for this time period, we'll let the user completely
* control the range.
*/
private var scrubBarMouseCaptured:Boolean; /**
* @private
* We pause the video when dragging the thumb for the scrub bar. This
* stores whether we were paused or not.
*/
private var wasPlayingBeforeSeeking:Boolean; /**
* @private
* We are in the process of changing the timestamp
*/
private var scrubBarChanging:Boolean; /**
* @private
*/
private function scrubBar_changeStartHandler(event:Event):void
{
scrubBarChanging = true;
} /**
* @private
*/
private function scrubBar_thumbPressHandler(event:TrackBaseEvent):void
{
scrubBarMouseCaptured = true;
if (isPlaying)
{
pause();
wasPlayingBeforeSeeking = true;
}
} /**
* @private
*/
private function scrubBar_thumbReleaseHandler(event:TrackBaseEvent):void
{
scrubBarMouseCaptured = false;
if (wasPlayingBeforeSeeking)
{
play();
wasPlayingBeforeSeeking = false;
}
} /**
* @private
*/
private function scrubBar_changeHandler(event:Event):void
{
seek(scrubBar.value * 1000);
} /**
* @private
*/
private function scrubBar_changeEndHandler(event:Event):void
{
scrubBarChanging = false;
} // ************************ VOLUME private var _volume:Number = 1; public function get volume():Number
{
return _volume;
} public function set volume(value:Number):void {
if (value<0 || value>1) return; _volume = value; if (volumeBar)
volumeBar.value = value; if(!myChannel)return;
var transform:SoundTransform = myChannel.soundTransform;
transform.volume = value;
myChannel.soundTransform = transform;
} private function volumeBar_changeHandler(event:Event):void
{
if (volume != volumeBar.value)
volume = volumeBar.value;
} private var _muted:Boolean = false; public function get muted():Boolean
{
return _muted;
} public function set muted(value:Boolean):void
{
_muted = value; if (volumeBar)
volumeBar.muted = value;
if(!myChannel)return;
var transform:SoundTransform = myChannel.soundTransform;
transform.volume = muted ? 0 : volume;
myChannel.soundTransform = transform;
} private function volumeBar_mutedChangeHandler(event:FlexEvent):void
{
if (muted != volumeBar.muted)
muted = volumeBar.muted;
} }
}
Mp3PlayerSkin.mxml
<?xml version="1.0" encoding="utf-8"?> <!---
Default skin for Mp3Player. It uses the same graphical assets as spark VideoPlayer. @see org.flashcommander.components.Mp3Player
--> <s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
alpha.disabledStates="0.5"
height="24" minWidth="100" > <fx:Metadata>
[HostComponent("ddw.adobe.Mp3Player")]
</fx:Metadata> <s:states>
<s:State name="normal" />
<s:State name="disabled" stateGroups="disabledStates" />
</s:states> <!--- @copy spark.components.VideoPlayer#playerControls -->
<s:Group bottom="0" top="0" left="0" right="0" id="playerControls"> <!--- @copy spark.components.VideoPlayer#playPauseButton默认大小24×24 -->
<s:ToggleButton id="playPauseButton" left="0" bottom="0"
skinClass="ddw.adobe.PlayPauseButtonSkin"
focusIn="event.target.depth=1" focusOut="event.target.depth=0" /> <!--把( scrubbar + the currentTime/duration labels) 组成一个group放在这个容器(Group)里-->
<s:Group left="25" right="38" top="0" bottom="0"> <!-- background for scrubbar + the currentTime/duration -->
<s:Rect left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF" />
<s:GradientEntry color="0xDCDCDC" />
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- fill highlight -->
<s:Rect left="1" right="1" top="1" height="11" >
<s:fill>
<s:SolidColor color="0xFFFFFF" alpha="0.3" />
</s:fill>
</s:Rect> <!-- one pixel border -->
<s:Rect left="1" right="1" top="1" bottom="1">
<s:stroke>
<s:LinearGradientStroke weight="1" rotation="90">
<s:GradientEntry color="0xFEFEFE" />
<s:GradientEntry color="0xEAEAEA" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect> <!-- border for the scrubbar/time label controls -->
<s:Rect left="-1" right="0" top="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="0x131313" />
</s:stroke>
</s:Rect> <!-- 按照水平方向布局scrubBar+currentTimeDisplay+timeDivider+durationDisplay -->
<!-- 按照垂直方向居中布局scrubBar+currentTimeDisplay+timeDivider+durationDisplay -->
<s:Group left="0" right="0" height="23" bottom="0">
<s:layout>
<s:HorizontalLayout verticalAlign="middle" gap="1" />
</s:layout> <!-- 左边留7个像素空间
<s:Rect width="7" height="11">
<s:fill>
<s:SolidColor color="0xFF0000" />
</s:fill>
</s:Rect>--> <!--- @copy spark.components.VideoPlayer#scrubBar -->
<s:ScrubBar id="scrubBar" width="100%" liveDragging="true"
skinClass="ddw.adobe.ScrubBarSkin" /> <!-- 右边留8个像素空间
<s:Rect width="8" height="1" />--> <!--- @copy spark.components.VideoPlayer#currentTimeDisplay -->
<s:Label id="currentTimeDisplay" /> <!--- @private -->
<s:Label id="timeDivider" text="/" /> <!--- @copy spark.components.VideoPlayer#durationDisplay -->
<s:Label id="durationDisplay" /> <!-- spacer -->
<s:Rect width="8" height="1" />
</s:Group> </s:Group> <!--- @copy spark.components.VideoPlayer#volumeBar -->
<s:VolumeBar id="volumeBar" snapInterval=".01" stepSize=".01" liveDragging="true"
right="0" bottom="0"
skinClass="spark.skins.spark.mediaClasses.normal.VolumeBarSkin"
focusIn="event.target.depth=1" focusOut="event.target.depth=0" /> </s:Group> </s:SparkSkin>
PlayPauseButtonSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
alpha.disabledStates="0.5"> <!-- host component -->
<fx:Metadata>
/**
* @copy spark.skins.spark.ApplicationSkin#hostComponent
*/
[HostComponent("spark.components.ToggleButton")]
</fx:Metadata> <fx:Script fb:purpose="styling">
/* Define the skin elements that should not be colorized. */
static private const exclusions:Array = ["playSymbol", "pauseSymbol"]; /**
* @private
*/
override public function get colorizeExclusions():Array {return exclusions;} /* Define the symbol fill items that should be colored by the "symbolColor" style.*/
static private const symbols:Array = ["playSymbolFill", "pauseSymbolFill1_1", "pauseSymbolFill1_2",
"pauseSymbolFill1_3", "pauseSymbolFill1_4", "pauseSymbolFill1_5",
"pauseSymbolFill2_1", "pauseSymbolFill2_2", "pauseSymbolFill2_3",
"pauseSymbolFill2_4", "pauseSymbolFill2_5"]; /**
* @private
*/
override public function get symbolItems():Array {return symbols}; /**
* @private
*/
override protected function initializationComplete():void
{
useChromeColor = true;
super.initializationComplete();
}
</fx:Script> <!-- states -->
<s:states>
<s:State name="up" />
<s:State name="over" stateGroups="overStates" />
<s:State name="down" stateGroups="downStates" />
<s:State name="disabled" stateGroups="disabledStates" />
<s:State name="upAndSelected" stateGroups="selectedStates, selectedUpStates" />
<s:State name="overAndSelected" stateGroups="overStates, selectedStates" />
<s:State name="downAndSelected" stateGroups="downStates, selectedStates" />
<s:State name="disabledAndSelected" stateGroups="selectedUpStates, disabledStates, selectedStates" />
</s:states> <!-- layer 1: 背景但不包括边框,边框为layer 5 left="0" right="0" top="0" bottom="0"-->
<s:Rect left="1" right="1" top="1" bottom="1">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF"
color.overStates="0xCACACA"
color.downStates="0xA8A8A8" />
<s:GradientEntry color="0xDCDCDC"
color.overStates="0x8D8D8D"
color.downStates="0x6B6B6B"/>
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- layer 2: 除了downStates状态外出现的一个像素的内边框 -->
<s:Rect left="1" right="1" top="1" bottom="1" excludeFrom="downStates">
<s:stroke>
<s:LinearGradientStroke weight="1" rotation="90">
<s:GradientEntry color="0xFEFEFE" alpha.overStates="0.22" />
<s:GradientEntry color="0xEAEAEA" alpha.overStates="0.22" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect> <!-- layer 3: 除了downStates状态外出现的上部高光 -->
<s:Rect left="1" right="1" top="1" height="11" excludeFrom="downStates">
<s:fill>
<s:SolidColor color="0xFFFFFF"
alpha="0.3"
alpha.overStates="0.12" />
</s:fill>
</s:Rect> <!-- layer 4:绘制 downStates状态下出现的内部凹陷 -->
<!--上边一个像素横线-->
<s:Rect left="1" top="1" right="1" height="1" includeIn="downStates">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.4" />
</s:fill>
</s:Rect>
<!--上边一个像素横线-->
<s:Rect left="1" top="2" right="1" height="1" includeIn="downStates">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<!--左边一个像素竖线-->
<s:Rect left="1" top="1" bottom="1" width="1" includeIn="downStates">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<!--右边一个像素竖线-->
<s:Rect right="1" top="1" bottom="1" width="1" includeIn="downStates">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect> <!-- layer 5: 整体边框,决定按钮默认大小 -->
<s:Rect left="0" right="0" top="0" bottom="0" width="24" height="24">
<s:stroke>
<s:SolidColorStroke color="0x131313" />
</s:stroke>
</s:Rect> <!--- 定义play 按钮.垂直居中及水平居中 -->
<s:Group horizontalCenter="0" verticalCenter="0" excludeFrom="selectedStates" id="playSymbol"> <!-- 三角形:evenOdd=奇偶缠绕类型,重叠不fill;nonZero=非零缠绕类型 ,同方向重叠填充,异方向重叠不填充-->
<s:Path winding="evenOdd" data="M 1 0 L 1 13 L 8 7 L 1 0 Z">
<s:fill>
<!--- @private -->
<s:SolidColor color="0x555555" alpha="0.75" id="playSymbolFill"/>
</s:fill>
</s:Path> <!-- triangle drop shadow on bottom/right -->
<s:Line xFrom="1" xTo="7" yFrom="0" yTo="7">
<s:stroke>
<s:SolidColorStroke color="0x000000" alpha="0.33" />
</s:stroke>
</s:Line> <!-- line on left of triangle -->
<s:Line x="0" yFrom="0" yTo="13">
<s:stroke>
<s:SolidColorStroke color="0x000000" alpha="0.5" />
</s:stroke>
</s:Line>
</s:Group> <!--- 定义 pause 按钮. -->
<s:Group horizontalCenter="0" verticalCenter="0" includeIn="selectedStates" id="pauseSymbol"> <!-- 左边竖线 -->
<s:Rect left="0" top="0" height="11" width="3">
<s:fill>
<s:LinearGradient rotation="90">
<!--- @private -->
<s:GradientEntry color="0x252525" alpha="0.75" ratio="0.1" id="pauseSymbolFill1_1"/>
<!--- @private -->
<s:GradientEntry color="0x404040" alpha="0.75" ratio="0.2" id="pauseSymbolFill1_2"/>
<!--- @private -->
<s:GradientEntry color="0x4B4B4B" alpha="0.75" ratio="0.55" id="pauseSymbolFill1_3"/>
<!--- @private -->
<s:GradientEntry color="0x424242" alpha="0.75" ratio="0.9" id="pauseSymbolFill1_4"/>
<!--- @private -->
<s:GradientEntry color="0xC4C4C4" alpha="0.75" ratio="1.0" id="pauseSymbolFill1_5"/>
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- 右边竖线(left(4)+width(3)决定了pauseSymbol的宽=7) -->
<s:Rect left="4" top="0" height="11" width="3">
<s:fill>
<s:LinearGradient rotation="90">
<!--- @private -->
<s:GradientEntry color="0x252525" alpha="0.75" ratio="0.1" id="pauseSymbolFill2_1"/>
<!--- @private -->
<s:GradientEntry color="0x404040" alpha="0.75" ratio="0.2" id="pauseSymbolFill2_2"/>
<!--- @private -->
<s:GradientEntry color="0x4B4B4B" alpha="0.75" ratio="0.55" id="pauseSymbolFill2_3"/>
<!--- @private -->
<s:GradientEntry color="0x424242" alpha="0.75" ratio="0.9" id="pauseSymbolFill2_4"/>
<!--- @private -->
<s:GradientEntry color="0xC4C4C4" alpha="0.75" ratio="1.0" id="pauseSymbolFill2_5"/>
</s:LinearGradient>
</s:fill>
</s:Rect> </s:Group>
</s:SparkSkin>
ScrubBarSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minHeight="14"
alpha.disabled="0.5">
<!--外观部件loadedRangeArea、playedArea不是继承Hslider,不参与自动布局-->
<!--thumb是继承Hslider不参与自动布局、track是继承Hslider参与自动布局-->
<!--通过updateSkinDisplayList()方法计算track、thumb的位置(依赖slider的value属性)来更新loadedRangeArea、playedArea-->
<fx:Metadata>
/**
* @copy spark.skins.spark.ApplicationSkin#hostComponent
*/
[HostComponent("spark.components.mediaClasses.ScrubBar")]
</fx:Metadata> <fx:Script fb:purpose="styling">
/* Define the skin elements that should not be colorized. */
static private const exclusions:Array = ["track", "thumb"]; /**
* @private
*/
override public function get colorizeExclusions():Array {return exclusions;} /**
* @private
*/
override protected function initializationComplete():void
{
useChromeColor = true;
super.initializationComplete();
}
</fx:Script> <s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states> <fx:Declarations>
<!--- Defines the appearance of the ScrubBar skin's data tip. To customize the data tip's appearance, create a custom ScrubBarSkin class. -->
<fx:Component id="dataTip">
<s:DataRenderer minHeight="24" minWidth="40" y="-34">
<s:RectangularDropShadow id="shadow" distance="3"
angle="90" color="#999999" left="0" top="0" right="0" bottom="0"/> <s:Rect top="0" left="0" right="0" bottom="0">
<s:fill>
<s:SolidColor color="0x000000" alpha=".9"/>
</s:fill>
</s:Rect> <s:Label id="labelDisplay" text="{data}"
horizontalCenter="0" verticalCenter="1"
left="5" right="5" top="5" bottom="5"
textAlign="center" verticalAlign="middle"
fontWeight="normal" color="white" fontSize="11">
</s:Label>
</s:DataRenderer>
</fx:Component>
</fx:Declarations> <!--- The skin pat that defines the video timeline. The timeline shows the current playhead location
in the video, the amount of the video previously played, and the loaded in part of the video. -->
<s:Button id="track" left="0" right="0" top="0" height="11"
skinClass="ddw.adobe.ScrubBarTrackSkin" /> <!--- @copy spark.components.mediaClasses.ScrubBar#loadedRangeArea父容器的布局不影响该对象 -->
<!---->
<s:Group id="loadedRangeArea" x="0" y="0" height="11" includeInLayout="false" alpha="0"> <!-- inset 7 and 6 pixels because that's thumbSize/2 -->
<s:Group left="7" right="6" top="0" bottom="0" minWidth="0"> <!-- fill0xD7D7D7 -->
<s:Rect left="1" right="1" top="1" bottom="1">
<s:fill>
<s:SolidColor color="0xff0000" />
</s:fill>
</s:Rect> <!-- inner glow -->
<!-- set height to 100%, maxHeight=1, minHeight=0 b/c only want this line to show up
if there's room for it -->
<s:Rect left="1" top="1" bottom="1" width="100%" maxWidth="1" minWidth="0">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<s:Rect left="2" right="1" top="1" height="100%" maxHeight="1" minHeight="0">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect> <!-- black line on right -->
<!-- set width to 100%, maxWidth=1, minWidth=0 b/c only want this line to show up
if there's room for it -->
<s:Rect right="0" top="1" bottom="1" width="100%" maxWidth="1" minWidth="0">
<s:fill>
<s:SolidColor color="0x000000" alpha=".5"/>
</s:fill>
</s:Rect> </s:Group>
</s:Group> <!--- @copy spark.components.mediaClasses.ScrubBar#playedArea父容器的布局不影响该对象 -->
<s:Group id="playedArea" x="0" y="0" height="11" includeInLayout="false" alpha="0"> <!-- inset 7 and 6 pixels because that's thumbSize/2 -->
<s:Group left="7" right="6" top="0" bottom="0" minWidth="0"> <!-- inner glow -->
<s:Rect left="1" right="1" top="1" bottom="1">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFEFEFE"/>
<s:GradientEntry color="0xECECEC"/>
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- fill -->
<s:Rect left="2" right="2" top="2" bottom="2">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF" alpha="0.85"/>
<s:GradientEntry color="0xE1E1E1" alpha="0.85"/>
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- black line on right -->
<!-- set width to 100%, maxWidth=1, minWidth=0 b/c only want this line to show up
if there's room for it -->
<s:Rect right="0" top="1" bottom="1" width="100%" maxWidth="1" minWidth="0">
<s:fill>
<s:SolidColor color="0x131313"/>
</s:fill>
</s:Rect> </s:Group>
</s:Group> <!--- A skin part that defines a button that can be dragged along the track to increase or decrease
the playhead location in the video.父容器的布局不影响该对象 -->
<s:Button id="thumb" x="0" y="0" width="14" height="19" includeInLayout="false"
skinClass="ddw.adobe.ScrubBarThumbSkin" /> </s:SparkSkin>
ScrubBarThumbSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"> <fx:Metadata>
/**
* @copy spark.skins.spark.ApplicationSkin#hostComponent
*/
[HostComponent("spark.components.Button")]
</fx:Metadata> <fx:Script fb:purpose="styling">
/**
* @private
*/
override protected function initializationComplete():void
{
useChromeColor = true;
super.initializationComplete();
}
</fx:Script> <s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states> <!-- black line on top -->
<s:Rect width="1" x="7" y="0" height="7">
<s:fill>
<s:SolidColor color="0x000000"/>
</s:fill>
</s:Rect> <!-- now the base shape of the component -->
<s:Group y="6"> <!-- drop shadow for shape -->
<s:Line xFrom="4" xTo="11" y="10">
<s:stroke>
<s:SolidColorStroke color="0x000000" alpha="0.12" />
</s:stroke>
</s:Line> <!-- shape border -->
<s:Path winding="evenOdd" data="M 4 2 L 4 10 L 11 10 L 11 3 L 10 3 L 10 2 L 9 2 L 9 1 L 6 1 L 6 2 L 5 2 L 5 3 L 4 3 L 4 2 Z">
<s:fill>
<s:SolidColor color="0x000000"/>
</s:fill>
</s:Path> <!-- shape fill -->
<s:Path winding="evenOdd" data="M 5 4 L 5 9 L 10 9 L 10 4 L 9 4 L 9 3 L 8 3 L 8 2 L 8 1 L 8 2 L 7 2 L 7 3 L 6 3 L 6 4 L 5 4 Z">
<s:fill>
<s:SolidColor color="0xFFFFFF"/>
</s:fill>
</s:Path> <!-- shape fill highlight -->
<s:Path winding="evenOdd" data="M 5 4 L 5 9 L 10 9 L 10 4 L 9 4 L 9 3 L 8 3 L 8 2 L 8 1 L 8 2 L 7 2 L 7 3 L 6 3 L 6 4 L 5 4 Z">
<s:fill>
<s:SolidColor color="0xFFFFFF" alpha="0.22"/>
</s:fill>
</s:Path> </s:Group> <!-- for sizing/hit-test only -->
<s:Rect width="13" height="19">
<s:fill>
<s:SolidColor color="0x000000" alpha="0" />
</s:fill>
</s:Rect> </s:SparkSkin>
ScrubBarTrackSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"> <fx:Metadata>
/**
* @copy spark.skins.spark.ApplicationSkin#hostComponent
*/
[HostComponent("spark.components.Button")]
</fx:Metadata> <fx:Script fb:purpose="styling">
/**
* @private
*/
override protected function initializationComplete():void
{
useChromeColor = true;
super.initializationComplete();
}
</fx:Script> <s:states>
<s:State name="up" />
<s:State name="down" />
<s:State name="over" />
<s:State name="disabled" />
</s:states>
<!--宽高属性到父容器里去设置-->
<!-- inset 7 and 6 pixels because that's thumbSize/2 -->
<s:Group left="7" right="6" top="0" bottom="0"> <!-- fill -->
<s:Rect left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0x7B7B7B"/>
<s:GradientEntry color="0xA2A2A2"/>
</s:LinearGradient>
</s:fill>
</s:Rect> <!-- inset shadow -->
<s:Rect left="1" right="1" top="1" height="1">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<s:Rect left="1" top="2" bottom="1" width="1">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<s:Rect right="1" top="2" bottom="1" width="1">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect> <!-- border -->
<s:Rect left="0" right="0" top="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="0x131313" weight="1" />
</s:stroke>
</s:Rect> <!-- outside highlight -->
<s:Rect left="-1" right="-1" top="-1" bottom="-1">
<s:stroke>
<s:LinearGradientStroke rotation="90">
<s:GradientEntry color="0xFFFFFF" alpha="0.12"/>
<s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradientStroke>
</s:stroke>
</s:Rect> </s:Group>
</s:SparkSkin>
flex-mp3的更多相关文章
- Flex Flash Player回声消除的最佳方法
Adobe Flash Player 已经成为音频和视频播放的非常流行的工具.实际上,目前大多数因特网视频均使用 Flash Player观看. Flash Player 通过将许多技术进行组合可以提 ...
- 博客中 Flex4/Flash mp3音乐播放器实例 含演示地址
要求 必备知识 本文要求基本了解 Adobe Flex编程知识和JAVA基础知识. 开发环境 MyEclipse10/Flash Builder4.6/Flash Player11及以上 演示地址 演 ...
- Flex性能优化常用手法总结 转
转自:http://bbs.51aspx.com/showtopic-43693.html 随着Flex越来越多的被人们所熟知,越来越多的互联网也开始了RIA应用.众所周知,目前国内的宽带应用并不是像 ...
- 使用Flex 和 Red5开发简单视频直播功能
Flex 是一个高效.免费的开源框架,可用于构建具有表现力的 Web应用程序,这些应用程序利用Adobe Flash Player和Adobe AIR, 可以实现跨浏览器.桌面和操作系统.虽然只能使用 ...
- Flex回声消除的最佳方法
Adobe Flash Player 已经成为音频和视频播放的非常流行的工具.实际上,目前大多数因特网视频均使用 Flash Player观看. Flash Player 通过将许多技术进行组合可以提 ...
- Flash&Flex大全
官方在线帮助(没标英文的都是中文) 用于 Adobe Flash Platform 的 ActionScript 3.0 参考 更多参考使这样的链接下载离线版:http://help.adobe.co ...
- Vue实现mp3音乐播放及动态进度条
今天碰到一个Vue点击mp3播放及进度条动态走动的小功能,记录一下: 首先是通过HTML5 audio标签引入音频: <template> <div class="x-fo ...
- flex embed 使用
Flex 软件中经常需要使用一些外部的资源,如图片.声音.SWF或字体,虽然你也可以在软件运行的时候引入和载入,但是也可能经常需要直接将这些资源编译(Compile)到软件中,也就是直接嵌入资源(Em ...
- OpenCASCADE Expression Interpreter by Flex & Bison
OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...
- Flex 布局教程:语法篇
作者: 阮一峰 网页布局(layout)是CSS的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 + float属性.它对于那些特殊布局非常不方便 ...
随机推荐
- linux下useradd -p 添加用户并设定密码
useradd 有个参数-p是设定密码,我试过,不能登录,今天想到这个问题,搜索得:-p 后面跟的是密文,也就是经过加密之后的那个串. 附上网上的破解shadow口令的链接,都是牛人啊.. http: ...
- Android开发 |常见的内存泄漏问题及解决办法
在Android开发中,内存泄漏是比较常见的问题,有过一些Android编程经历的童鞋应该都遇到过,但为什么会出现内存泄漏呢?内存泄漏又有什么影响呢? 在Android程序开发中,当一个对象已经不需要 ...
- 利用反射把DataTable自动赋值到Model实体(自动识别数据类型)
转:http://www.cnblogs.com/the7stroke/archive/2012/04/22/2465591.html using System.Collections.Generic ...
- android学习笔记五
Android中的category大全 Api Level 3(SDK 1.5)和Api Level 4(SDK 1.6): android.intent.category.ALTERNATIVE a ...
- HDU 5429 Geometric Progression
题意:给出一个大数数列,问是不是等比数列. 解法:拿java大数搞,注意全是0的情况也是Yes.我把公比用分数表示了,灰常麻烦,题解说只要判a[i - 1] * a[i + 1] == a[i] * ...
- <转>DNS服务系列之二:DNS区域传送漏洞的安全案例
DNS区域传送(DNS zone transfer)指的是一台备用服务器使用来自主服务器的数据刷新自己的域(zone)数据库.这为运行中的DNS服务提供了一定的冗余度,其目的是为了防止主的域名服务器因 ...
- Chapter3:字符串、向量和数组
C++11新特性:范围for(range for) for (declaration: expression) statement vector和数组都是对象的集合,而引用不是对象. vector对象 ...
- java集合框架复习(一)
数组类Array是java中最基本的一个存储结构,它用于存储 一组连续的对象或一组类型相同的基本类型的数据. Array特点:效率高,但容量固定且无法动态改变, 缺点:无法判断其中存有多少元素,len ...
- 使用MATLAB生成模糊控制的离线查询表
1.打开模糊控制工具箱,编辑输入输出变量的隶属度函数和模糊控制规则,如下图所示,导出为fuzzy_control.fis文件. 2.打开Simulink模块,建立下图所示的系统框图,两输入,一输出,处 ...
- lucene学习笔记:二,Lucene的框架
Lucene总的来说是: 一个高效的,可扩展的,全文检索库. 全部用Java实现,无须配置. 仅支持纯文本文件的索引(Indexing)和搜索(Search). 不负责由其他格式的文件抽取纯文本文件, ...