Loading Arrays to XML Object

Could you please let me know, what would be the best approach in loading a String array of data(about 300 elements) to XML object's Setter method's.

Thanks for your response...
Do I have to write 300 setter methods to load the individual element in the array ?
I have 300 elements in a String array and I have about 300 XML elements too.
Here is what I want to do.
Take the first String element in the array and set the value to the first XML element. (i.e.) setElement1(arrayOfData[1]), and the second String element to the second XML element, setElement2(arrayOfData[2]) and so on... (upto 300 elements).

Similar Messages

  • Loading and viewing XML when a class object is created..Help Please

    Hello,
    I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
    Class object is instantiated
    Class construtor then calls the loadXML method which laods the XML
    And then assigns the XML to a class instance variable.
    So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. I would highly appreciate it if someone can help in the right direction, please.
    [code]
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        public class Cars extends MovieClip {
               public var _CarList:Object;
               public function Quiz()
                  super();
                  loadCars();
    // ===========================================================
    //           CARS GETTER SETTER
    // ===========================================================
            public function set Cars(val:XML):void
                this._CarList = val;
            public function get Cars():XML
                return this._CarList;
    // ===========================================================
    //            LOAD QUESTIONS FROM XML
    // ===========================================================
            public function loadcars()
                var myXML:XML;
                var myLoader:URLLoader = new URLLoader();
                myLoader.load(new URLRequest("xml/cars.xml"));
                myLoader.addEventListener(Event.COMPLETE, processXML);
                function processXML(e:Event):void
                    myXML = new XML(e.target.data);  
                    Cars = myXML;                 // Assigning the loaded xml data via mutator method to the _CarList;
    //=============================================================  
                                  INSTANTIATING THE CLASS OBJECT
    //=============================================================
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        import com.as3.app.*;
        public class DocumentClass extends MovieClip {
            public var c:Car;
            public function DocumentClass()
                super();
                c = new Cars();  
                trace(c.Cars);
    [/code

    where you have:
                super();
                c = new Cars();  
                trace(c.Cars);
    c.Cars will not trace as the loaded xml, because it will not have loaded in time. After some time it should presumably have the correct value.
    loading operations in actionscript are asynchronous, so your nested function which is acting as the listener ( function processXML(e:Event):void) only ever executes when the raw xml data has loaded and that is (I believe, not 100% sure) always at least one frame subsequent to the current one.
    In general I would consider it bad practise to use nested functions like that, but I don't think its contributing to your issues here. I think its just a timing issue given how things work in flash....
    Additional observation:
    your Cars constructor calls loadCars() and your loadCars method is defined as:
    public function loadcars()
    I assume its just a typo in the forum that the uppercase is missing in the function name....

  • Spry = Exception caught while loading data.xml [object Error]

    Exception caught while loading data.xml [object Error]
    I get this mistake message then I look in the Browser to my
    create html page with put in the xml file by Spry. All my xml files
    are not shows, its shows only the error massage.
    What can I do for the repair it?
    Thanks in advance for you answer and regards.

    Hi Jay,
    While in theory it should work offline, you have run into
    the main issue.
    IE7 has a security limitation that prevents the ActiveX
    control that does the XMLHttpRequest from working from the local
    file system.
    Without being about to control the viewing environment, you
    can't guarantee it will work in all instances.
    It will work if running off a web server (
    http://localhost or otherwise).
    I wouldn't recommend it for offline use unless you can
    control the usage.
    Let me know if you have further questions.
    Thanks,
    Donald Booth
    Adobe Spry Team

  • Exception caught while loading clients.xml: [object Error] in IE

    I’m following lesson 9 from Adobe Dreamweaver CS3
    Classroom in a Book which starts with viewing in a browser the
    final web page provided on the CD that comes with the book.
    The problem is that when I browse that file, IE 7 gives this
    error:
    quote:
    Exception caught while loading clients.xml: [object Error]
    Other browsers and versions of IE display the
    page fine.
    From Dreamweaver I ran Browser Compatibility check and it
    reported this:
    quote:
    Found 1 errors in external css files
    Affects: Firefox 1.5; Internet Explorer 6.0, 7.0; Netscape
    8.0; Opera 8.0, 9.0
    Found 2 errors in external css files
    Affects: Internet Explorer for Macintosh 5.2
    Found 3 errors in external css files
    Affects: Safari 2.0
    All errors point to this code from the same
    line:
    href="css/main.css
    and the whole line is:
    <link href="css/main.css" rel="stylesheet" type="text/css"
    media="screen" />
    I also ran validation of the file and it reported this:
    quote:
    2 The tag: "html" doesn't have an attribute: "xmlns:spry" in
    currently active versions.[XHTML 1.0 transitional]
    114 The tag: "div" doesn't have an attribute: "spry:region"
    in currently active versions.[XHTML 1.0 transitional]
    117 The tag: "th" doesn't have an attribute: "spry:sort" in
    currently active versions.[XHTML 1.0 transitional]
    118 The tag: "th" doesn't have an attribute: "spry:sort" in
    currently active versions.[XHTML 1.0 transitional]
    120 The tag: "tr" doesn't have an attribute: "spry:setrow" in
    currently active versions.[XHTML 1.0 transitional]
    120 The tag: "tr" doesn't have an attribute: "spry:select" in
    currently active versions.[XHTML 1.0 transitional]
    120 The tag: "tr" doesn't have an attribute: "spry:repeat" in
    currently active versions.[XHTML 1.0 transitional]
    120 The tag: "tr" doesn't have an attribute: "spry:odd" in
    currently active versions.[XHTML 1.0 transitional]
    120 The tag: "tr" doesn't have an attribute: "spry:hover" in
    currently active versions.[XHTML 1.0 transitional]
    128 The tag: "div" doesn't have an attribute:
    "spry:detailregion" in currently active versions.[XHTML 1.0
    transitional]
    129 The tag: "div" doesn't have an attribute: "tabindex" in
    currently active versions.[XHTML 1.0 transitional]
    134 The tag: "div" doesn't have an attribute:
    "spry:detailregion" in currently active versions.[XHTML 1.0
    transitional]
    143 The tag: "div" doesn't have an attribute:
    "spry:detailregion" in currently active versions.[XHTML 1.0
    transitional]
    The problem is that I don’t know what to do next and if
    and how this file can be fixed.
    Will appreciate greatly your help
    Thank you

    Another bump
    hoping the experts here might help if they check the files, I
    uploaded the project on a public site. You can download it from
    here:
    http://savefile.com/files/1452147
    at he bottom of the page click Download and on the next page
    at the bottom click Download file now
    These are the troubleshooting steps and solutions I
    attempted.
    After I ran check Browser Compatibility it showed problems
    located in main.css file
    I opened main.css and ran Browser Compatibility there too.
    The problems were listed as the following:
    Error Unsupported property: content
    Internet Explorer 6.0, 7.0; Internet Explorer for Macintosh
    5.2
    line 75 .clearfix:after { content: "."; display: block;
    height: 0; clear: both; visibility: hidden; }
    Error Unsupported property: zoom
    Firefox 1.5; Internet Explorer for Macintosh 5.2; Netscape
    8.0; Opera 8.0, 9.0; Safari 2.0
    line 82 .clearfix { zoom: 1; }
    Error Unsupported value: 'hand'
    Safari 2.0
    line 150 .hoverRow, .selectRow{ background-color: #FFFF00;
    cursor: pointer; cursor: hand; }
    also lines 157
    Warning Unsupported value: 'hand'
    Firefox 1.5; Internet Explorer 6.0, 7.0; Internet Explorer
    for Macintosh 5.2; Netscape 8.0
    line 150 .hoverRow, .selectRow{ background-color: #FFFF00;
    cursor: pointer; cursor: hand; }
    also lines 157
    I deleted unsupported properties and changed the unsupported
    value of hand to default and saved the main.css.
    Unfortunately IE still couldn't render the page showing the
    same error.
    I searched the CSS Advisor web site and even entire Google
    but except a few people reporting the same error no solution was
    posted.
    I also tied to contact the publisher of the book but I didn't
    get any replies with solutions yet.
    Since this is a learning project I'm trying to prepare myself
    for real live scenarios and wonder what experienced users would do
    when facing a similar problem if the project was for a client. What
    would you do. What is an acceptable practice? If you can't find a
    solution what would you say to your clients "well IE 7 can't render
    certain things from your page and there is nothing I can do about
    it"?
    I'll appreciate any input

  • Ie7 problem " Exception Caught while loading corporate.xml: [Object Error]

    I am working with spry in dreamweaver cs3. My xml file is as
    simple as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <corporate>
    <item>
    <item_menu>Welcome letter</item_menu>
    <menu_content><![CDATA[<p>Welcome content
    goes here<p>]]></menu_content>
    </item>
    </corporate>
    I add a dataset contain this xml file to an html page using
    the CS3 "insert dataset command". Once I add the dataset to the
    page, IE7 can not load the corporate.xml. The corporate.xml is on
    available in the right folder. This problem does not occur in
    Fireforx, but it occurs in IE7. I need help. Thanks

    I am working with spry in dreamweaver cs3. My xml file is as
    simple as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <corporate>
    <item>
    <item_menu>Welcome letter</item_menu>
    <menu_content><![CDATA[<p>Welcome content
    goes here<p>]]></menu_content>
    </item>
    </corporate>
    I add a dataset contain this xml file to an html page using
    the CS3 "insert dataset command". Once I add the dataset to the
    page, IE7 can not load the corporate.xml. The corporate.xml is on
    available in the right folder. This problem does not occur in
    Fireforx, but it occurs in IE7. I need help. Thanks

  • Internal.text parsed by XML object ?

    Is it possible to use the XML object to parse internal xml
    instead of loading an external file?
    I am writing an application that converts arrays &
    objects into xml.
    In my development, I am displaying the xml in a text field on
    the stage. In testing I want to read this text field as a xml file.
    Currently I copy and past the xml from flash into the external xml
    file (with notepad) then reload the xml file with
    sample_xml.load("xml/sample_1.xml");
    Can I point to the text field in flash to get the xml parsing
    instead of the external file?
    Thanks

    Actually two ways:
    var myXML:XML = new XML(myTextField.text)
    or
    var myXML:XML = new XML();
    //maybe:
    myXML.ignoreWhite=true;
    //and later...
    myXML.parseXML(myTextField.text);

  • Load and Send XML values

    I am new to ActionScript 3 and have a project I would like to get some help on. I have an XML file on a server that has two types of parent nodes... an example is below:
    <bodytypesuggestions>
    <ID1>36</ID1>
    <ID2>34</ID2>
    <ID3>37</ID3>
    </bodytype>
    <bodytypes>
    <ID1>34</ID1>
    <ID2>32</ID2>
    <ID3>35</ID3>
    </bodytype>
    The AS code below connects my flash to the URL:
    import flash.net.*;
    import flash.events.*;
    var myXML:XMLList;
    var url:URLRequest = new URLRequest("MYSERVER.COM");
    var XMLLoader:URLLoader = new URLLoader(url);
    XMLLoader.addEventListener(Event.COMPLETE, GetRecommendations);
    XMLLoader.addEventListener(Event.CHANGE, updateAndGetRecommendations);
    function GetSuggestions(event:Event):void {
    if (XMLLoader.data) {
    myXML = XMLList(XMLLoader.data);
    var myDev:XMLList = new XMLList(XMLLoader.data)
    var bodytypelist:XMLList = myDev..bodytypes
    var bydytypesugglist:XMLList = myDev..bodytypesuggestions
    trace(bodytypelist);
    this["ID1"].text = bodytypelist.ID1;
    this["ID1"].restrict = "0-9.";
    this["ID1"].maxChars = 5;
    this["ID2"].text = bodytypelist.ID2;
    this["ID2"].restrict = "0-9.";
    this["ID2"].maxChars = 5;
    this["ID3"].text = bodytypelist.ID3;
    this["ID3"].restrict = "0-9.";
    this["ID3"].maxChars = 5;
    Now in my flash file, I have 3 textInput fields that are populated with the above XML values from the bodytype child values.
    My question is - how can I write a function that when a user changes a value in any one of the text fields, the data returned is from the bodytypesuggestions node value instantly, i.e. once a field value is changed, the other two will change accordingly. The actual XML on the server already handles those calculations. I hope this makes sense, I really need some help on this one.

    I am not 100% certain what you're asking for here...
    I would tend to send XML rather than an XMLList string. I can't get the e4x filtering to work for an XMLList like that, which means (I assume) that you would need to iterate the list and using filtering on each XML object in the list. Perhaps I've missed something as you don't seem to be expressing a problem with loading the xml data and getting it into the textfields initially. I've not tried using the filtering on an XMLList directly before but could not get it working the way you have it. So in the following simulation I have wrapped the list in a top level tag to get it working the way I wanted.
    Here is a non-loading simulation of what you seem to want. The difference here is that the GetSuggestions 'listener' is called manually with the data string rather than by the URLLoader's listener with the data attached to the URLLoader's dispatched event.
    Hope that helps some.
    var xStr:String="<bodytypesuggestions><ID1>36</ID1><ID2>34</ID2><ID3>37</ID3></bodytypesuggestions><bodytypes><ID1>34</ID1><ID2>32</ID2><ID3>35</ID3></bodytypes>";
    var myXML:XML;
    var suggestions:XMLList;
    //requires 3 input textfields on the stage named ID1, ID2, ID3
    function GetSuggestions(data:String):void {
    if (data) {
    var myXML:XML = XML("<wrapper>"+XMLList(data).toXMLString()+"</wrapper>");
    var bodytypelist:XMLList = myXML..bodytypes;
    suggestions = myXML..bodytypesuggestions;
    ID1.text = bodytypelist.ID1;
    ID1.restrict = "0-9.";
    ID1.maxChars = 5;
    ID2.text = bodytypelist.ID2;
    ID2.restrict = "0-9.";
    ID2.maxChars = 5;
    ID3.text = bodytypelist.ID3;
    ID3.restrict = "0-9.";
    ID3.maxChars = 5;
    GetSuggestions(xStr)
    ID1.addEventListener(Event.CHANGE,myTextListener)
    ID2.addEventListener(Event.CHANGE,myTextListener)
    ID3.addEventListener(Event.CHANGE,myTextListener)
    function myTextListener(e:Event):void{
         var updates:Array = ['ID1','ID2','ID3'];
         //check to see if current value is recognized
         if (TextField(e.currentTarget).text == suggestions.elements(TextField(e.currentTarget).name).text()){
              trace('found match')
              for each(var fieldName:String in updates){
                   if (TextField(e.currentTarget).name==fieldName) continue;
                   TextField(this[fieldName]).text = suggestions.elements(fieldName).text();
                   trace(' set '+fieldName + ' to '+TextField(this[fieldName]).text)

  • Loading a tree of objects from a cache in a single call using an aggregator

    Hi,
    I currently have the following problem. I am trying to load a tree of objects from coherence by recursing up an object tree from a child object.
    What is currently in place is something like this (not actual implementation).
    Child child...// initialisation of Child;
    List<Parent> parents = new LinkedList<Parent>();
    Parent parent = null;
    int parentId = child.getParentId();
    while (true) {
    parent = cache.get(parentId);
    if (parent != null) {
    parents.add(parent);
    parentId = parent.getParentId();
    } else {
    break;
    However, this results in a number of calls over the network to the coherence cache and is proving to be quite inefficient. What I would like is to be able to write something like a filter or an aggregation function which will simply take in the child, or the parent id of the child, and return a list of all the parents (with the recursion logic taking place on the coherence node). This will hopefully reduce network latency considerably.
    Does anybody know how to go about doing this within coherence?

    XML might be a better solution, but using tags should work.
    The Sun tutorial at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags5.html#68205 should be helpful to you.
    When processing a tag, determine if there is a parent tag by using getParent() or findAncestorWithClass().
    If there is no parent, instantiate your site navigation object based on the tag arguments and save a reference within the tag object. You'll probably want to also add the reference to page or session scope as an attribute for later use.
    If there is a parent, instantiate the new navigation object and then retrieve the parent navigation object from the parent tag (create a getNavigation() method in tag?). Then add the new navigation object to the array in the parent navigation object.

  • Passing data from an XML object to an itemRenderer

    I'm trying to color the background of a column in a datagrid and have found a sample file that illustrate the concept. However, the sample has data stored in an arrayCollection whereas mine is in an XML object. The problem is that the data in the sample file is apparently automatically passed to the itemRenderer (shown below: note the trace statement). My XML object does not appear to automatically pass data to the itemRenderer. So my questions are:
    1. Is there a simple way to pass data stored in an XML object to an itemRenderer
    or
    2. Should I convert my XML to an arrayCollection? If so, what's the best way to do this-- I've tried the following, but without success:
    <mx:Model id="xmldata" source="example3.xml"/>
      <mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(xmldata.Example1)}" />
    Here's what the xml looks like:
    <TABLE>
       <EXAMPLE1>
          <difficulty> 0.5 </difficulty>
          <discrimination> 0.7 </discrimination>
          <item> 3 </item>
       </EXAMPLE1>
    </TABLE>  
    Here's the itemRenderer:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
        <!--
            This item renderer simply extends Label and overrides the updateDisplayList function to
            draw a gradient-filled rectangle. The colors in the gradient are determined from the
            data.
        -->
        <mx:Script>
        <![CDATA[
            import flash.geom.Matrix;
            import flash.display.GradientType;
            import flash.display.Graphics;
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                var m:Matrix = new Matrix();
                m.createGradientBox(unscaledWidth,unscaledHeight);
                var g:Graphics = graphics;
                            trace("data.col3="+data.col3)
                var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
                g.clear();
                g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
                // the rectangle is drawn a little high and a little tall to compensate for the gap
                // the DataGrid introduces between rows.
                g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
                g.endFill();
        ]]>
        </mx:Script>
    </mx:Label>

    This sample code should answer your question of how to bring data into the renderer automatically. It comes in via the DataGrid dataProvider and then you refer to it in the renderer as data.XYZ, where XYZ is the field in the XML with the data. See FB 3 help sys on e4x syntax.
    ------------------ mainapp.mxml --------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="srvc.send();">
      <mx:Script>
        <![CDATA[
          import mx.rpc.events.ResultEvent;
          import mx.collections.XMLListCollection;
          [Bindable] private var xlc:XMLListCollection;
          private function dataHandler(evt:ResultEvent):void{
            xlc = new XMLListCollection(evt.result..EXAMPLE1 as XMLList);
        ]]>
      </mx:Script>
      <mx:HTTPService id="srvc" url="data2.xml" result="dataHandler(event)"
        resultFormat="e4x"/>
      <mx:DataGrid dataProvider="{xlc}">
        <mx:columns>
          <mx:DataGridColumn headerText="Difficulty" dataField="difficulty"/>
          <mx:DataGridColumn headerText="Discrimination" dataField="discrimination"/>
          <mx:DataGridColumn headerText="Item" itemRenderer="MyLabel"/>
        </mx:columns>
      </mx:DataGrid>
    </mx:Application>
    ----------- MyLabel.mxml --------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import flash.geom.Matrix;
          import flash.display.GradientType;
          import flash.display.Graphics;
          override protected function updateDisplayList(unscaledWidth:Number,
            unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            this.text = data.col3;
            var m:Matrix = new Matrix();
            m.createGradientBox(unscaledWidth,unscaledHeight);
            var g:Graphics = graphics;
            var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
            g.clear();
            g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
            g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
            g.endFill();
        ]]>
      </mx:Script>
    </mx:Label>
    ------------ data2.xml ----------------
    <?xml version="1.0" encoding="utf8"?>
    <TABLE>
       <EXAMPLE1>
          <difficulty> 0.5 </difficulty>
          <discrimination> 0.7 </discrimination>
          <col3> 3 </col3>
       </EXAMPLE1>
    </TABLE>

  • Placing a variable value into an XML Object

    I am trying to figure out how I would get the value of a variable into an XML Object.
    I have the variable
    var dragonName:String = "Samuel";
    var listing:XML = new XML();
    listing = <thedragon>
                            <dragon>
                                  <myname> dragonName.valueOf()</myname>
                             </dragon>
                   </thedragon>
    However, the dragon name does not show up when I go trace(listing);
    How do I do it and should I have imported something as well or what?

    yeah - in fact you can do all sort of things. This is extremely useful when you creating an XML dynamically e.g.
    var names:Array = ["Sammy", "Samuel", "Sancho"];
    var xml:XML =     <dragon>
                         <myname>{Math.floor(Math.random()*names.length) < 2 ? names[1] : names[Math.round(Math.PI) - 1]}</myname>
                      </dragon>;
    or you can even run a function:
    var xml:XML =     <dragon>
                         <myname>{dragonName()}</myname>
                      </dragon>;
    private function dragonName():String {
       return "Samuel";

  • Loading swf with XML on Click

    Hi all, can anyone help
    can anyone shine a little light onto a little confusion I am having, I have a menu that already loads in images via an XML file on a menu, what I am trying to do is when an image/meni Item is click I would like to load in an swf into the same place as the image Item loads into! am I making any sense.
    on a click event, do I use in the XML file the <link>link to swf</link>   ????
    this is what I have in my xml file that loads in the images so far;
    <image name="image 12" path="img/img12.jpg"
    title="Lorem ipsum 12"
    text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo 12" />
    what I am getting confused with is what I also put within the AS, I am sure it is not alot but I'm just not sure what needs to go where??
    this is what I have within the AS that loads in XML, I hope its ok to paste this code, never like posting to much code incase is scares people off, I just don't want to leave anything out, hope thats ok with everyone:eek:
    // Use URLLoader to load XML
    xmlLoader = new URLLoader();
    xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
    // Listen for the complete event
    xmlLoader.addEventListener(Event.COMPLETE, onXMLComplete);
    xmlLoader.load(new URLRequest("data.xml")); 
    stage.addEventListener( MouseEvent.MOUSE_WHEEL, onMouseWheel );
    //———————————————EVENT HANDLERS
    private function onXMLComplete(event:Event):void
    // Create an XML Object from loaded data
    var data:XML = new XML(xmlLoader.data);
    // Now we can parse it
    var images:XMLList = data.image;
    for(var i:int = 0; i < images.length(); i++)
    // Get info from XML node
    var imageName:String = images[i].@name;
    var imagePath:String = images[i].@path;
    var titles:String = images[i].@title;
    var texts:String = images[i].@text;
    // Load images using standard Loader
    var loader:Loader = new Loader();
    // Listen for complete so we can center the image
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageComplete);
    loader.load(new URLRequest(imagePath));
    // Create a container for the loader (image)
    var holder:MovieClip = new MovieClip();
    holder.addChild(loader);
    var button_main:Button_mr = new Button_mr();   /
    holder.addChild(button_main);               
    var tooltip:ToolTip = new ToolTip();
    tooltip.field.text = titles;  //loads tooltip 1
    tooltip.field2.text = texts;  //loads tool tip 2
    tooltip.x = -350; 
    tooltip.y = 0;   
    holder.addChild(tooltip);
    // Same proceedure as before
    holder.buttonMode = true;
    holder.addEventListener( MouseEvent.CLICK, onMenuItemClick );
    // Add it to the menu
    circleMenu.addChild(holder);
    many thanks for any help!!!!

    1. Be sure in main.swf there is no masking or layering hiding
    the reflection area. A way to test quickly is to load in a plain
    master swf that is much larger than the externals swf.
    2. Know the weakness of loadMovie for timing issues that
    require the external movie to be fully loaded before actions are
    taken on it. I see a bunch of these in the code you posted. Best to
    use
    MovieClipLoader.onLoadInit
    before you attempt to access the external swf properties or code or
    add code.
    3. Be sure the code is firing on load and all objects are
    created. Add some trace statements for those objects.
    4. I noticed you do not use BitmapData so this may not be
    relevant but be sure to add
    System.security.allowDomain("*");
    to the main.swf as well as in external swfs and only if you
    are using the BitmapData class.
    5. As I started to look at the code a bit and noticed this
    item:
    There is no constructor for the Flash MovieClip class. You
    will not see a compiler error message because you do not have the
    code wrapped into a class.
    var home:MovieClip = new MovieClip();
    However it does not have impact on the code.
    better would be
    var home:MovieClip;

  • Flash player freeznig when loading in small XML files

    Hi all,
    I could really use some help in finding a reasonable solution
    to this problem. I'm getting a problem where the flash player
    freezes giving the "A script is causing the flash player to run
    slowly" dialog box, when it's trying to load in XML files for
    content. Therre are 15 files and they are all between 1-3kb. I
    wrote a loop so that the next file doesn't begin loadnig until the
    previous file has finished. But on some machines I still randomly
    get this problem.
    I've tried using the download simulator in flash and it seems
    that this error always occurs on lower connection speeds, but we
    are on a fast connection here and I still randomly get it freezing
    I traced which files it freezes on and it's different ones every
    time.
    Any help would be greatly appriciated.
    Thanks.
    Here is the code for my xml functions:
    // LOAD XML CONTENT FILE
    function loadXMLFile(fileName, callBackFunction){
    var_xml = new XML();
    var_xml.load(fileName);
    var_xml.ignoreWhite = true;
    var_xml.onLoad = callBackFunction;
    // FUNCTION: getNodes()
    function getNodes(success) {
    if (success == true) {
    loadParentNode(this);
    else {
    trace("ERROR: XML not loaded");
    // CREATE VARIABLES FROM NODES
    function loadParentNode(myXMLobj) {
    var obj_xml = myXMLobj;
    //Determine number of parent nodes
    var noOfParentNodes = obj_xml.firstChild.childNodes.length;
    var content_xml = findXMLNode(obj_xml, "content");
    if (noOfParentNodes > 0) {
    for (x=0; x < noOfParentNodes; x++){
    var currentNode = content_xml.childNodes[x].nodeName;
    var currentValue = findXMLValue(content_xml, currentNode);
    this[content_xml.childNodes[x].nodeName] = currentValue;
    gotoAndPlay("xmlOK");
    else {
    trace ("1 ERROR: No Parent Nodes Found");
    // GET VALUE OF CHILD NODE
    function getChildNode(sectionName, desiredNodeName) {
    var obj_xml = this.var_xml; // create a pointer to the XML
    object
    var noOfParentNodes = obj_xml.firstChild.childNodes.length;
    if (noOfParentNodes > 0) {
    for (x=0; x < noOfParentNodes; x++){
    //Find parent Node (sectionName)
    if (obj_xml.firstChild.childNodes[x].nodeName ==
    sectionName) {
    var nodeFound = 1;
    var XMLvars = obj_xml.firstChild.childNodes[x];
    var noOfChildNodes = XMLvars.childNodes.length;
    if (noOfChildNodes > 0) {
    for (var i = 0; i < noOfChildNodes; i++) {
    if (XMLvars.childNodes
    .nodeName == desiredNodeName) {
    return XMLvars.childNodes.firstChild.nodeValue;
    } else {
    trace ("ERROR: No Parent Nodes Found");
    if (nodeFound <> 1) {
    trace ("ERROR: Parent Node \"" + XMLnodeName + "\" Not
    Found.");
    //===FIND XML
    NODE=======================================================
    _global.findXMLNode = function(node_xml, XMLnodeName) {
    while (node_xml.nodeType == 1) {
    if (node_xml.nodeName == XMLnodeName) {
    return node_xml;
    } else if (node_xml.firstChild.nodeType == 1){
    checkChildNodes = findXMLNode(node_xml.firstChild,
    XMLnodeName);
    if (checkChildNodes != undefined) return checkChildNodes;
    node_xml = node_xml.nextSibling;
    //===FIND XML
    VALUE=======================================================
    _global.findXMLValue = function(node_xml, XMLnodeName){
    while (node_xml.nodeType == 1) {
    if (node_xml.nodeName == XMLnodeName) {
    return node_xml.firstChild.nodeValue;
    } else if (node_xml.firstChild.nodeType == 1){
    return findXMLValue(node_xml.firstChild, XMLnodeName);
    node_xml = node_xml.nextSibling;
    }

    Hi Rex,
    That plugin version installed is actually the HW accelerated beta version Gala: 10.1.81.25 (The current version is 10.1.81.75).  I would recommend installing the official release, since the Gala version does have some compatibility issues.  You can download the latest version here: http://get.adobe.com/flashplayer/
    -Charbs

  • XML object returns attributes but not elements

    Hi,
    I'm very new to this so my problem is probably down to bad practices but anyhow... I have code as follows:
    var s:String = load.data; //This turns up as fully-formed correct XML every time.
    var docx:XML = new XML(s);
    trace(new String(docx..@src));
    trace(new String(docx..entry));
    In the above the first trace works fine and returns the value of all 'src' attributes found in the document.
    However, the second statement does nothing at all. It should return a list of 'entry' nodes I think.
    The XML document I'm using is found here: http://picasaweb.google.com/data/feed/api/all
    Is the XML object malfunctioning or is my code wrong?
    Thanks
    Jack

    Turns out it was a namespace issue. Here's an explanation for others who get stuck with a similar issue.
    I added these lines to the script in my mxml file:
    private namespace webNameSpace = "http://www.w3.org/2005/Atom";
    use namespace webNameSpace;
    The string "http://www.w3.org/2005/Atom" is taken from the root node of my xml document. In this case it was from the tag:
    <feed
         xmlns='http://www.w3.org/2005/Atom'
         xmlns:exif='http://schemas.google.com/photos/exif/2007'
         xmlns:gphoto='http://schemas.google.com/photos/2007'
         xmlns:media='http://search.yahoo.com/mrss/'
         xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
         xmlns:gml='http://www.opengis.net/gml'
         xmlns:georss='http://www.georss.org/georss'
    >
    Presumably, if I want to use tags that have NS prefixes (eg <gphoto:url>) then I'll need to add the other namespaces for use.
    Still, if anyone has any comments on whether there is a cleaner way to do this, or even just to let me know I'm doing it right, then please post back as I'm very knew to this and would like my code to be corrected/affirmed if possible.
    Thanks all,
    Jack
    EDIT: can I mark my own posts as answered?

  • Clear loaded pictures in xml gallery to load another set

    i cannot figure how to unload my already populated xml gallery, before loading new content :
    here the functions i want :
    //following 2 functions will be called by a button :
    // removes previously placed objects
    function clearLoadedPictures():void {
    // Load another ,xml to load new pictures set - ok : works fine
    function LoadNewPictures():void {
            i_g = 0;
               // xml data
                var xml_gallery:XML                = new XML();
                var xml_gallery_List:XMLList        = new XMLList;
                // XML data loader...
                var xmlUrlReq:URLRequest   = new URLRequest("xml/gallery2.xml");// gallery2.xml will replace gallery.xml already loaded
                var xml_gallery_UrlLoader:URLLoader = new URLLoader(xmlUrlReq);
                xml_gallery_UrlLoader.addEventListener(Event.COMPLETE, xml_gallery_Complete);
                xml_gallery_UrlLoader.addEventListener(IOErrorEvent.IO_ERROR, xml_gallery_LoadFailed);
    here the xml gallery code :
    var _mc:item;
    var total:int;
    var i_g:int;
    var id:int;
    var btn_Gallery_Ready:Boolean;
    var speedX:Number;
    var spaceR:Number;
    var img_gallery_Loader:Loader;
    i_g = 0;
               // xml data
                var xml_gallery:XML                = new XML();
                var xml_gallery_List:XMLList        = new XMLList;
                // XML data loader...
                var xmlUrlReq:URLRequest   = new URLRequest("xml/gallery.xml");
                var xml_gallery_UrlLoader:URLLoader = new URLLoader(xmlUrlReq);
                xml_gallery_UrlLoader.addEventListener(Event.COMPLETE, xml_gallery_Complete);
                xml_gallery_UrlLoader.addEventListener(IOErrorEvent.IO_ERROR, xml_gallery_LoadFailed);
                bottom24.gallery.content_mc.addEventListener(MouseEvent.ROLL_OVER, startScroll);
                bottom24.gallery.content_mc.addEventListener(MouseEvent.ROLL_OUT, stopScroll); //
    // xmlComplete function
            function xml_gallery_Complete(e:Event):void
            xml_gallery = XML(e.target.data); //
                xml_gallery_List = xml_gallery.item;  // <item> in gallery.xml
                total = xml_gallery_List.length();
                spaceR = xml_gallery.attribute("space"); // specified in gallery.xml file as is : <gallery space="119" speed="0.2">
                speedX = xml_gallery.attribute("speed");
                init_gallery();
            function xml_gallery_LoadFailed(e:IOErrorEvent):void {
                trace("Load Failed: " + e);
            function init_gallery()  //
                //bottom.gallery.content_mc.itemHolder_mc.
                _mc = new item(); //
                _mc.alpha = 0;
                //_mc.imgMask_mc.scaleY = 0;  // condition pour apparition des timbres ds la gallery - OLD
                _mc.imgMask_mc.alpha = 0; // condition pour apparition des timbres ds la gallery - NEW
                _mc.x = i_g * spaceR;
                _mc.btn.id = i_g;
                _mc.btn.mouseChildren = false;
                bottom24.gallery.content_mc.itemHolder_mc.addChild(_mc);
                Tweener.addTween(_mc, {alpha:1, time:0.8, transition:"easeOutExpo"});
                _mc.online_mc.alpha = 0; //invisible sans roll over
                if (xml_gallery_List[i_g].url != "")
                    _mc.btn.buttonMode = true;
                    _mc.online_mc.visible = true;
                    btn_Gallery_Ready = true;
                else
                    _mc.btn.buttonMode = false;
                    _mc.online_mc.visible = false;
                    btn_Gallery_Ready = false;
            var imgRequest:URLRequest = new URLRequest (xml_gallery_List[i_g].image); //
             img_gallery_Loader = new Loader(); // var imgLoader:Loader;
                img_gallery_Loader.load(imgRequest); //
                img_gallery_Loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imgLoading);
                img_gallery_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, img_gallery_Complete);
                i_g++;
            function imgLoading(event:ProgressEvent):void // tiny preloader in bottom thumbs pics
        _mc.preloader_mc.width = Math.round(img_gallery_Loader.contentLoaderInfo.bytesLoaded / img_gallery_Loader.contentLoaderInfo.bytesTotal * 100);
            function img_gallery_Complete(event:Event):void
                _mc.imgHolder_mc.addChild(img_gallery_Loader);
                Tweener.addTween(_mc.imgHolder_mc, {_saturation:0.9, time:0.6});// desaturate scrolling thumbs
                //_mc.imgHolder_mc.alpha = 0.5; // test
                // apparition des timbres ds la gallery, ici fade in : - NEW
                Tweener.addTween(_mc.imgMask_mc, {"alpha":1, delay:i_g / 20, time:0.4, transition:"easeOutExpo"});// test
                // apparition des timbres ds la gallery, ici image apparait de haut en bas : - OLD
                //Tweener.addTween(_mc.imgMask_mc, {"scaleY":1, delay:i_g / 10, time:1, transition:"easeOutExpo"});
                // la ligne de preloader qui diminue vers la gauche :
                Tweener.addTween(_mc.preloader_mc, {"scaleX":0, delay:0, time:1, transition:"easeOutExpo"});
                _mc.btn.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
                _mc.btn.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
                _mc.btn.addEventListener(MouseEvent.CLICK, onMouseClick);
                if (i_g < total)
                    init_gallery();
    thanks

    hi,
    back to work,
    then i used a loop in the first clear function:
    var n:int = 0;
                  while (n < xml_gallery_List.length() -1) {
                      bottom24.gallery.content_mc.itemHolder_mc.removeChildAt(n); //
                    i++;
    and it remove all my previously loaded pictures,but it throw me an error :
    RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display: DisplayObjectContainer/removeChildAt()
    it seems error come from the removeChildAt, but i can't figure out what's wrong
    i've tried to replace removeChildAt(n); by removeChild(n); and the loop crash Flash software....
    any suggestion ?

  • Loading and unloading xml galleries

    I have a several galleries that I will be loading via several xml files.  Gallery1 will load on start and the other galleries will load through buttons using their instance names (i.e. "gallery3" button will load "gallery3.xml").  Currently I have a function + listener (called "home") to initiate gallery1 on start, a function + listener (called "goSection") to initiate the other galleries via button instance name, and a function that loads the gallery (called "fileLoaded") with the listener located in the "home" and "goSection" functions.  There is a lot more code in the fileLoaded function that controls the thumbnail and full size images functionality that I am excluding because its probably not necessary for my problem.  Im not sure the most efficient way to set this all up so I unload the existing gallery before I load a new gallery.  Ive tried to use removeChild and removeEventListener on urlLoader without much success.  Any suggestions?  ...
    //BUTTONS
    var sButtons:Array = [gallery1,gallery2,gallery3,gallery4];
    function sButtonsListeners():void {
         for (var i:uint = 0; i < sButtons.length; i++) {
         sButtons[i].addEventListener(MouseEvent.CLICK, goSection);
    sButtonsListeners();
    var urlLoader:URLLoader = new URLLoader();
    //INIT HOME
    function home():void {
         trace("gallery1 loaded");
         //load external xml
         var urlRequest:URLRequest = new URLRequest("gallery1.xml");
         urlLoader.load(urlRequest);
         urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    home();
    //GO SECTION
    function goSection(event:Event):void {
         trace(instanceName + " loaded");
         var instanceName:String = event.currentTarget.name;
         //load external xml
         var urlRequest:URLRequest = new URLRequest(instanceName + ".xml");
         urlLoader.load(urlRequest);
         urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    function fileLoaded(event:Event):void {
         var myXML:XML = new XML();
         var xmlList:XMLList;
         myXML.ignoreWhitespace = true;
         var arrayURL:Array = new Array();     //thumbnails
         var arrayName:Array = new Array();     //large photos
         var holderArray:Array = new Array();     //thumbnail holder
         var thumb:Thumbnail;     //represents Thumbnail.AS
         //represents the gallery container
         var sprite:Sprite = new Sprite();
         addChild(sprite);
         //thumbnail container
         var thumbsHolder:Sprite = new Sprite();
         sprite.addChild(thumbsHolder);
         //image container
         var imageHolder:Sprite = new Sprite();
         sprite.addChild(imageHolder);
         //load image
         var imageLoader:UILoader = new UILoader();
         imageLoader.buttonMode = true;
         imageHolder.addChild(imageLoader);
         myXML = XML(event.target.data);
         xmlList = myXML.children();
         for (var i:int=0; i<xmlList.length(); i++) {
         var picURL:String = xmlList[i].url;
         var picName:String = xmlList[i].big_url;
         arrayURL.push(picURL);
         arrayName.push(picName);
         holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
         holderArray[i].name = arrayName[i];
         holderArray[i].buttonMode = true;
         holderArray[i].y = 25;
         holderArray[i].x = i * 87 + 142;
         thumbsHolder.addChild(holderArray[i]);

    Anyone?  My biggest concern is unloading the existing gallery before I load a new one.  Currently they load on top of each other.

Maybe you are looking for