קוד:
loopit = 0
//browse
import flash.net.FileReference
var allTypes:Array = new Array()
var audioTypes:Object = new Object()
audioTypes.description = "Audio (*.MP3; *.WMV; *.WMP)"
audioTypes.extension = "*.mp3; *.wmv; *.wmp;"
allTypes.push(audioTypes)
var fileRef:FileReference = new FileReference()
//listener
var listener:Object = new Object()
listener.onSelect = function(file:FileReference):Void {
path.text = file.name
audio = new Sound()
audio.loadSound(path.text,false)
}
fileRef.addListener(listener)
//browse button
_root.createEmptyMovieClip("browseb", _root.getNextHighestDepth())
browseb._x = 268
browseb._y = 8
browseb.createTextField("browsetext", _root.getNextHighestDepth(), 0, 0, 53, 17)
browseb.browsetext.selectable = false
browseb.browsetext.text = "BROWSE"
browseb.browsetext.textColor = 0xA00101
browseb.onRelease = function() {
fileRef.browse(allTypes)
}
//path var
_root.createTextField("path", _root.getNextHighestDepth(), 45, 8, 220, 18)
path.selectable = false
path.textColor = 0xFF0000
path.text = "- Press BROWSE and select an audio file."
//control buttons
_root.createEmptyMovieClip("playb", _root.getNextHighestDepth())
playb._x = 268 + 70
playb._y = 8
playb.createTextField("playtext", _root.getNextHighestDepth(), 0, 0, 53, 17)
playb.playtext.selectable = false
playb.playtext.text = "PLAY"
playb.onRelease = function() {
audio.start(0, loopit)
}
//
_root.createTextField("middletext", _root.getNextHighestDepth(), 268 + 70 + 50 - 11, 8, 53, 17)
middletext.selectable = false
middletext.text = "|"
//
_root.createEmptyMovieClip("stopb", _root.getNextHighestDepth())
stopb._x = 268 + 70 + 50
stopb._y = 8
stopb.createTextField("stoptext", _root.getNextHighestDepth(), 0, 0, 53, 17)
stopb.stoptext.selectable = false
stopb.stoptext.text = "STOP"
stopb.onRelease = function() {
audio.stop()
}
//loop button
_root.createEmptyMovieClip("loopb", _root.getNextHighestDepth())
loopb._x = 268 + 70 + 50 + 50
loopb._y = 8
loopb.createTextField("loopbtext", _root.getNextHighestDepth(), 0, 0, 73, 20)
loopb.loopbtext.selectable = false
loopb.loopbtext.text = "Loop: FALSE"
loopb.onRelease = function() {
audio.stop()
if (loopb.loopbtext.text == "Loop: FALSE") {
loopb.loopbtext.text = "Loop: TRUE"
loopit = 9999
}
else if (loopb.loopbtext.text == "Loop: TRUE") {
loopb.loopbtext.text = "Loop: FALSE"
loopit = 0
}
}
//line
_root.createEmptyMovieClip("line", _root.getNextHighestDepth())
line.lineStyle(1,0x000000,100)
line.moveTo(0, 30)
line.lineTo(Stage.width, 30)