Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 04:40
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  Populating listboxes embedded in an accordion from an XML file... Help!
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Populating listboxes embedded in an accordion from an XML file... Help!  (Read 694 times)
TooDerisive
Server what's that
*
Posts: 1


View Profile Email
« on: 01/06/07, 19:56 »

I'm having a hard time understanding why this won't work I'm hoping someone here can help me.

I have an XML file as such:
<?xml version="1.0"?>
<galleries>
   <gallery id="animations" displayName="Animation">
      
   </gallery>
   <gallery id="graphics" displayName="Graphic Designs">
   
   </gallery>
   <gallery id="illustrations" displayName="Illustrations">
      <item id="tu" displayName="Tu" src="illustrations/tu.jpg">This is a character</item>
      <item id="pirate" displayName="Pirate" src="illustrations/pirate.jpg">This is a</item>
      <item id="psyloke" displayName="Psyloke" src="illustrations/psyloke.jpg">X-Men</item>
   </gallery>
   <gallery id="websites" displayName="Web Design">
   
   </gallery>
</galleries>

Then I have my flash document which has
an accordion instanced as "navAccordion" on my main timeline
I created a movie clip named "listBoxContainer" and added a listbox to the movie clip instancing it as "listBoxContainer"

Then I have my external as file:
_global.style.setStyle( "themeColor", "haloOrange" );

import mx.core.View;

var xml = new XML();        //setup a variable to hold the XML
xml.ignoreWhite = true;
xml.load( "galleries.xml" );    //load the XML file
//The following gets called when the XML has been loaded
xml.onLoad = function( status )  {
   if ( !status )
      trace( status );
   var galleries = this.firstChild.childNodes;
   for( var i = 0; i < galleries.length; i++ ){
         gallery = galleries[ i ];
         var tab = navAccordion.createChild( "listBoxContainer", gallery.attributes.id, {label: gallery.attributes.displayName });      
         var files = gallery.childNodes;
         for( var j = 0; j < files.length; j++ ){
               var file = files[ j ];
               tab.listBoxContainer.addItem( file.attributes.displayName );
         }
   }
} //end xmllist.onload

Here's the deal.  It populates the accordion tabs correctly and applies a listbox instance to each of them.  But it will not populate the listboxes.
If I do it manually OUTSIDE the onLoad function then it works... otherwise no joy.

Please help!
-TooDerisive

Logged
Andresss
Moderator
Systems Administrator
*****
Posts: 738


check me out at www.asb-labs.com/blog


View Profile WWW Email
« Reply #1 on: 01/08/07, 11:50 »

hey hi welcome aboard,have you tried using a trace()??, inside your MC the "listBoxContainer" trace the level:
trace(this), and you'll see that the level is static so instead of using:

tab.listBoxContainer.addItem( file.attributes.displayName );
//use the level traced for instance:
traced_level.listBoxContainer.addItem({label:file.attributes.displayName,data:""});
//

now as i saw in your code you say you have the same name for the listBox and for its parent MC, you should try with different names so you don't get confusing at all, for example here:

tab.listBoxContainer.addItem( file.attributes.displayName );//if both the list and the container MC have the same name, i believe you missed one instance name:
tab.listBoxContainer.listBoxContainer.addItem( file.attributes.displayName );

hope it helps

cheers!!
Logged

halemos de flash en espaņol!....wondering about crazy flash experiments?
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything