loading xml

  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

Hi i am trying to load xml based on what button a user presses, dynamically in the movie clip named "mc_trivia1" based on an id number.



the actionscript

Code: [ Select ]
AboriginalEconomicStream.onRelease = function() {
    _root.attachMovie("mc_trivia1", "mc_trivia1", 1);
    _root.mc_trivia1._x = 512;
    _root.mc_trivia1._y = 384;
    
};
AboriginalSocialStream_mc.onRelease = function() {
    _root.attachMovie("mc_trivia1", "mc_trivia1", 1);
    _root.mc_trivia1._x = 512;
    _root.mc_trivia1._y = 384;
};
  1. AboriginalEconomicStream.onRelease = function() {
  2.     _root.attachMovie("mc_trivia1", "mc_trivia1", 1);
  3.     _root.mc_trivia1._x = 512;
  4.     _root.mc_trivia1._y = 384;
  5.     
  6. };
  7. AboriginalSocialStream_mc.onRelease = function() {
  8.     _root.attachMovie("mc_trivia1", "mc_trivia1", 1);
  9.     _root.mc_trivia1._x = 512;
  10.     _root.mc_trivia1._y = 384;
  11. };






The xml im trying to load

Code: [ Select ]
<info>
   <address>
    <id>1</id>
    <title>Aboriginal Community Development - Economic Stream</title>
    <descript>The two-year Aboriginal Community Development program explores various aspects of a community in order to plan efficient and applicable support programs to enhance, support or develop the community. Students will be exposed to classic and experiential learning methods including a work practicum, in which students partner with a community organization/agency to practice the skills learned in the classroom. The economic stream focuses on building and maintaining resources in communities so that they are self-sufficient and healthy places to live and work. If your interests lie in economic development and you enjoy marketing and business-related skills, the economic specialization may appeal to you.    </descript>
   </address>
</info>

<info>
   <address>
    <id>2</id>
    <title>Aboriginal Community Development - Social Stream</title>
    <descript>The two-year Aboriginal Community Development program explores various aspects of a community in order to plan efficient and applicable support programs to enhance, support or develop the community. Students will be exposed to classic and experiential learning methods including a work practicum, in which students partner with a community organization/agency to practice the skills learned in the classroom. The economic stream focuses on building and maintaining resources in communities so that they are self-sufficient and healthy places to live and work. If your interests lie in economic development and you enjoy marketing and business-related skills, the economic specialization may appeal to you.    </descript>
   </address>
</info>
  1. <info>
  2.    <address>
  3.     <id>1</id>
  4.     <title>Aboriginal Community Development - Economic Stream</title>
  5.     <descript>The two-year Aboriginal Community Development program explores various aspects of a community in order to plan efficient and applicable support programs to enhance, support or develop the community. Students will be exposed to classic and experiential learning methods including a work practicum, in which students partner with a community organization/agency to practice the skills learned in the classroom. The economic stream focuses on building and maintaining resources in communities so that they are self-sufficient and healthy places to live and work. If your interests lie in economic development and you enjoy marketing and business-related skills, the economic specialization may appeal to you.    </descript>
  6.    </address>
  7. </info>
  8. <info>
  9.    <address>
  10.     <id>2</id>
  11.     <title>Aboriginal Community Development - Social Stream</title>
  12.     <descript>The two-year Aboriginal Community Development program explores various aspects of a community in order to plan efficient and applicable support programs to enhance, support or develop the community. Students will be exposed to classic and experiential learning methods including a work practicum, in which students partner with a community organization/agency to practice the skills learned in the classroom. The economic stream focuses on building and maintaining resources in communities so that they are self-sufficient and healthy places to live and work. If your interests lie in economic development and you enjoy marketing and business-related skills, the economic specialization may appeal to you.    </descript>
  13.    </address>
  14. </info>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

It won't work to use attachMovie since that requires your content to already exist in the library. You need something like this instead.

Code: [ Select ]
var xmlObject_xml = new XML();
xmlObject_xml.ignoreWhite = true;
xmlObject_xml.onLoad = function(success) {
    if (success) {
        _global.arrayForXML = xmlObject_xml.firstChild.childNodes;
    } else {
        trace("Error loading xmlObject_xml");
    }
};
xmlObject_xml.load("path to xml");
  1. var xmlObject_xml = new XML();
  2. xmlObject_xml.ignoreWhite = true;
  3. xmlObject_xml.onLoad = function(success) {
  4.     if (success) {
  5.         _global.arrayForXML = xmlObject_xml.firstChild.childNodes;
  6.     } else {
  7.         trace("Error loading xmlObject_xml");
  8.     }
  9. };
  10. xmlObject_xml.load("path to xml");


you could use the load code in your button but its easier to load all your xml content at once and then make an array or something and then call the content from that when you press a button.

more help at: http://www.kirupa.com/web/xml/index.htm
  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

PARTIAL SUCCESS!

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 15 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.