get nested xml tags in Flash, loop within loop

  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Hi there,,

I am trying to get this data into flash. I can get the results for each memeber but, when I put in my nested loop to get the information I get the entire array of all the members or just the end results. Here's a bit of the xml file schema first...

Code: [ Select ]
<?xml version="1.0" encoding="iso-8859-1"?>
<coreteam>
    <member>
        <id>1</id>
        <name>Person A</name>
        <location>UK</location>
        <profile></profile>
        <ThumbnailURL></ThumbnailURL>
        <photoURL></photoURL>
        <countriesVisited>
            <country>DB Kenya</country>
            <country>DB Rwanda</country>
            <country>DB Tanzania</country>
            <country>DB Uganda</country>
        </countriesVisited>
    </member>
    
    <member>
        <id>2</id>
        <name>Person B</name>
        <location>UK</location>
        <profile></profile>
        <ThumbnailURL></ThumbnailURL>
        <photoURL></photoURL>
        <countriesVisited>
            <country>TC Egypt</country>
            <country>TC Tanzania</country>
            <country>TC Uganda</country>
        </countriesVisited>
    </member>
    
etc etc....
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <coreteam>
  3.     <member>
  4.         <id>1</id>
  5.         <name>Person A</name>
  6.         <location>UK</location>
  7.         <profile></profile>
  8.         <ThumbnailURL></ThumbnailURL>
  9.         <photoURL></photoURL>
  10.         <countriesVisited>
  11.             <country>DB Kenya</country>
  12.             <country>DB Rwanda</country>
  13.             <country>DB Tanzania</country>
  14.             <country>DB Uganda</country>
  15.         </countriesVisited>
  16.     </member>
  17.     
  18.     <member>
  19.         <id>2</id>
  20.         <name>Person B</name>
  21.         <location>UK</location>
  22.         <profile></profile>
  23.         <ThumbnailURL></ThumbnailURL>
  24.         <photoURL></photoURL>
  25.         <countriesVisited>
  26.             <country>TC Egypt</country>
  27.             <country>TC Tanzania</country>
  28.             <country>TC Uganda</country>
  29.         </countriesVisited>
  30.     </member>
  31.     
  32. etc etc....


now here is the actionscript so far...


Code: [ Select ]
stop();
///set up this default, not worth explaining
XML.prototype.ignoreWhite = true;
///Create a new empty XML Object
var myXMLCoreTeam:XML = new XML();

///load in the xml files
myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team
myXMLCoreTeam.onLoad = function(success){ //open function statement (1)
var rootNode:XMLNode = myXMLCoreTeam.firstChild;
var contentNode:XMLNode = rootNode.firstChild;

//new array for the total number of childNodes
    _global.menuArray = new Array();    
    _global.menuArray = rootNode.childNodes;
    
    _global.numOfItems = _global.menuArray.length;
    _global.team_member_id = new Array();
    _global.team_member_name = new Array();
    _global.team_member_location = new Array();
    _global.team_member_profile = new Array();
    _global.team_member_thumbnail = new Array();
    _global.team_member_photo = new Array();
    _global.team_member_country = new Array();
    _global.team_member_countries = new Array();
    
//set up Arrays for each attribute of each child
        for(var i=0;i<=_global.numOfItems;i++){ // (2) For loop - length ends up being the total number of child rows of <flashMenu> in the XML

            _global.team_member_id.push(menuArray[i].childNodes[0].childNodes[0].nodeValue);
            _global.team_member_name.push(menuArray[i].childNodes[1].childNodes[0].nodeValue);
            _global.team_member_location.push(menuArray[i].childNodes[2].childNodes[0].nodeValue);
            _global.team_member_profile.push(menuArray[i].childNodes[3].childNodes[0].nodeValue);
            _global.team_member_thumbnail.push(menuArray[i].childNodes[4].childNodes[0].nodeValue);
            _global.team_member_photo.push(menuArray[i].childNodes[5].childNodes[0].nodeValue);
            
                        
        for(L=0;L<_global.menuArray[i].childNodes[6].childNodes.length;L++){ //for loop for each country, need to assign to each ID
                        
        _global.team_member_country[i]=_global.menuArray[i].childNodes[6].childNodes[L].childNodes[0].nodeValue;
        trace(_global.team_member_country[i]);
        _global.team_member_countries[i] = _global.team_member_country[i];
            trace(_global.team_member_countries[i]);
            trace(_global.team_member_countries);
        }// close loop
        
} //Close Loop    (2)

    gotoAndPlay("success");
} //Close function (1)
  1. stop();
  2. ///set up this default, not worth explaining
  3. XML.prototype.ignoreWhite = true;
  4. ///Create a new empty XML Object
  5. var myXMLCoreTeam:XML = new XML();
  6. ///load in the xml files
  7. myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team
  8. myXMLCoreTeam.onLoad = function(success){ //open function statement (1)
  9. var rootNode:XMLNode = myXMLCoreTeam.firstChild;
  10. var contentNode:XMLNode = rootNode.firstChild;
  11. //new array for the total number of childNodes
  12.     _global.menuArray = new Array();    
  13.     _global.menuArray = rootNode.childNodes;
  14.     
  15.     _global.numOfItems = _global.menuArray.length;
  16.     _global.team_member_id = new Array();
  17.     _global.team_member_name = new Array();
  18.     _global.team_member_location = new Array();
  19.     _global.team_member_profile = new Array();
  20.     _global.team_member_thumbnail = new Array();
  21.     _global.team_member_photo = new Array();
  22.     _global.team_member_country = new Array();
  23.     _global.team_member_countries = new Array();
  24.     
  25. //set up Arrays for each attribute of each child
  26.         for(var i=0;i<=_global.numOfItems;i++){ // (2) For loop - length ends up being the total number of child rows of <flashMenu> in the XML
  27.             _global.team_member_id.push(menuArray[i].childNodes[0].childNodes[0].nodeValue);
  28.             _global.team_member_name.push(menuArray[i].childNodes[1].childNodes[0].nodeValue);
  29.             _global.team_member_location.push(menuArray[i].childNodes[2].childNodes[0].nodeValue);
  30.             _global.team_member_profile.push(menuArray[i].childNodes[3].childNodes[0].nodeValue);
  31.             _global.team_member_thumbnail.push(menuArray[i].childNodes[4].childNodes[0].nodeValue);
  32.             _global.team_member_photo.push(menuArray[i].childNodes[5].childNodes[0].nodeValue);
  33.             
  34.                         
  35.         for(L=0;L<_global.menuArray[i].childNodes[6].childNodes.length;L++){ //for loop for each country, need to assign to each ID
  36.                         
  37.         _global.team_member_country[i]=_global.menuArray[i].childNodes[6].childNodes[L].childNodes[0].nodeValue;
  38.         trace(_global.team_member_country[i]);
  39.         _global.team_member_countries[i] = _global.team_member_country[i];
  40.             trace(_global.team_member_countries[i]);
  41.             trace(_global.team_member_countries);
  42.         }// close loop
  43.         
  44. } //Close Loop    (2)
  45.     gotoAndPlay("success");
  46. } //Close function (1)


on success I go to the frame label with success and set a menuID to each instance of a movie clip and when I rollover it is suppose to get my list of countries for each person

Code: [ Select ]
L = 0;
pushoverX = 72;
pushoverY = (Stage.width/(_global.numOfItems/2))/2;

while(L<_global.numOfItems){//open loop (1)
        this.attachMovie("thumbnail_container", "thumbnail_container" + L, (-L) , {_x:pushoverX ,_y:pushoverY});
        set("thumbnail_container" + L + ".menuID" , L);
    

                    
            
    with (eval("thumbnail_container" + L )){
        thumbnail_txt = _global.team_member_name[L];
        
                
    }// end with evaluation    
            

        pushoverX = pushoverX + thumbnail_container0._width + _global.Xmargin;
        if(pushoverX >= Stage.width - thumbnail_container0._width - _global.Xmargin){
        pushoverY= pushoverY + thumbnail_container0._height + _global.Ymargin;
        pushoverX= 72;
        }
                    
                    L=L+1;

} // closes loop (1)        
  1. L = 0;
  2. pushoverX = 72;
  3. pushoverY = (Stage.width/(_global.numOfItems/2))/2;
  4. while(L<_global.numOfItems){//open loop (1)
  5.         this.attachMovie("thumbnail_container", "thumbnail_container" + L, (-L) , {_x:pushoverX ,_y:pushoverY});
  6.         set("thumbnail_container" + L + ".menuID" , L);
  7.     
  8.                     
  9.             
  10.     with (eval("thumbnail_container" + L )){
  11.         thumbnail_txt = _global.team_member_name[L];
  12.         
  13.                 
  14.     }// end with evaluation    
  15.             
  16.         pushoverX = pushoverX + thumbnail_container0._width + _global.Xmargin;
  17.         if(pushoverX >= Stage.width - thumbnail_container0._width - _global.Xmargin){
  18.         pushoverY= pushoverY + thumbnail_container0._height + _global.Ymargin;
  19.         pushoverX= 72;
  20.         }
  21.                     
  22.                     L=L+1;
  23. } // closes loop (1)        


on my instance of the persons Icon I have this

Code: [ Select ]

thumb_hit_area.onRelease = function(){
        
        trace(menuID);
        trace(_global.team_member_countries[menuID]);
    
}
  1. thumb_hit_area.onRelease = function(){
  2.         
  3.         trace(menuID);
  4.         trace(_global.team_member_countries[menuID]);
  5.     
  6. }


I know it's something to do with my nested for loop.
I'm trying to get the array to look like this.


Code: [ Select ]
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
trace(ticTacToe[0]);// output: 1,2,3
  1. var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
  2. trace(ticTacToe[0]);// output: 1,2,3


if anyone can help me get the information into the nested array for each person I would be very greatful

thanks

Andi
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

wooow, you sure are a global and old style user :P
From my point of view, i'd use directly movieclips instead of arrays ... or objects. They make life easier.
Maybe your mistake lies within this code:
Code: [ Select ]
with (eval("thumbnail_container" + L )){
   thumbnail_txt = _global.team_member_name[L];
}
  1. with (eval("thumbnail_container" + L )){
  2.    thumbnail_txt = _global.team_member_name[L];
  3. }

If thumbnail_txt is not a variable for the dynamic text, then you should use:
thumbnail_txt.text = _global.team_member_name[L];
If it is a variable, then you might want to embed the font. Stage -> select the text from the movieclip-> goto properties panel -> Character button -> check Specify Ranges and select Basic Latin.
Anyway, consider this code:

Code: [ Select ]
XML.prototype.ignoreWhite = true;
///Create a new empty XML Object
var myXMLCoreTeam:XML = new XML();
///load in the xml files
myXMLCoreTeam.load("coreteam.xml"); // xml xource for the core team
myXMLCoreTeam.onLoad = function(success)
{
    ProcessXMLData();
}

function ProcessXMLData()
{
    var rootNode:XMLNode = myXMLCoreTeam.firstChild;
    var contentNode:XMLNode = rootNode.firstChild;

    menuArray = rootNode.childNodes;
    var numOfItems = menuArray.length;
    
    var pushoverX = 72;    
    var pushoverY = (Stage.width/(numOfItems/2))/2;    

    var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;

    for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++)
    {
        var crtMember = rootNode.childNodes[iNodeIndex0];
        
        var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
        iNodeIndex1 = 0;        
        crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        
        crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
        crtMC.countriesVisited = new Array();
            
        // countries
        var VisitedCountry = crtMember.childNodes[iNodeIndex1];
        var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;

        for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
            crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
            
        // atach thumbnail_container for each member
        crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
       crtMC.thumbnail_container.thumbnail_txt.text = crtMC.countriesVisited;

       pushoverX += thumbnail_container._width + Xmargin;

       if(pushoverX >= Stage.width - crtMC.thumbnail_container._width - Xmargin)
        {
            pushoverY += crtMC.humbnail_container._height + Ymargin;
            pushoverX= 72;
   }
    }
}

var menuArray = new Array();
var Xmargin = 20;
var Ymargin = 30;
stop();
  1. XML.prototype.ignoreWhite = true;
  2. ///Create a new empty XML Object
  3. var myXMLCoreTeam:XML = new XML();
  4. ///load in the xml files
  5. myXMLCoreTeam.load("coreteam.xml"); // xml xource for the core team
  6. myXMLCoreTeam.onLoad = function(success)
  7. {
  8.     ProcessXMLData();
  9. }
  10. function ProcessXMLData()
  11. {
  12.     var rootNode:XMLNode = myXMLCoreTeam.firstChild;
  13.     var contentNode:XMLNode = rootNode.firstChild;
  14.     menuArray = rootNode.childNodes;
  15.     var numOfItems = menuArray.length;
  16.     
  17.     var pushoverX = 72;    
  18.     var pushoverY = (Stage.width/(numOfItems/2))/2;    
  19.     var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;
  20.     for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++)
  21.     {
  22.         var crtMember = rootNode.childNodes[iNodeIndex0];
  23.         
  24.         var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
  25.         iNodeIndex1 = 0;        
  26.         crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  27.         
  28.         crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  29.         crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  30.         crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  31.         crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  32.         crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  33.         crtMC.countriesVisited = new Array();
  34.             
  35.         // countries
  36.         var VisitedCountry = crtMember.childNodes[iNodeIndex1];
  37.         var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
  38.         for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
  39.             crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  40.             
  41.         // atach thumbnail_container for each member
  42.         crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
  43.        crtMC.thumbnail_container.thumbnail_txt.text = crtMC.countriesVisited;
  44.        pushoverX += thumbnail_container._width + Xmargin;
  45.        if(pushoverX >= Stage.width - crtMC.thumbnail_container._width - Xmargin)
  46.         {
  47.             pushoverY += crtMC.humbnail_container._height + Ymargin;
  48.             pushoverX= 72;
  49.    }
  50.     }
  51. }
  52. var menuArray = new Array();
  53. var Xmargin = 20;
  54. var Ymargin = 30;
  55. stop();
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

hmmm. looks good. Will give it a try and let you know...

I learnt the _global. way, your code looks much more tidy than mine.

(Yes the Txt fields are all dynamic text and embedded)

Cheers for now

Andi
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Hi there,

thanks for your help. This code didn't help me much, as it created the movie clips but did not spread them out evenly accross the stage 550 X 420. I had to take the attach movie clips out of the nested loop. I also amended so that it would give a new instance name otherwise it did not work.

I have amended it. It almost works. Each Icon or thumbnail should return information about that person, and a seperate array for the countries they have been to.

Code: [ Select ]
XML.prototype.ignoreWhite = true;

///Create a new empty XML Object

var myXMLCoreTeam:XML = new XML();

///load in the xml files

myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team

myXMLCoreTeam.onLoad = function(success)

{

  ProcessXMLData();

}

function ProcessXMLData()

{

  var rootNode:XMLNode = myXMLCoreTeam.firstChild;

  var contentNode:XMLNode = rootNode.firstChild;

  menuArray = rootNode.childNodes;

  var numOfItems = menuArray.length;

 

  var pushoverX = 72; 

  var pushoverY = (Stage.width/(numOfItems/2))/2; 

  var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;

  for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++)

  {

   var crtMember = rootNode.childNodes[iNodeIndex0];
   var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
    
   iNodeIndex1 = 0;  

   crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

     crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

   crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

   crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

   crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

   crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;

  
     
// atach thumbnail_container for each member

   crtMC.attachMovie("thumbnail_container", "thumbnail_container" + iNodeIndex0, (-iNodeIndex0), {_x:pushoverX ,_y:pushoverY});
        
        set("crtMC.thumbnail_container" + iNodeIndex0 + ".thumbnailID", iNodeIndex0);
        
     with(eval("crtMC.thumbnail_container" + iNodeIndex0)){
            thumbnail_txt = crtMC.sName;
            
            var thumbnailWidth = _parent._width;
            var thumbnailHeight = _parent._height;
            thumb_hit_area.onRelease = function(){
                trace(crtMC.sName);
                
            }
    }
                

        pushoverX += thumbnailWidth + Xmargin;
     if(pushoverX >= Stage.width -thumbnailWidth - Xmargin)
   {

     pushoverY += thumbnailHeight + Ymargin;

     pushoverX= 72;

   }  

    // countries
     
     crtMC.countriesVisited = new Array();
   var VisitedCountry = crtMember.childNodes[iNodeIndex1];
     var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;

   for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)

     crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
      
    
     }
}

var menuArray = new Array();

var Xmargin = 36;

var Ymargin = 24;

stop();
  1. XML.prototype.ignoreWhite = true;
  2. ///Create a new empty XML Object
  3. var myXMLCoreTeam:XML = new XML();
  4. ///load in the xml files
  5. myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team
  6. myXMLCoreTeam.onLoad = function(success)
  7. {
  8.   ProcessXMLData();
  9. }
  10. function ProcessXMLData()
  11. {
  12.   var rootNode:XMLNode = myXMLCoreTeam.firstChild;
  13.   var contentNode:XMLNode = rootNode.firstChild;
  14.   menuArray = rootNode.childNodes;
  15.   var numOfItems = menuArray.length;
  16.  
  17.   var pushoverX = 72; 
  18.   var pushoverY = (Stage.width/(numOfItems/2))/2; 
  19.   var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;
  20.   for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++)
  21.   {
  22.    var crtMember = rootNode.childNodes[iNodeIndex0];
  23.    var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
  24.     
  25.    iNodeIndex1 = 0;  
  26.    crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  27.      crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  28.    crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  29.    crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  30.    crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  31.    crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  32.   
  33.      
  34. // atach thumbnail_container for each member
  35.    crtMC.attachMovie("thumbnail_container", "thumbnail_container" + iNodeIndex0, (-iNodeIndex0), {_x:pushoverX ,_y:pushoverY});
  36.         
  37.         set("crtMC.thumbnail_container" + iNodeIndex0 + ".thumbnailID", iNodeIndex0);
  38.         
  39.      with(eval("crtMC.thumbnail_container" + iNodeIndex0)){
  40.             thumbnail_txt = crtMC.sName;
  41.             
  42.             var thumbnailWidth = _parent._width;
  43.             var thumbnailHeight = _parent._height;
  44.             thumb_hit_area.onRelease = function(){
  45.                 trace(crtMC.sName);
  46.                 
  47.             }
  48.     }
  49.                 
  50.         pushoverX += thumbnailWidth + Xmargin;
  51.      if(pushoverX >= Stage.width -thumbnailWidth - Xmargin)
  52.    {
  53.      pushoverY += thumbnailHeight + Ymargin;
  54.      pushoverX= 72;
  55.    }  
  56.     // countries
  57.      
  58.      crtMC.countriesVisited = new Array();
  59.    var VisitedCountry = crtMember.childNodes[iNodeIndex1];
  60.      var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
  61.    for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
  62.      crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  63.       
  64.     
  65.      }
  66. }
  67. var menuArray = new Array();
  68. var Xmargin = 36;
  69. var Ymargin = 24;
  70. stop();


OK, so I am having trouble setting a unique ID to each movie clip. with this code here...

Code: [ Select ]
  crtMC.attachMovie("thumbnail_container", "thumbnail_container" + iNodeIndex0, (-iNodeIndex0), {_x:pushoverX ,_y:pushoverY});
        
        set("crtMC.thumbnail_container" + iNodeIndex0 + ".thumbnailID", iNodeIndex0);
        
     with(eval("crtMC.thumbnail_container" + iNodeIndex0)){
            thumbnail_txt = crtMC.sName;
            
            var thumbnailWidth = _parent._width;
            var thumbnailHeight = _parent._height;
            thumb_hit_area.onRelease = function(){
                trace(crtMC.sName);
                
            }
    }
  1.   crtMC.attachMovie("thumbnail_container", "thumbnail_container" + iNodeIndex0, (-iNodeIndex0), {_x:pushoverX ,_y:pushoverY});
  2.         
  3.         set("crtMC.thumbnail_container" + iNodeIndex0 + ".thumbnailID", iNodeIndex0);
  4.         
  5.      with(eval("crtMC.thumbnail_container" + iNodeIndex0)){
  6.             thumbnail_txt = crtMC.sName;
  7.             
  8.             var thumbnailWidth = _parent._width;
  9.             var thumbnailHeight = _parent._height;
  10.             thumb_hit_area.onRelease = function(){
  11.                 trace(crtMC.sName);
  12.                 
  13.             }
  14.     }


the function is also returning the last know result in the array, and soes not work if you put it as
trace(crtMC.sName[iNodeIndex0]);

it's why I must try to set the ID of each, I am almost there. The clips are laid out and the names of each person assigned to the dynamic text. But its the function when I click on them that's causing the trouble.

Thanks

Andi
[/quote][/code]
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

ok just got the setting of ID with this

Code: [ Select ]
set(crtMC+ ".thumbnail_container" + iNodeIndex0 +".thumbID", iNodeIndex0);
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

ohhh nooo, don't go old style again.
set(crtMC+ ".thumbnail_container" + iNodeIndex0 +".thumbID", iNodeIndex0);
is the same as
crtMC["thumbnail_container"+iNodeIndex0].thumbID = iNodeIndex0;

And i'm not sure what exactly you trying to do there.
Probably you didn't understand exactly what i did up there. Let me explain it to you.
I create a movieclip for each member, set it's properties (ID, name, location ....), then attach in every member movieclip one single thumbnail_container, since i presume you use only one thumbnail for each member. All you had to do was to dynamically arrange the movieclips on the stage, not to get the thumbnails out of the member movieclips.
If i'm wrong please let me know.
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Sorry.... I am not so good with the new style, lots to learn.

Ok I'll describe what we are trying to achieve here.
I am building a portfolio for a charity organisation.

There is a portfolio which I am building which will load into the main load box on the site. It will be stored as a seperate swf on the server and called into the loadbox when clicked on the portfolio icon. (or the page will end up massive..

So I have and XML file for this swf (see the schema above)
For Each member there is a number of countries which they have done work in.

so from the first set of childnodes in the menuArray we get the basic info about the person, and loads in an icon for each one. When you click in the icon I want to load in the list of each country that person has done work in.

So you get this:

Member A : Tanzania
: Uganda
: Kenya

Menmber B : Ghana
: Uganda

The problem I had was returning all the Countries into a list. component ... addItem in the childnodes of the country

I can get all the countries as a single item in an Array, but not as a list
IE I got

TanzaniaAfricaKenya

instead of

Tanzania
Africa
Kenya

hope this explains better.
Thanks

Andi
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

that's because you pass the array to the list, not each member of the array separated by a "\n" (end of line).
What you need is (i work here on my example, provided upper):

Code: [ Select ]
// countries
   var VisitedCountry = crtMember.childNodes[iNodeIndex1];
   var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
   for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
     crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;

   // atach thumbnail_container for each member
   crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
    
// here is the change made
for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
  crtMC.thumbnail_container.thumbnail_txt.text = crtMC.countriesVisited[iNodeIndex2] + "\n";
  1. // countries
  2.    var VisitedCountry = crtMember.childNodes[iNodeIndex1];
  3.    var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
  4.    for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
  5.      crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  6.    // atach thumbnail_container for each member
  7.    crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
  8.     
  9. // here is the change made
  10. for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++)
  11.   crtMC.thumbnail_container.thumbnail_txt.text = crtMC.countriesVisited[iNodeIndex2] + "\n";


also make sure that thumbnail_txt is a multiline dynamic text
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Hi there thanks for that...

I now understand almost everything here.
The reason it didn't work first time is that there were a few spelling mistakes and now they are corrected, everything loads in.

heres the code I have now.

Code: [ Select ]
XML.prototype.ignoreWhite = true;

///Create a new empty XML Object
var myXMLCoreTeam:XML = new XML();

///load in the xml files
myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team
myXMLCoreTeam.onLoad = function(success){

    ProcessXMLData();
}
function ProcessXMLData()
{

/// First set of Variables and Arrays
  var rootNode:XMLNode = myXMLCoreTeam.firstChild;

 /// var contentNode:XMLNode = rootNode.firstChild; //// do we actually need this?
  menuArray = rootNode.childNodes;
  var numOfItems = menuArray.length;
  var pushoverX = 72; 
  var pushoverY = (Stage.width/(numOfItems/2))/2; 
  var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;
 
  //// First For Loop
  for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++){
    iNodeIndex1 = 0; 
   var crtMember = rootNode.childNodes[iNodeIndex0];
     var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
    
   crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
   crtMC.countriesVisited = new Array();
    
// countries
        
   var VisitedCountry = crtMember.childNodes[iNodeIndex1];
   var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;

// here is the change made
for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++){ 

// attach thumbnail_container for each member
crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
crtMC.thumbnail_container.thumbnail_txt = crtMC.sName + "\n"; /// changed the text to reflect the members name
crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;

crtMC.thumbnail_container.onRelease = function(){
trace(crtMC.countriesVisited[0]);

}//close imediate function
} // close loop iNodeIndex2

  pushoverX += crtMC.thumbnail_container._width + Xmargin; /// had to add in the crtMC.
           if(pushoverX >= Stage.width - crtMC.thumbnail_container._width - Xmargin) /// was mispelled, so corrected
   {
     pushoverY += crtMC.thumbnail_container._height + Ymargin;
     pushoverX= 72;
     }// close if statement
    }// close loop iNodeIndex0
}// End Function

//var menuArray = new Array(); /// is this needed now?
var Xmargin = 20;
var Ymargin = 30;
stop();
  1. XML.prototype.ignoreWhite = true;
  2. ///Create a new empty XML Object
  3. var myXMLCoreTeam:XML = new XML();
  4. ///load in the xml files
  5. myXMLCoreTeam.load("xml/coreteam.xml"); // xml xource for the core team
  6. myXMLCoreTeam.onLoad = function(success){
  7.     ProcessXMLData();
  8. }
  9. function ProcessXMLData()
  10. {
  11. /// First set of Variables and Arrays
  12.   var rootNode:XMLNode = myXMLCoreTeam.firstChild;
  13.  /// var contentNode:XMLNode = rootNode.firstChild; //// do we actually need this?
  14.   menuArray = rootNode.childNodes;
  15.   var numOfItems = menuArray.length;
  16.   var pushoverX = 72; 
  17.   var pushoverY = (Stage.width/(numOfItems/2))/2; 
  18.   var iIndex, iNodeIndex0, iNodeIndex1, iNodeIndex2;
  19.  
  20.   //// First For Loop
  21.   for (iNodeIndex0 = 0; iNodeIndex0<numOfItems; iNodeIndex0++){
  22.     iNodeIndex1 = 0; 
  23.    var crtMember = rootNode.childNodes[iNodeIndex0];
  24.      var crtMC = this.createEmptyMovieClip("member" + iNodeIndex0, iNodeIndex0);
  25.     
  26.    crtMC.ID = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  27.    crtMC.sName = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  28.    crtMC.sLocation = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  29.    crtMC.profile = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  30.    crtMC.thumbnailURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  31.    crtMC.photoURL = crtMember.childNodes[iNodeIndex1++].firstChild.nodeValue;
  32.    crtMC.countriesVisited = new Array();
  33.     
  34. // countries
  35.         
  36.    var VisitedCountry = crtMember.childNodes[iNodeIndex1];
  37.    var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
  38. // here is the change made
  39. for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++){ 
  40. // attach thumbnail_container for each member
  41. crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
  42. crtMC.thumbnail_container.thumbnail_txt = crtMC.sName + "\n"; /// changed the text to reflect the members name
  43. crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  44. crtMC.thumbnail_container.onRelease = function(){
  45. trace(crtMC.countriesVisited[0]);
  46. }//close imediate function
  47. } // close loop iNodeIndex2
  48.   pushoverX += crtMC.thumbnail_container._width + Xmargin; /// had to add in the crtMC.
  49.            if(pushoverX >= Stage.width - crtMC.thumbnail_container._width - Xmargin) /// was mispelled, so corrected
  50.    {
  51.      pushoverY += crtMC.thumbnail_container._height + Ymargin;
  52.      pushoverX= 72;
  53.      }// close if statement
  54.     }// close loop iNodeIndex0
  55. }// End Function
  56. //var menuArray = new Array(); /// is this needed now?
  57. var Xmargin = 20;
  58. var Ymargin = 30;
  59. stop();


Ok I had to make some small changes, as the dynamic text in the thumbnail contains the name of each person. What I am trying to do is return the countries when that thumbnail is clicked on.

the code here is supposed to trace this however is comming back with the last known person or undefined..

Code: [ Select ]
// attach thumbnail_container for each member
crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
crtMC.thumbnail_container.thumbnail_txt = crtMC.sName + "\n"; /// changed the text to reflect the members name
crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;

crtMC.thumbnail_container.onRelease = function(){
trace(crtMC.countriesVisited[0]);

}//close imediate function
} // close loop iNodeIndex2
  1. // attach thumbnail_container for each member
  2. crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
  3. crtMC.thumbnail_container.thumbnail_txt = crtMC.sName + "\n"; /// changed the text to reflect the members name
  4. crtMC.countriesVisited[iNodeIndex2] = VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  5. crtMC.thumbnail_container.onRelease = function(){
  6. trace(crtMC.countriesVisited[0]);
  7. }//close imediate function
  8. } // close loop iNodeIndex2


I was hoping that the array of items for each thumbnail would be something more like this, by referring the array back to the first index Node...

crtMC.countriesVisited[iNodeIndex0]= VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
Code: [ Select ]
crtMC.countriesVisited[iNodeIndex0]= VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;

crtMC.thumbnail_container.onRelease = function(){
trace(crtMC.countriesVisited[0]);

}//close imediate function
} // close loop iNodeIndex2
  1. crtMC.countriesVisited[iNodeIndex0]= VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue;
  2. crtMC.thumbnail_container.onRelease = function(){
  3. trace(crtMC.countriesVisited[0]);
  4. }//close imediate function
  5. } // close loop iNodeIndex2


I feel I nearly there.. a bit like there and back again by Bilbo Baggins.

Cheers

Andi
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Ok this works into a dynamic text area.

Code: [ Select ]
// countries
        
   var VisitedCountry = crtMember.childNodes[iNodeIndex1];
   var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;

 // attach thumbnail_container for each member
crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
crtMC.thumbnail_container.thumbnail_txt = crtMC.sName; /// changed the text to reflect the members name


// here is the change made
for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++){
crtMC.countriesVisited.push(VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue);
crtMC.thumbnail_container.countries_txt = crtMC.thumbnail_container.countries_txt + "\n" + crtMC.countriesVisited[iNodeIndex2];

} // close loop iNodeIndex2
  1. // countries
  2.         
  3.    var VisitedCountry = crtMember.childNodes[iNodeIndex1];
  4.    var numOfCountries = crtMember.childNodes[iNodeIndex1].childNodes.length;
  5.  // attach thumbnail_container for each member
  6. crtMC.attachMovie("thumbnail_container", "thumbnail_container", 0, {_x:pushoverX ,_y:pushoverY});
  7. crtMC.thumbnail_container.thumbnail_txt = crtMC.sName; /// changed the text to reflect the members name
  8. // here is the change made
  9. for (iNodeIndex2 = 0; iNodeIndex2 < numOfCountries; iNodeIndex2++){
  10. crtMC.countriesVisited.push(VisitedCountry.childNodes[iNodeIndex2].firstChild.nodeValue);
  11. crtMC.thumbnail_container.countries_txt = crtMC.thumbnail_container.countries_txt + "\n" + crtMC.countriesVisited[iNodeIndex2];
  12. } // close loop iNodeIndex2


by jove, he's nearly there...
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

that's a better way of putting it..
Code: [ Select ]
crtMC.thumbnail_container.countries_txt += "\n" + crtMC.countriesVisited[iNodeIndex2];


... now I'm talking to myself, posting as I do this... quite insane....
  • northstjarna
  • Beginner
  • Beginner
  • northstjarna
  • Posts: 58
  • Loc: Chertsey, UK

Post 3+ Months Ago

Hi there thanks for all your help.

I applied your methods to various things and now am a new kind of action script guy...

you can see the workings in many of the pages in a test site I created here... It's almost finished..


http://www.northstjarna.com/mission_africa/mission_africa.html


heres the code that doesn the map....



Code: [ Select ]
import mx.transitions.Tween;
import mx.transitions.easing.*
var my_sound:Sound = new Sound();
my_sound.attachSound("click");

africa_grouped_anim.attachMovie("tooltip_main1","africa_tip",0,{_x:352.4, _y:186.4});
africa_grouped_anim.africa_tip.tipText.text = "currently opperating in... Click for more";
this.attachMovie("country_info_whole","country_info_whole",999,{_x:-58,_y:210});
this.country_info_whole._alpha = 0;

XML.prototype.ignoreWhite = true;

var profiles_xml:XML = new XML();
profiles_xml.load("xml/country_profiles.xml");
profiles_xml.onLoad = function(success){

var rootNode:XMLNode = profiles_xml.firstChild;
var contentNode = rootNode.childNodes;
numOfItems = contentNode.length;
var indexNode0 , indexNode1;



for (indexNode0=0;indexNode0<numOfItems;indexNode0++){

    // Set the Country Clips up
    var CoID = contentNode[indexNode0].attributes.ID;
    var CoIDX = contentNode[indexNode0].attributes.X;
    var CoIDY = contentNode[indexNode0].attributes.Y;
    var my_country_name = contentNode[indexNode0].childNodes[0].childNodes;
    var my_population = contentNode[indexNode0].childNodes[1].childNodes;
    var my_capital = contentNode[indexNode0].childNodes[2].childNodes;
    var my_area = contentNode[indexNode0].childNodes[3].childNodes;
    var my_major_languages = contentNode[indexNode0].childNodes[4].childNodes;
    var my_major_religions = contentNode[indexNode0].childNodes[5].childNodes;
    var my_life_expectancy = contentNode[indexNode0].childNodes[6].childNodes;
    var my_monetary_unit = contentNode[indexNode0].childNodes[7].childNodes;
    var my_main_exports = contentNode[indexNode0].childNodes[8].childNodes;
    var my_gni_per_capita = contentNode[indexNode0].childNodes[9].childNodes;
    var my_internet_domain = contentNode[indexNode0].childNodes[10].childNodes;
    var my_international_dialing_code = contentNode[indexNode0].childNodes[11].childNodes;
    var my_source = contentNode[indexNode0].childNodes[12].childNodes;
    
    var My_countryMC = africa_grouped_anim.africa_grouped.attachMovie(CoID , CoID + indexNode0 ,indexNode0 ,{_x:CoIDX,_y:CoIDY});
    
    My_countryMC.country_name = my_country_name;
    My_countryMC.population = my_population;
    My_countryMC.capital = my_capital;
    My_countryMC.area = my_area;
    My_countryMC.major_languages = my_major_languages;
    My_countryMC.major_religions = my_major_religions;
    My_countryMC.life_expectancy = my_life_expectancy;
    My_countryMC.monetary_unit = my_monetary_unit;
    My_countryMC.main_exports = my_main_exports;
    My_countryMC.gni_per_capita = my_gni_per_capita;
    My_countryMC.internet_domain = my_internet_domain;
    My_countryMC.international_dialing_code = my_international_dialing_code;
    My_countryMC.sources = my_source;
    
    
    
    My_countryMC._alpha = 0;
    My_countryMC.onRollOver = C_over;
    My_countryMC.onRollOut = C_out;
    My_countryMC.onRelease = C_released;

    
    
}// End indexNode0

} // end XML Function

function C_over(){
    this._alpha = 70;
    africa_grouped_anim.africa_tip._alpha = 0;
    this.attachMovie("tooltip_main1","country_tip",1000,{_x:-25, _y:-75});
    this.country_tip.tipText.text = this.country_name;
    my_sound.start();
}

function C_out(){
    this._alpha = 30;
    this.country_tip.removeMovieClip();
    africa_grouped_anim.africa_tip._alpha = 100;
    
}

function C_released(){
    my_sound.start();
    this._alpha = 100;
    africa_grouped_anim.africa_tip._alpha = 0;
    this.attachMovie("tooltip_main1","country_tip",1000,{_x:-25, _y:-75});
    this.country_tip.tipText.text = this.country_name;
    country_info_whole.country_information.country_name.text = "Country: " + this.country_name;
    country_info_whole.country_information.population.text = "Population: " + this.population;
    country_info_whole.country_information.capital.text = "Capital: " + this.capital;
    country_info_whole.country_information.area.text = "Area " + this.area;
    country_info_whole.country_information.major_languages.text = "Languages: " + this.major_languages;
    country_info_whole.country_information.major_religions.text = "Religions: " + this.major_religions;
    country_info_whole.country_information.life_expectancy.text = "Life Expectancy: " + this.life_expectancy;
    country_info_whole.country_information.monetary_unit.text = "Currency: " + this.monetary_unit;
    country_info_whole.country_information.main_exports.text = "Exports: " + this.main_exports;
    country_info_whole.country_information.gni_per_capita.text = "GNI Per Capita: " + this.gni_per_capita;
    country_info_whole.country_information.internet_domain.text = "Intenet Domain: " + this.internet_domain;
    country_info_whole.country_information.international_dialing_code.text = "International Dialing Code: " + this.international_dialing_code;
    country_info_whole.country_information.sources.text = "Information Source BBC: " + this.sources;
    country_info_whole.country_information.other_info.text = "" ;
    var my_tween:Object = new Tween (country_info_whole, "_alpha" , Regular.easeOut , 0, 100, 1, true);
}
  1. import mx.transitions.Tween;
  2. import mx.transitions.easing.*
  3. var my_sound:Sound = new Sound();
  4. my_sound.attachSound("click");
  5. africa_grouped_anim.attachMovie("tooltip_main1","africa_tip",0,{_x:352.4, _y:186.4});
  6. africa_grouped_anim.africa_tip.tipText.text = "currently opperating in... Click for more";
  7. this.attachMovie("country_info_whole","country_info_whole",999,{_x:-58,_y:210});
  8. this.country_info_whole._alpha = 0;
  9. XML.prototype.ignoreWhite = true;
  10. var profiles_xml:XML = new XML();
  11. profiles_xml.load("xml/country_profiles.xml");
  12. profiles_xml.onLoad = function(success){
  13. var rootNode:XMLNode = profiles_xml.firstChild;
  14. var contentNode = rootNode.childNodes;
  15. numOfItems = contentNode.length;
  16. var indexNode0 , indexNode1;
  17. for (indexNode0=0;indexNode0<numOfItems;indexNode0++){
  18.     // Set the Country Clips up
  19.     var CoID = contentNode[indexNode0].attributes.ID;
  20.     var CoIDX = contentNode[indexNode0].attributes.X;
  21.     var CoIDY = contentNode[indexNode0].attributes.Y;
  22.     var my_country_name = contentNode[indexNode0].childNodes[0].childNodes;
  23.     var my_population = contentNode[indexNode0].childNodes[1].childNodes;
  24.     var my_capital = contentNode[indexNode0].childNodes[2].childNodes;
  25.     var my_area = contentNode[indexNode0].childNodes[3].childNodes;
  26.     var my_major_languages = contentNode[indexNode0].childNodes[4].childNodes;
  27.     var my_major_religions = contentNode[indexNode0].childNodes[5].childNodes;
  28.     var my_life_expectancy = contentNode[indexNode0].childNodes[6].childNodes;
  29.     var my_monetary_unit = contentNode[indexNode0].childNodes[7].childNodes;
  30.     var my_main_exports = contentNode[indexNode0].childNodes[8].childNodes;
  31.     var my_gni_per_capita = contentNode[indexNode0].childNodes[9].childNodes;
  32.     var my_internet_domain = contentNode[indexNode0].childNodes[10].childNodes;
  33.     var my_international_dialing_code = contentNode[indexNode0].childNodes[11].childNodes;
  34.     var my_source = contentNode[indexNode0].childNodes[12].childNodes;
  35.     
  36.     var My_countryMC = africa_grouped_anim.africa_grouped.attachMovie(CoID , CoID + indexNode0 ,indexNode0 ,{_x:CoIDX,_y:CoIDY});
  37.     
  38.     My_countryMC.country_name = my_country_name;
  39.     My_countryMC.population = my_population;
  40.     My_countryMC.capital = my_capital;
  41.     My_countryMC.area = my_area;
  42.     My_countryMC.major_languages = my_major_languages;
  43.     My_countryMC.major_religions = my_major_religions;
  44.     My_countryMC.life_expectancy = my_life_expectancy;
  45.     My_countryMC.monetary_unit = my_monetary_unit;
  46.     My_countryMC.main_exports = my_main_exports;
  47.     My_countryMC.gni_per_capita = my_gni_per_capita;
  48.     My_countryMC.internet_domain = my_internet_domain;
  49.     My_countryMC.international_dialing_code = my_international_dialing_code;
  50.     My_countryMC.sources = my_source;
  51.     
  52.     
  53.     
  54.     My_countryMC._alpha = 0;
  55.     My_countryMC.onRollOver = C_over;
  56.     My_countryMC.onRollOut = C_out;
  57.     My_countryMC.onRelease = C_released;
  58.     
  59.     
  60. }// End indexNode0
  61. } // end XML Function
  62. function C_over(){
  63.     this._alpha = 70;
  64.     africa_grouped_anim.africa_tip._alpha = 0;
  65.     this.attachMovie("tooltip_main1","country_tip",1000,{_x:-25, _y:-75});
  66.     this.country_tip.tipText.text = this.country_name;
  67.     my_sound.start();
  68. }
  69. function C_out(){
  70.     this._alpha = 30;
  71.     this.country_tip.removeMovieClip();
  72.     africa_grouped_anim.africa_tip._alpha = 100;
  73.     
  74. }
  75. function C_released(){
  76.     my_sound.start();
  77.     this._alpha = 100;
  78.     africa_grouped_anim.africa_tip._alpha = 0;
  79.     this.attachMovie("tooltip_main1","country_tip",1000,{_x:-25, _y:-75});
  80.     this.country_tip.tipText.text = this.country_name;
  81.     country_info_whole.country_information.country_name.text = "Country: " + this.country_name;
  82.     country_info_whole.country_information.population.text = "Population: " + this.population;
  83.     country_info_whole.country_information.capital.text = "Capital: " + this.capital;
  84.     country_info_whole.country_information.area.text = "Area " + this.area;
  85.     country_info_whole.country_information.major_languages.text = "Languages: " + this.major_languages;
  86.     country_info_whole.country_information.major_religions.text = "Religions: " + this.major_religions;
  87.     country_info_whole.country_information.life_expectancy.text = "Life Expectancy: " + this.life_expectancy;
  88.     country_info_whole.country_information.monetary_unit.text = "Currency: " + this.monetary_unit;
  89.     country_info_whole.country_information.main_exports.text = "Exports: " + this.main_exports;
  90.     country_info_whole.country_information.gni_per_capita.text = "GNI Per Capita: " + this.gni_per_capita;
  91.     country_info_whole.country_information.internet_domain.text = "Intenet Domain: " + this.internet_domain;
  92.     country_info_whole.country_information.international_dialing_code.text = "International Dialing Code: " + this.international_dialing_code;
  93.     country_info_whole.country_information.sources.text = "Information Source BBC: " + this.sources;
  94.     country_info_whole.country_information.other_info.text = "" ;
  95.     var my_tween:Object = new Tween (country_info_whole, "_alpha" , Regular.easeOut , 0, 100, 1, true);
  96. }




and heres some code for a photo gallery using the same method...


Code: [ Select ]
import mx.transitions.Tween;
import mx.transitions.easing.*
var Xmargin = 20;
var Ymargin = 40;

XML.prototype.ignoreWhite = true;

///Create a new empty XML Object
var my_gallery_xml:XML = new XML();

///load in the xml files
my_gallery_xml.load("xml/gallery.xml"); // xml xource for the core team
my_gallery_xml.onLoad = function(success){
    
    ProcessXMLData();
}

function ProcessXMLData(){
 
  var SetOverX = 0;
 
/// First set of Variables and Arrays
  var rootNode:XMLNode = my_gallery_xml.firstChild;
  menuArray = rootNode.childNodes;

  var numOfItems = menuArray.length;
  var iIndexSet, iIndexSet0, iIndex, iNodeIndex0, iNodeIndex1;
  iNodeIndex0 = 0;

//// First For Loop to load in each member
for (iIndexSet0 = 0;iIndexSet0<(numOfItems/6); iIndexSet0++){ 

var pushoverX = 100;  
var pushoverY = 100;

var containerMC = this.attachMovie("container_MC", "container" + iIndexSet0, -(iIndexSet0) ,{_x:SetOverX,_y:0});

//// Create Thumbnails in this Container
for (var set_thumbs = 0 ; set_thumbs<6; set_thumbs++ , iNodeIndex0++){

iNodeIndex1 = 0;

var crtThumb = rootNode.childNodes[iNodeIndex0];
var thumbMC = containerMC.createEmptyMovieClip("thumbnail" + iNodeIndex0, iNodeIndex0);
    
     thumbMC.ID = crtThumb.attributes.ID;
     thumbMC.thumbnailURL = crtThumb.attributes.thumbnail;
     thumbMC.imageURL = crtThumb.attributes.imageURL;
     thumbMC.annotation = crtThumb.childNodes[iNodeIndex1].nodeValue;

     // attach thumbnail_container for each image thumbnail
     thumbMC.attachMovie("thumb_MC", "thumb_MC", 0, {_x:pushoverX ,_y:pushoverY});
     thumbMC.thumb_MC.loadMovie(thumbMC.thumbnailURL);
     

thumbMC.onRelease = t_hit;


/// Pushover Functions for thumbnails
pushoverX += thumbMC.thumb_MC._width + Xmargin; /// had to add in the crtMC.
if(pushoverX >= 550 - (thumbMC.thumb_MC._width*2)){
        pushoverX = 100;
        pushoverY += 75 + Ymargin;
        
    }
    
}// close loop iNodeIndex0

SetOverX += + 550;

}// close loop iIndexSet0

}// End Function
    
function t_hit(){
var myURL = this.imageURL;
var myCaption = this.annotation;
_parent.photo_loadi._xscale = 48;
_parent.photo_loadi._yscale = 45;
_parent.photo_loadi.swapDepths(0);
_parent.photo_loadi._alpha = 100;

var jpgTween:Object = new Tween(_parent.photo_loadi, "_alpha", Regular.easeOut , 0 , 100 , 2, true );
var mcLoader:MovieClipLoader = new MovieClipLoader ();
mcLoader.loadClip(myURL , _parent.photo_loadi.the_loader);
_parent.caption_says = myCaption;

_parent.photo_loadi.attachMovie("the_close_btn","closer",1,{_x:0 , _y:0});
_parent.photo_loadi.closer._xscale = 120;
_parent.photo_loadi.closer._yscale = 120;
_parent.photo_loadi.closer.onRelease = function(){
    
    var jpgTween:Object = new Tween(_parent.photo_loadi, "_alpha", Regular.easeOut ,100 , 0 , 1, true );
    _parent.caption_says = "";
    
} // Close immediate function for closing image

}    // End on Release function for each thumbnail 
  1. import mx.transitions.Tween;
  2. import mx.transitions.easing.*
  3. var Xmargin = 20;
  4. var Ymargin = 40;
  5. XML.prototype.ignoreWhite = true;
  6. ///Create a new empty XML Object
  7. var my_gallery_xml:XML = new XML();
  8. ///load in the xml files
  9. my_gallery_xml.load("xml/gallery.xml"); // xml xource for the core team
  10. my_gallery_xml.onLoad = function(success){
  11.     
  12.     ProcessXMLData();
  13. }
  14. function ProcessXMLData(){
  15.  
  16.   var SetOverX = 0;
  17.  
  18. /// First set of Variables and Arrays
  19.   var rootNode:XMLNode = my_gallery_xml.firstChild;
  20.   menuArray = rootNode.childNodes;
  21.   var numOfItems = menuArray.length;
  22.   var iIndexSet, iIndexSet0, iIndex, iNodeIndex0, iNodeIndex1;
  23.   iNodeIndex0 = 0;
  24. //// First For Loop to load in each member
  25. for (iIndexSet0 = 0;iIndexSet0<(numOfItems/6); iIndexSet0++){ 
  26. var pushoverX = 100;  
  27. var pushoverY = 100;
  28. var containerMC = this.attachMovie("container_MC", "container" + iIndexSet0, -(iIndexSet0) ,{_x:SetOverX,_y:0});
  29. //// Create Thumbnails in this Container
  30. for (var set_thumbs = 0 ; set_thumbs<6; set_thumbs++ , iNodeIndex0++){
  31. iNodeIndex1 = 0;
  32. var crtThumb = rootNode.childNodes[iNodeIndex0];
  33. var thumbMC = containerMC.createEmptyMovieClip("thumbnail" + iNodeIndex0, iNodeIndex0);
  34.     
  35.      thumbMC.ID = crtThumb.attributes.ID;
  36.      thumbMC.thumbnailURL = crtThumb.attributes.thumbnail;
  37.      thumbMC.imageURL = crtThumb.attributes.imageURL;
  38.      thumbMC.annotation = crtThumb.childNodes[iNodeIndex1].nodeValue;
  39.      // attach thumbnail_container for each image thumbnail
  40.      thumbMC.attachMovie("thumb_MC", "thumb_MC", 0, {_x:pushoverX ,_y:pushoverY});
  41.      thumbMC.thumb_MC.loadMovie(thumbMC.thumbnailURL);
  42.      
  43. thumbMC.onRelease = t_hit;
  44. /// Pushover Functions for thumbnails
  45. pushoverX += thumbMC.thumb_MC._width + Xmargin; /// had to add in the crtMC.
  46. if(pushoverX >= 550 - (thumbMC.thumb_MC._width*2)){
  47.         pushoverX = 100;
  48.         pushoverY += 75 + Ymargin;
  49.         
  50.     }
  51.     
  52. }// close loop iNodeIndex0
  53. SetOverX += + 550;
  54. }// close loop iIndexSet0
  55. }// End Function
  56.     
  57. function t_hit(){
  58. var myURL = this.imageURL;
  59. var myCaption = this.annotation;
  60. _parent.photo_loadi._xscale = 48;
  61. _parent.photo_loadi._yscale = 45;
  62. _parent.photo_loadi.swapDepths(0);
  63. _parent.photo_loadi._alpha = 100;
  64. var jpgTween:Object = new Tween(_parent.photo_loadi, "_alpha", Regular.easeOut , 0 , 100 , 2, true );
  65. var mcLoader:MovieClipLoader = new MovieClipLoader ();
  66. mcLoader.loadClip(myURL , _parent.photo_loadi.the_loader);
  67. _parent.caption_says = myCaption;
  68. _parent.photo_loadi.attachMovie("the_close_btn","closer",1,{_x:0 , _y:0});
  69. _parent.photo_loadi.closer._xscale = 120;
  70. _parent.photo_loadi.closer._yscale = 120;
  71. _parent.photo_loadi.closer.onRelease = function(){
  72.     
  73.     var jpgTween:Object = new Tween(_parent.photo_loadi, "_alpha", Regular.easeOut ,100 , 0 , 1, true );
  74.     _parent.caption_says = "";
  75.     
  76. } // Close immediate function for closing image
  77. }    // End on Release function for each thumbnail 


My issue is now reolved thanks!

Andi

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.