My concern: I am proud of myself, although quite beginner in Actionscript, that I managed to make a good flash player in AS2. It works locally. But when I put on my site, the images associated with songs that do not load half the time.
If someone has an idea or can find out the actual problem than it would be of great concerned. Here is my code:
Code:
var flag =false;
var song = 0;
var p=0;
var totalsuiv:Number = 0;
var chargesuiv:Number = 0;
var percentagensuiv:Number = Math.round(chargesuiv/totalsuiv*100);
File_XML = new XML();
File_XML.ignoreWhite = true;
if (_root.list == undefined) {
_root.list = "son";
// = you assign the value
}
File_XML.load(_root.list+".xml" );
/* To fetch the XML file in html flash object: add a parameter with in dreamweaver property. paramater: flashvars and value: = list for his name's XML file
*/
var music = new Array();
var artist = new Array();
var title = new Array();
var logo = new Array();
var sounds = new Array();
File_XML.onLoad = function(Success) {
if (Success) {
for (i=0; File_XML.childNodes[0].childNodes[i]!=undefined; i++) {
/*loop until we have a sound that bears the numbers i
it stores the path del image in variable image
initialization; condition; incrementation (!= is different)*/
music[i] = File_XML.childNodes[0].childNodes[i].childNodes[0].firstChild;
artist[i] = File_XML.childNodes[0].childNodes[i].childNodes[1].firstChild;
title[i] = File_XML.childNodes[0].childNodes[i].childNodes[2].firstChild;
logo[i] = File_XML.childNodes[0].childNodes[i].childNodes[3].firstChild;
sounds[i] = new Sound();
//we filled the table (array) by any sound of the xml
_root.containertitle.attachMovie("titlemusic","titlemusic"+i,i+10);
eval("_root.containertitle.titlemusic"+i).textmusic.text = title[i];
eval("_root.containertitle.titlemusic"+i).textartist.text = artist[i];
textmusic.autoSize = true;
eval("_root.containertitle.titlemusic"+i)._x = 100;
eval("_root.containertitle.titlemusic"+i)._y = 18*i+18;
eval("_root.containertitle.titlemusic"+i).num = i;
eval("_root.containertitle.titremusica"+i).attachMovie("bib","bib_load",1);
eval("_root.containertitle.titlemusic"+i).bib_load._x = -100;
eval("_root.containertitle.titlemusic"+i).bib_load._y = -8;
eval("_root.containertitle.titlemusic"+i).bib_load.stop();
eval("_root.containertitle.titlemusic"+i).bib_load._visible = false;
eval("_root.containertitle.titlemusic"+i).onPress = function() {
flag = true;
for (j=0;j<sounds.length;j++) {
sounds[j].stop();
}
if (_root.sounds[this.num].duration==undefined) { _root.sounds[this.num].loadSound (_root.music[this.num],true);
}
else {
if (_root.sounds[this.num].position == _root.sounds[this.num].duration) {
_root.p == 0;
}
_root.sounds[this.num].start(_root.p/1000);
}
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=false;
this.bib_load.play();
this.bib_load._visible=true;
vol = _root.sounds[_root.song].getVolume();
_root.sounds[this.num].setVolume(vol);
_root.song = this.num;
chargeimage();
progress();
}
}
}
}
_root.onEnterFrame = function () {
chargeimage();
}
_root.player.debut.onPress = function () {
if(_root.flag==false){
var flag = true;
_root.sounds[_root.song].loadSound (_root.music[_root.song],true);
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=true;
this.bib_load.play();
chargeimage();
progress();
}
else{
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load.play();
if(_root.sounds[_root.song].position == _root.sounds[_root.song].duration) {
p==0;
}
_root.sounds[_root.song].start(_root.p/1000);
}
}
_root.player.inpause.onPress = function () {
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load.stop();
for (j=0;j<sounds.length;j++) {
sounds[j].stop();
}
_root.p= _root.sounds[_root.song].position;
}
_root.player.Next.onPress = function () {
if(_root.flag==true){
songNext();
}
}
_root.player.precedent.onPress = function () {
if(_root.song>0){
_root.sounds[_root.song].stop();
vol = _root.sounds[_root.song].getVolume();
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=false;
_root.song --;
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=true;
_root.sounds[_root.song].setVolume(vol);
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load.play();
if (_root.sounds[_root.song].duration==undefined) {
_root.sounds[_root.song].loadSound (_root.music[_root.song],true);
}
chargeimage();
}
_root.sounds[_root.song].start(0);
}
_root.progression.onPress = function () {
var temps = (_root._xmouse-this._x)/this._width;
_root.sounds[_root.song].stop;
_root.sounds[_root.song].start((_root.sounds[_root.song].duration)*temps/1000);
}
songNext = function(){
if(_root.song<(i-1)){
_root.sounds[_root.song].stop();
vol = _root.sounds[_root.song].getVolume();
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=false;
_root.song++;
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=true;
_root.sounds[_root.song].setVolume(vol);
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load.play();
if (_root.sounds[_root.song].duration==undefined) {
_root.sounds[_root.song].loadSound (_root.music[_root.song],true);
}
chargeimage();
}
else{
_root.sounds[_root.song].stop();
vol = _root.sounds[_root.song].getVolume();
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=false;
_root.song = 0;
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load._visible=true;
_root.sounds[_root.song].setVolume(vol);
eval("_root.containertitle.titlemusic"+[_root.song]).bib_load.play();
if (_root.sounds[_root.song].duration==undefined) {
_root.sounds[_root.song].loadSound (_root.music[_root.song],true);
}
chargeimage();
}
_root.sounds[_root.song].start(0);
}
chargeimage = function(){
if (_root.logo[_root.song]!= undefined) {
_root.imageSound.loadMovie(_root.logo[_root.song]);
this.onEnterFrame = function():Void {
totalsuiv = _root.imageSound.getBytesTotal();
chargesuiv = _root.imageSound.getBytesLoaded();
percentagesuiv = Math.round(chargesuiv/totalsuiv*100);
if (percentagesuiv == 100) {
delete this.onEnterFrame;
_root.imageSound._width = 95;
_root.imageSound._height = 95;
}
}
}
else {
_root.imageSound.unloadMovie();
}
}
progress = function(){
_root.progression.progressionbar.onEnterFrame = function(){
this._width = (_root.sounds[_root.song].position/_root.sounds[_root.song].duration)*215;
if (this._width == 215){
songNext();
}
}
}
Bookmarks