Hjælp til simpel flash
Godmorgen alle eksperter.jeg har et lille problem med noget flash. Jeg vil have den til at musikken skal være stoppet fra starten af. Det eneste der er i flash er en "PlayPause" og en "Next knap" altså "PlayPause" er jo en knap som sådan i flash, hvis i forstår. Denne kode henter sangene fra en XML fil. Kan bare ikke lige huske hvordan det er man stopper musikken fra staten af også når man trykker på play så starter den.
//Setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
//Array of songs
var sa:Array = new Array();
//Currently playing song
var cps:Number = -1;
//Position of music
var pos:Number;
//Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
sa.push(nodes[i].attributes.url);
}
playSong();
}
xml.load("songs.xml");
//Play the MP3 File
function playSong():Void
{
s = new Sound();
if(cps == sa.length -1)
{
cps=0;
s.loadSound(sa[cps], true);
}
else
{
s.loadSound(sa[++cps], true);
}
playPause.gotoAndStop("pause");
}
// Pauses the music
function pauselt():Void
{
pos = s.position;
s.stop();
}
function unPauselt():Void
{
s.start(pos/1000);
}
// playPause Toggle
playPause.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop("pauseOver");
else this.gotoAndStop("playOver");
}
playPause.onRollOut = playPause.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop("pause");
else this.gotoAndstop("play");
}
playPause.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop("playOver");
this._parent.pauselt();
}
else
{
this.gotoAndStop("pauseOver");
this._parent.unPauselt();
}
}
// Next Button
next.onRollOver = function()
{
this.gotoAndStop("nextOver");
}
next.onRollOut = next.onReleaseOutside = function()
{
this.gotoAndStop("next");
}
next.onRelease = function()
{
this._parent.playSong();
}
Morten
