A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: XML not working on server

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    4

    XML not working on server

    i downloaded a couple templates from flashmo.com all them reference a XML file everything works after publish but when uploaded the text fields say undefined and the music doesn't play this is quite frustrating as my hole site is wrapped up into these swf. projects. Here is my AS Code



    // Flash MP3 Player XML
    // Developed by www.flashmo.co=
    import mx.transitions.Tween;
    import mx.transitions.easing.*;

    var song_folder:String = "songs/";
    var song_list:Array = new Array();
    var track_list:Array = new Array();
    var artist_list:Array = new Array();
    var album_list:Array = new Array();
    var current:Number = 0;
    var position:Number;
    var new_volume:Number = 100;
    var flashmo_xml:XML = new XML();
    flashmo_xml.ignoreWhite = true;
    flashmo_xml.onLoad = function()
    {
    var nodes:Array = this.firstChild.childNodes;
    for(var i = 0; i < nodes.length; i++)
    {
    song_list.push(nodes[i].attributes.filename);
    track_list.push(nodes[i].attributes.track);
    artist_list.push(nodes[i].attributes.artist);
    album_list.push(nodes[i].attributes.album);
    }
    play_song("start");
    }
    flashmo_xml.load( song_folder + "flashmo_songs.xml");

    fm_play.play_pause.onRelease = function()
    {
    if( this._parent._currentframe == 1 )
    this._parent._parent.play_pause("pause");
    else
    this._parent._parent.play_pause("play");

    this._parent.play();
    }
    fm_prev.onRelease = function()
    {
    this._parent.play_song("prev");
    }
    fm_next.onRelease = function()
    {
    this._parent.play_song("next");
    }
    function play_song(track:String):Void
    {
    if(track == "prev")
    current--;
    else if(track == "start")
    current = 0;
    else
    current++;

    if(current == song_list.length)
    current = 0;
    else if(current < 0)
    current = song_list.length - 1;

    s = new Sound(); s.loadSound(song_folder + song_list[current], true);
    s.setVolume(new_volume);
    track_title.text = track_list[current];
    artist_name.text = artist_list[current];
    album_title.text = album_list[current];
    track_info.text = "Track " + (current+1) + " of " + song_list.length;
    fm_play.gotoAndStop(1);
    }
    function play_pause(pp:String):Void
    {
    if(pp == "pause")
    {
    position = s.position;
    s.stop();
    }
    else if(pp == "play")
    {
    s.start(position/1000);
    }
    }
    var my_interval:Number;
    my_interval = setInterval(update_bar, 100);
    function update_bar():Void
    {
    var total_seconds:Number = s.duration/1000;
    var minutes:Number = Math.floor(total_seconds/60);
    var seconds = Math.floor(total_seconds)%60;
    if(seconds < 10)
    seconds = "0" + seconds;

    var total_current_seconds:Number = s.position/1000;
    var current_minutes:Number = Math.floor(total_current_seconds/60);
    var current_seconds = Math.floor(total_current_seconds)%60;
    if(current_seconds < 10)
    current_seconds = "0" + current_seconds;

    percent_loaded = Math.round(s.getBytesLoaded() / s.getBytesTotal() * 100);

    if( percent_loaded != 100 && percent_loaded > 0)
    loading_info.text = "loading... " + percent_loaded + "%";
    else
    loading_info.text = "";

    flashmo_bar._width = Math.round( s.position/s.duration*flashmo_bar_bg._width );
    flashmo_pointer._x = flashmo_bar._width + flashmo_bar._x;

    position_info.text = current_minutes +":"+ current_seconds + " / " + minutes +":"+ seconds;
    if( s.getBytesLoaded() == s.getBytesTotal() && s.position == s.duration )
    play_song();
    }
    var theMenu:ContextMenu = new ContextMenu();
    theMenu.hideBuiltInItems(); _root.menu = theMenu;
    var item:ContextMenuItem = new ContextMenuItem("Created by www.flashmo.com", flashmo);
    theMenu.customItems[0] = item;
    function flashmo() { getURL("http://www.whoismannyd.com"); }

    flashmo_pointer.onPress = function()
    {
    this.startDrag(true, flashmo_bar_bg._x, this._y, flashmo_bar_bg._width + flashmo_bar_bg._x, this._y );
    s.stop(); clearInterval(my_interval);
    }
    flashmo_pointer.onRelease = flashmo_pointer.onReleaseOutside = function()
    {
    this.stopDrag();
    new_position = s.duration * (this._x - flashmo_bar_bg._x) / (flashmo_bar_bg._width * 1000);
    s.start(new_position); fm_play.gotoAndStop(1);
    my_interval = setInterval(update_bar, 100);
    }
    flashmo_volume_pointer.onPress = function()
    {
    this.startDrag(true, flashmo_volume_bg._x, this._y, flashmo_volume_bg._width + flashmo_volume_bg._x, this._y );
    }
    flashmo_volume_pointer.onRelease = flashmo_volume_pointer.onReleaseOutside = function()
    {
    this.stopDrag(); new_volume = this._x - flashmo_volume_bg._x;
    new Tween(flashmo_volume, "_width", Strong.easeOut, flashmo_volume._width, new_volume, 1.5, true);
    s.setVolume(new_volume);
    }



    THIS IS MY XML FILE

    <?xml version="1.0" encoding="UTF-8" ?>
    <songs>
    <song filename="01 let um go.mp3" track="Let Um Go" artist="Manny D" album="Unknown" />
    <song filename="02 FIGHT NIGHT.mp3" track="Fight Night" artist="Manny D" album="Unknown" />
    <song filename="03 put um up.mp3" track="Put Um UP" artist="Manny D" album="Unknown" />
    <song filename="04 Dats Urs.mp3" track="Dats Urs" artist="Manny D" album="Unknown" />
    <song filename="05 Skurt Skurt (mixed down).mp3" track="Skurt Skurt" artist="Manny D" album="Unknown" />
    <song filename="06 jump.mp3" track="Jump" artist="Manny D" album="Unknown" />
    <song filename="07 FAT CHICKS FT.YOUNG ZEE AND REDMAN.mp3" track="Fat Chicks" artist="Manny D FT. Young Zee & Redman" album="Unknown" />
    <song filename="08 pass the dochit.mp3" track="Pass The
    Dochit" artist="Manny D" album="Unknown" />
    <song filename="09 Shake For Dat Money 1.mp3" track="Shake For Dat
    Money" artist="Manny D" album="Unknown" />
    <song filename="10 ROCKN WIT MY SHADES ON.mp3" track="Rockn Wit
    My Shades On" artist="Manny D" album="Unknown" />
    <song filename="11 MONEYS THE MOTIVATION.mp3" track="Moneys The
    Motivation" artist="Manny D" album="Unknown" />
    <song filename="12 go get her.mp3" track="Go Get Her" artist="Manny D" album="Unknown" />
    <song filename="13 KNOCK KNOCK FT.KRSONE.mp3" track="Knock Knock" artist="Manny D
    FT. KRSONE" album="Unknown" />
    <song filename="14 PLEASE FORGIVE ME.mp3" track="Please Forgive
    Me" artist="Manny D" album="Unknown" />
    </songs>


    I DON'T KNOW WHERE I WENT WRONG PLEASE HELP THANKS.

  2. #2
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Check your paths to the MP3's. Are you uploading them the same way you're usining them on your desktop?

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    4
    Quote Originally Posted by intromo View Post
    Check your paths to the MP3's. Are you uploading them the same way you're usining them on your desktop?

  4. #4
    Junior Member
    Join Date
    May 2009
    Posts
    4
    it's all in one folder songs, swfs, xml, fla and i put that folder onto my server is there such a thing as a server that won't let you use xml files im not very expirenced with this stuff. When i preview in my browser i can see the backgound and the buttons work the change what track number im on but no music and no text

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you have -
    var song_folder:String = "songs/";
    .....
    flashmo_xml.load( song_folder + "flashmo_songs.xml");
    .....
    s.loadSound(song_folder + song_list[current], true);

    so the html and swf is in the root folder
    and the xml and mp3's need to be in a sub-folder called - songs

    root/
    ----songs/

    ps... don't upload the fla, it's an authoring file and useless online

  6. #6
    Junior Member
    Join Date
    May 2009
    Posts
    4
    thank you soo much it works now that was a very stupid mistake. I spent all day yesterday going threw 113 pages looking for a simaler post i will pay more attention to these message boards to see if i can help out at all

  7. #7
    Junior Member
    Join Date
    Jun 2007
    Posts
    9

    XML not loading songs

    I am using a Flashmo template, plays fine all great on my computer, when I upoad it to the server just like this guy above it says loadng XML... and does nothing . Works fine on my drive when exporting it. I upload the same heierarchy and it won't Play please help me. Thanks I read the post a bove so I put the xml file in the songs folder but it made no difference. Thanks

  8. #8
    Junior Member
    Join Date
    Jun 2007
    Posts
    9
    Here is my code, and I am sure I have it uploaded correctly. Please help. Thanks

    /*

    Credits

    Flash MP3 Player

    Developed By
    http://www.flashmo.com

    Reference
    http://www.gotoandlearn.com

    Tweener
    http://code.google.com/p/tweener

    */

    import caurina.transitions.Tweener;
    import caurina.transitions.properties.ColorShortcuts;
    ColorShortcuts.init();

    var auto_play:Boolean = true;
    var i:Number;
    var total_items:Number;
    var current_no:Number = 0;
    var flashmo_xml:XML;
    var flashmo_item_list = new Array();
    var item_group:MovieClip = new MovieClip();

    var flashmo_s:Sound = new Sound();
    var flashmo_sc:SoundChannel = new SoundChannel();
    var flashmo_st:SoundTransform = new SoundTransform();
    var flashmo_cpi:Number = 0;
    var flashmo_lpi:Number = -1;
    var flashmo_pos:Number = 0;
    var item_paused:Boolean = false;
    var playback_min:uint;
    var playback_sec:uint;
    var total_min:uint;
    var total_sec:uint;
    var estimated_length:int;
    var drag_area:Rectangle = new Rectangle( 0, status_bar.status_bar_scroller.y, status_bar.load_progress_bar.width, 0 );

    this.addChild(item_group);
    item_group.mask = slider_mask;

    flashmo_item_1.visible = false;
    flashmo_sb.visible = false;
    status_bar.visible = false;
    flashmo_volume.visible = false;
    flashmo_previous.visible = false;
    flashmo_next.visible = false;
    flashmo_play.visible = false;
    flashmo_pause.visible = false;

    current_item_title.text = "Loading XML Data...";

    status_bar.status_bar_scroller.buttonMode = true;
    status_bar.status_bar_scroller.addEventListener( MouseEvent.MOUSE_DOWN, scroller_drag );
    status_bar.status_bar_scroller.addEventListener( MouseEvent.MOUSE_UP, scroller_drop );
    status_bar.fm_bar.addEventListener( Event.ENTER_FRAME, item_progress );
    status_bar.clickable_area.buttonMode = true;
    status_bar.clickable_area.addEventListener( MouseEvent.MOUSE_DOWN, position_seek );
    status_bar.load_progress_bar.addEventListener( Event.ENTER_FRAME, drag_area_progress );

    function load_xml( xml_file:String ):void
    {
    var xml_loader:URLLoader = new URLLoader();
    xml_loader.load( new URLRequest( xml_file ) );
    xml_loader.addEventListener(Event.COMPLETE, read_xml);
    }

    function read_xml( e:Event ):void
    {
    flashmo_xml = new XML(e.target.data);
    total_items = flashmo_xml.song.length();

    for( i = 0; i < total_items; i++ )
    {
    flashmo_item_list.push( {
    url: flashmo_xml.song[i].url.toString(),
    artist: flashmo_xml.song[i].artist.toString(),
    track: flashmo_xml.song[i].track.toString()
    } );
    }
    load_songs();
    add_controls();
    }

    function load_songs():void
    {
    for( i = 0; i < total_items; i++ )
    {
    var flashmo_item_mc:MovieClip = new MovieClip();
    var item:MovieClip = new flashmo_item();

    item.item_title.text = flashmo_item_list[i].artist + " - " + flashmo_item_list[i].track;
    item.y = item_group.numChildren * 30;

    item.hit.buttonMode = true;
    item.hit.addEventListener( MouseEvent.MOUSE_OVER, item_over );
    item.hit.addEventListener( MouseEvent.MOUSE_OUT, item_out );
    item.hit.addEventListener( MouseEvent.CLICK, item_click );
    item.name = "flashmo_song_" + item_group.numChildren;

    item.addChild(flashmo_item_mc);
    item_group.addChild( item );
    }

    flashmo_sb.visible = true;
    flashmo_sb.buttonMode = true;
    flashmo_sb.scrolling("item_group", "slider_mask", 0.80);

    play_item();
    }

    function add_controls():void
    {
    flashmo_previous.addEventListener(MouseEvent.CLICK , on_click_prev);
    flashmo_pause.addEventListener(MouseEvent.CLICK, on_click_pause);
    flashmo_play.addEventListener(MouseEvent.CLICK, on_click_play);
    flashmo_next.addEventListener(MouseEvent.CLICK, on_click_next);

    status_bar.visible = true;
    flashmo_volume.visible = true;
    flashmo_previous.visible = true;
    flashmo_next.visible = true;

    if( auto_play )
    {
    flashmo_pause.visible = true;
    flashmo_play.visible = false;
    }
    else
    {
    flashmo_play.visible = true;
    flashmo_pause.visible = false;
    }
    }

    function change_color( mc:MovieClip, r_offset:int, g_offset:int, b_offset:int ):void
    {
    Tweener.addTween( mc, {_color_redOffset:r_offset, _color_blueOffset:g_offset,
    _color_blueOffset:b_offset, time:1.5, transition:"easeOutExpo"});
    }

    function play_item():void
    {
    if( flashmo_lpi > -1 )
    change_color( MovieClip(item_group.getChildAt(flashmo_lpi) ), 0, 0, 0);

    change_color( MovieClip(item_group.getChildAt(flashmo_cpi) ), -40, 10, -40);

    flashmo_s.removeEventListener(ProgressEvent.PROGRE SS, load_progress);
    status_bar.load_progress_bar.removeEventListener(E vent.ENTER_FRAME, drag_area_progress);
    status_bar.load_progress_bar.scaleX = status_bar.clickable_area.scaleX =
    status_bar.fm_bar.width = status_bar.status_bar_scroller.x = 0;

    flashmo_sc.stop();
    flashmo_s = new Sound();
    flashmo_sc = new SoundChannel();
    flashmo_volume.mute.gotoAndStop("on");

    if( flashmo_volume.flashmo_scroller.x == 0 )
    flashmo_volume.flashmo_scroller.x = 60;

    flashmo_st.volume = flashmo_volume.flashmo_scroller.x /
    ( flashmo_volume.flashmo_scrollable_area.width - flashmo_volume.flashmo_scroller.width );
    flashmo_s.load( new URLRequest( flashmo_item_list[flashmo_cpi].url ) );

    status_bar.load_progress_bar.addEventListener( Event.ENTER_FRAME, drag_area_progress );

    if( flashmo_cpi != 0 || auto_play )
    {
    flashmo_sc = flashmo_s.play();
    item_paused = false;
    flashmo_pause.visible = true;
    flashmo_play.visible = false;
    }
    else
    {
    flashmo_pause.visible = false;
    flashmo_play.visible = true;
    }

    flashmo_sc.soundTransform = flashmo_st;
    flashmo_sc.addEventListener(Event.SOUND_COMPLETE, next_item_handler);
    flashmo_s.addEventListener(ProgressEvent.PROGRESS, load_progress);
    flashmo_lpi = flashmo_cpi;
    current_item_title.text = flashmo_item_list[flashmo_cpi].artist + " - " +
    flashmo_item_list[flashmo_cpi].track;
    }

    function next_item_handler( e:Event )
    {
    play_next_item();
    }

    function load_progress( e:ProgressEvent ):void
    {
    var load_ratio:Number = e.bytesLoaded / e.bytesTotal;
    status_bar.load_progress_bar.scaleX = status_bar.clickable_area.scaleX = load_ratio;

    if( load_ratio >= 1 )
    flashmo_s.removeEventListener( Event.ENTER_FRAME, load_progress );
    }

    function item_over( me:MouseEvent ):void
    {
    var mc:MovieClip = MovieClip(me.target.parent);
    current_no = parseInt(mc.name.slice(13,15));
    change_color(mc, -40, 0, 40);
    }

    function item_out( me:MouseEvent ):void
    {
    var mc:MovieClip = MovieClip(me.target.parent);
    current_no = parseInt(mc.name.slice(13,15));
    if( current_no != flashmo_cpi )
    change_color( mc, 0, 0, 0 );
    else
    change_color( MovieClip( item_group.getChildAt(flashmo_cpi) ), -40, 10, -40 );
    }

    function item_click( me:MouseEvent ):void
    {
    var mc:MovieClip = MovieClip(me.target.parent);
    current_no = parseInt(mc.name.slice(13,15));
    flashmo_cpi = current_no;
    play_item();
    }

    function on_click_pause( me:MouseEvent ):void
    {
    flashmo_play.visible = true;
    flashmo_pause.visible = false;
    pause_it();
    }

    function on_click_play( me:MouseEvent ):void
    {
    flashmo_pause.visible = true;
    flashmo_play.visible = false;
    unpause_it();
    }

    function pause_it():void
    {
    item_paused = true;
    flashmo_pos = flashmo_sc.position;
    flashmo_sc.stop();
    flashmo_sc.removeEventListener( Event.SOUND_COMPLETE, next_item_handler );
    }

    function unpause_it():void
    {
    item_paused = false;
    flashmo_sc = flashmo_s.play( flashmo_pos );
    flashmo_sc.addEventListener( Event.SOUND_COMPLETE, next_item_handler );
    }

    function on_click_next( me:MouseEvent ):void
    {
    play_next_item();
    }

    function on_click_prev( me:MouseEvent ):void
    {
    play_prev_item();
    }

    function play_next_item():void
    {
    if( flashmo_cpi < total_items - 1 )
    flashmo_cpi++;
    else
    flashmo_cpi = 0;

    play_item();
    }

    function play_prev_item():void
    {
    if(flashmo_cpi > 0)
    flashmo_cpi--;
    else
    flashmo_cpi = total_items - 1;

    play_item();
    }

    function scroller_drag( me:MouseEvent ):void
    {
    me.target.startDrag(false, drag_area);
    status_bar.status_bar_scroller.addEventListener( Event.ENTER_FRAME, on_scroll );
    status_bar.fm_bar.removeEventListener( Event.ENTER_FRAME, item_progress );
    stage.addEventListener( MouseEvent.MOUSE_UP, up );
    }

    function scroller_drop( me:MouseEvent ):void
    {
    me.target.stopDrag();
    }

    function position_seek( me:MouseEvent ):void
    {
    status_bar.status_bar_scroller.startDrag(true, drag_area);
    status_bar.status_bar_scroller.addEventListener( Event.ENTER_FRAME, on_scroll );
    status_bar.fm_bar.removeEventListener( Event.ENTER_FRAME, item_progress );
    stage.addEventListener( MouseEvent.MOUSE_UP, up );
    }

    function up( me:MouseEvent ):void
    {
    status_bar.status_bar_scroller.stopDrag();
    set_progress();

    status_bar.fm_bar.addEventListener( Event.ENTER_FRAME, item_progress );
    status_bar.status_bar_scroller.removeEventListener ( Event.ENTER_FRAME, on_scroll );
    stage.removeEventListener( MouseEvent.MOUSE_UP, up );
    }

    function on_scroll( e:Event ):void
    {
    status_bar.fm_bar.width = status_bar.status_bar_scroller.x;
    var playback_ratio:Number = ( status_bar.fm_bar.width / status_bar.load_progress_bar_bg.width )
    * estimated_length * 0.001;

    playback_min = Math.floor(playback_ratio / 60);
    playback_sec = Math.floor(playback_ratio % 60);

    status_bar.status_text.text = pad_zero(playback_min) + ":" + pad_zero(playback_sec)
    + " / " + pad_zero(total_min) + ":" + pad_zero(total_sec);
    }

    function set_progress():void
    {
    var load_time:Number = flashmo_s.bytesLoaded / flashmo_s.bytesTotal;
    var estimated_length:int = Math.ceil( flashmo_s.length / load_time );
    var pos:Number = estimated_length * ( status_bar.status_bar_scroller.x / status_bar.load_progress_bar_bg.width );

    if( !item_paused )
    {
    if( Math.ceil(pos) == estimated_length )
    {
    play_next_item();
    }
    else
    {
    flashmo_sc.stop();
    flashmo_sc = flashmo_s.play(pos);
    flashmo_sc.addEventListener( Event.SOUND_COMPLETE, next_item_handler );
    }
    }
    else
    {
    if( pos == estimated_length )
    pos = pos - 1;
    flashmo_pos = pos;
    }
    }

    function item_progress( e:Event ):void
    {
    if( !item_paused )
    {
    var load_time:Number = flashmo_s.bytesLoaded / flashmo_s.bytesTotal;
    estimated_length = Math.ceil( flashmo_s.length / load_time );

    playback_min = Math.floor( ( flashmo_sc.position * 0.001 ) / 60);
    playback_sec = Math.floor( ( flashmo_sc.position * 0.001 ) % 60);
    total_min = Math.floor( ( estimated_length * 0.001 ) / 60 );
    total_sec = Math.floor( ( estimated_length * 0.001 ) % 60 );

    status_bar.fm_bar.width = Math.round( flashmo_sc.position / flashmo_s.length * status_bar.load_progress_bar.width );
    status_bar.status_bar_scroller.x = status_bar.fm_bar.width;
    status_bar.status_text.text = pad_zero(playback_min) + ":" + pad_zero(playback_sec) + " / " +
    pad_zero(total_min) + ":" + pad_zero(total_sec) ;
    }
    }

    function drag_area_progress( e:Event ):void
    {
    drag_area = new Rectangle(0, status_bar.status_bar_scroller.y, status_bar.load_progress_bar.width, 0);

    if( status_bar.load_progress_bar.width == status_bar.load_progress_bar_bg.width )
    status_bar.load_progress_bar.removeEventListener( Event.ENTER_FRAME, drag_area_progress );
    }

    function pad_zero( str_to_pad:Number ):String
    {
    if(str_to_pad < 10)
    return "0" + str_to_pad;
    else
    return String( str_to_pad );
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center