Results 1 to 4 of 4

Thread: Difference in online and offline music player

  1. #1
    Join Date
    Nov 2009
    Posts
    42

    Difference in online and offline music player

    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();
            }
        }
    }

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Difference in online and offline music player

    If I see that the addition of "_root" is not changed. Have you tried to put a trace (percent) to check? Otherwise, the else is empty too, although this is not the responsibility of your problem.

    Otherwise, your variable is not always declared (with the word "var"), out, "image" may already be reserved for AS2 (this is the case if the var name appears in blue) ...

    If you're in the learning phase, now converted to AS3, it's boring at first but at least it forces you to lay clean code.

  3. #3
    Join Date
    Nov 2009
    Posts
    42

    Re: Difference in online and offline music player

    Well I add the var, and delete else but this changes nothing.

    And I'm on the track and actually percentagesuiv is undefined. We advance... But I do not see because of what?

    Also tolalsuiv and chargesuiv are defined, locally obviously it gives the same number live

    An idea why it is not defined?

    For as3 I quite agree I have only been training as2 this spring (the trainer knew not regret the as3 ..) and saw that I had a few more basic. For not yet had the courage to put myself it seems very different and more
    In that light I also put a little javascript and php to.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Difference in online and offline music player

    I myself am a graphic artist, you have no excuse. More seriously, AS3 is more related to languages such as JS / C than AS2! But hey I'm telling you this because I myself started with AS2 programming

    For your problem, I know too ...

    chargesuiv and totalsuiv are also undefined?

    Well, I do not blunder in your effort to declare itself the var but you would have to declare the var dedicated to load outside the enterFrame

    var totalsuiv: Number;
    var chargesuiv: Number;
    var percentagesuiv: Number;

Similar Threads

  1. Replies: 10
    Last Post: 22-01-2012, 10:45 AM
  2. Replies: 4
    Last Post: 04-11-2011, 10:38 PM
  3. Replies: 5
    Last Post: 25-10-2011, 06:32 PM
  4. Nokia E5: Music Player adds sound clip to music player's list
    By Delightful. in forum Portable Devices
    Replies: 6
    Last Post: 23-06-2011, 12:15 AM
  5. Difference between Folder Redirection and Offline Folders
    By JohnB in forum Windows Server Help
    Replies: 11
    Last Post: 25-04-2008, 08:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,011,824.68472 seconds with 16 queries