[問題] 可幫我看看這段程式碼嗎?
嗯...小弟有一段FLASH 的Action Script看不懂,
請問有人可以幫我解釋一下嗎?
敲我水球或寄個信吧...
拜託了~專題撞牆中ˊˋ
import mx.transitions.Tween;
import mx.transitions.easing.*;
var repeatCurrentTrack = false
var baseIY = informer.ttxt._x
var f:Tween = null
var aaa, D
var file_description:Array = []
var CURSOUND = {}
var nextSong:Number
var playAtStart = false
var LOAD = !playAtStart
var openPlayList = true
!playAtStart ? play_pause.gotoAndStop(2) : play_pause.gotoAndStop(1)
MovieClip.prototype.init = function(Text){
this.txtc.txt.text = Text
this.onRollOver = function(){this.gotoAndPlay(2)}
this.onRollOut = function(){this.gotoAndPlay(8)}
}
function checker(){
aaa = 100
if(informer.ttxt._width > informer.mask._width){
var difference = informer.ttxt._x - (informer.ttxt._width - informer.mask._width)
f = new Tween(informer.ttxt, "_x", null, baseIY, difference, 3, true)
f.onMotionFinished = function(){
informer.onEnterFrame = function(){
aaa --
if(aaa <= 0){
aaa = 100
delete this.onEnterFrame;
f.yoyo()
}
}
}
}
else{
delete informer.onEnterFrame;
aaa = 100
f.rewind()
f.stop()
}
informer.ttxt._x = baseIY
}
function textSetter(txt, color){
informer.ttxt.txt.autoSize = "left"
var container = informer.ttxt.txt
container.text = txt
container.textColor = color
checker()
}
function loadSongsData(){
var songs = new XML();
songs.ignoreWhite = true;
songs.load("./music.xml")
songs.onLoad = function(loaded){
if(loaded){
for (i=0 ; i < songs.firstChild.childNodes.length; i++){
var temp = []
temp[0] = songs.firstChild.childNodes[i].childNodes[0]
temp[1] = songs.firstChild.childNodes[i].attributes.description
temp[2] = songs.firstChild.childNodes[i].attributes.Duration
file_description.push(temp)
}
textSetter("Player ready", "0x999999")
makePlaylist()
defineCURSOUND()
if(_global.startAtOnce){
play_pause.onPress()
}
}
}
}
function defineCURSOUND(){
this.CURSOUND.Url = file_description[0][0]
this.CURSOUND.Duration = file_description[0][2]
this.CURSOUND.ID = 0
this.CURSOUND.Description = file_description[0][1]
}
function makePlaylist(){
playlist.songs.link0.init(file_description[0][1])
playlist.songs.link0.ID = 0
playlist.songs.link0.Url = file_description[0][0]
playlist.songs.link0.Duration = file_description[0][2]
playlist.songs.link0.onRelease = function(){
this._parent._parent._parent.timeline.loader.clicker.enabled = true
if(play_pause._currentframe != 1)play_pause.gotoAndPlay(1)
playAtStart = true
this._parent._parent.prepare(this.ID)
}
for(i=1 ; i < file_description.length ; i++){
playlist.songs.link0.duplicateMovieClip("link" + i, i, i);
this.playlist.songs["link" + i].init(file_description[i][1])
this.playlist.songs["link" + i]._y += Math.floor(18*i) + 1*i
this.playlist.songs["link" + i].Url = file_description[i][0]
this.playlist.songs["link" + i].ID = i
this.playlist.songs["link" + i].Duration = file_description[i][2]
this.playlist.songs["link" + i].onRelease = function(){
this._parent._parent._parent.timeline.loader.clicker.enabled = true
if(play_pause._currentframe != 1)play_pause.gotoAndPlay(1)
playAtStart = true
LOAD = !playAtStart
this._parent._parent.prepare(this.ID)
}
}
this.playlist.appear()
playlist.songs.link0.swapDepths(playlist.songs.my_txt)
}
function repeater(currentTrack, stream){
nextSong = currentTrack
if(nextSong == file_description.length - 1){nextSong = -1}
if(!repeatCurrentTrack){
nextSong ++
}
else{
nextSong == -1 ? nextSong = (file_description.length - 1) : null
}
loadSound(file_description[nextSong][0], stream, file_description[nextSong][2], nextSong)
this.playlist.songs["link" + nextSong].gotoAndPlay(2)
this.playlist.songs["link" + nextSong].enabled = !(_global.PrevSong001.enabled = true)
_global.PrevSong001._alpha = 100
this.playlist.songs["link" + nextSong]._alpha = 60
_global.PrevSong001.gotoAndPlay(8)
_global.PrevSong001 = this.playlist.songs["link" + nextSong]
_global.PrevSong001.gotoAndPlay(2)
CURSOUND.Description = file_description[nextSong][1]
textSetter(CURSOUND.Description, "0x777777")
}
function loadSound(snd, stream, trackLength, current){
stream ? textSetter(CURSOUND.Description, "0x777777") : textSetter("Loading track: " + CURSOUND.Description, "0x777777")
D = trackLength
this.musicObj.stop()
this.musicObj.loadSound(null, true)
delete this.musicObj;
this.musicObj = new Sound()
this.musicObj.loadSound(snd, stream)
this.musicObj.setVolume(Math.round((regulator.scroller._x+0.8) * (100 / (regulator.bg._width - regulator.scroller._width))))
this.musicObj.onSoundComplete = function(){repeater(current, stream);
if(CURSOUND.ID > file_description.length -2){
CURSOUND.ID = 0}
else{
repeatCurrentTrack ? null : CURSOUND.ID++}
}
timeline.init(D)
}
//-------------------------------------------------trunk and actions
list.onRelease = function(){
if(openPlayList){
for (i in playlist.songs){playlist.songs[i]._visible = true}
_global.PrevSong001._alpha = 60
playlist.roll(playlist.topY, 20)
openPlayList = false
}
else{
playlist.roll(playlist.baseY, 25)
openPlayList = true
}
}
play_pause.onPress = function(){
timeline.loader.clicker.enabled = true
if(playAtStart){
this.gotoAndStop(2)
textSetter("Track paused", "0x777777")
informer.ttxt._x = baseIY
Mposition = musicObj.position
musicObj.stop()
playAtStart = false
}
else{
this.gotoAndStop(1)
textSetter(CURSOUND.Description, "0x777777")
this._parent.LOAD ? loadSound(this._parent.CURSOUND.Url, true, this._parent.CURSOUND.Duration, this._parent.CURSOUND.ID) :
musicObj.start(Mposition/1000, 1);
playAtStart = true
this._parent.LOAD = false
}
}
stop_.onRelease = function(){
textSetter("Track Stopped", "0x777777")
informer.ttxt._x = baseIY
delete timeline.onEnterFrame
informer.time.text = "00:00 / 00:00"
playAtStart = false
play_pause.gotoAndStop(2)
musicObj.start(0, 1)
musicObj.stop()
musicObj.loadSound(null)
this._parent.LOAD = true
timeline.mask_loader.gotoAndStop(1)
timeline.mask_position.gotoAndStop(1)
timeline.loader.clicker.enabled = false
}
next.onRelease = function(){
this._parent.LOAD = false
if(this._parent.CURSOUND.ID > file_description.length -2){
this._parent.CURSOUND.ID = 0
playlist.songs["link" + this._parent.CURSOUND.ID].onRelease()
}
else{
this._parent.CURSOUND.ID++
playlist.songs["link" + this._parent.CURSOUND.ID].onRelease()}
playlist.songs["link" + this._parent.CURSOUND.ID].gotoAndStop(7)
textSetter(CURSOUND.Description, "0x777777")
}
prev.onRelease = function(){
this._parent.LOAD = false
if(this._parent.CURSOUND.ID < 1){
this._parent.CURSOUND.ID = file_description.length - 1
playlist.songs["link" + this._parent.CURSOUND.ID].onRelease()
}
else{
this._parent.CURSOUND.ID--
playlist.songs["link" + this._parent.CURSOUND.ID].onRelease()}
playlist.songs["link" + this._parent.CURSOUND.ID].gotoAndStop(7)
textSetter(CURSOUND.Description, "0x777777")
}
repeat.onRelease = function(){
repeatCurrentTrack = !repeatCurrentTrack
this._currentframe == 1 ? this.gotoAndStop(2) : this.gotoAndStop(1)
}
function loadTrack(trackNumber){
this.playlist.songs["link" + (trackNumber-1)].onRelease()
this.playlist.songs["link" + (trackNumber-1)].gotoAndPlay(2)
}
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function():Void {
if (!playlist.hitTest(_root._xmouse, _root._ymouse, true))
{
if(!list.hitTest(_root._xmouse, _root._ymouse, true)){
playlist.roll(playlist.baseY, 25)
openPlayList = true
}
}
}
Mouse.addListener(mouseListener);
//----------------inintializer
loadSongsData()
--
http://www.wretch.cc/blog/r123448987
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.204.139.129
→
05/11 23:09, , 1F
05/11 23:09, 1F
→
05/11 23:10, , 2F
05/11 23:10, 2F
→
05/11 23:45, , 3F
05/11 23:45, 3F
推
05/11 23:59, , 4F
05/11 23:59, 4F
→
05/12 00:11, , 5F
05/12 00:11, 5F