Import/embed XML file for export?
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Import/embed XML file for export?

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2

    Import/embed XML file for export?

    How do I import or embed an XML file so I can export a 100% independent SWF? My project reads an external XML file for text fields and images. When I export the SWF, none of the images/text will show unless I have the XML file in the same directory. I want a 100% independent SWF without the need for the XML.

    Thanks.

  2. #2
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Since it doesn't allow me to edit my own post here's an update:

    Here's what I have so far, this is from a tutorial:

    Code:
    import com.greensock.*;
    import flash.events.Event; 
    import flash.events.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.display.MovieClip; 
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.utils.ByteArray;
     
     
    var imageArray:Array = new Array();
    var painterArray:Array = new Array();
    var titleArray:Array = new Array();
    var dateArray:Array = new Array();
     
     
    //Loader event for the XML
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, onLoaded);
     
     
    var xml:XML;
     
     
    loader.load(new URLRequest("mday.xml"));
     
     
    function onLoaded(e:Event):void {
        //load XML
        xml=new XML(e.target.data);
        var il:XMLList=xml.images;
        listLength=il.length();
        //fill up the array from XML
        populateArray();
    }
     
     
    function populateArray():void {
        //takes the properties defined in the XML and stores them into arrays
        var i:Number;
        for (i = 0; i < listLength; i++) {
            imageArray[i]=xml.images[i].pic;
            titleArray[i]=xml.images[i].title;
            painterArray[i]=xml.images[i].painter;
            dateArray[i]=xml.images[i].date;
        }
    }
    The AS is attached to a keyframe, not in its separate class.

    Thanks.

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

Poll by Flashkit.com