Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:15:50+00:00 2026-05-25T15:15:50+00:00

I’m a little stuck and could really use some help. I posted a question

  • 0

I’m a little stuck and could really use some help. I posted a question on here previously, but I figured out what the issue was there… sort of. Not completely, but enough to know I may be in over my head trying to adjust it.

So now I’m asking if anyone has heart enough to tell me how I would take this code and fix it so that I can include swf and image files only when I need them. They won’t always be in every node:

var pageXMLLoader = new URLLoader();
pageXMLLoader.load(new URLRequest("scripts/xml/content.xml"));
pageXMLLoader.addEventListener(Event.COMPLETE, pageXMLLoaded);
//This function is called when the XML file is loaded


function pageXMLLoaded(e:Event):void {

    //Create a new XML object from the loaded XML data
    //pageXML = new XML(pageXMLLoader.data);
    pageXML = new XML(e.target.data);

}


// Set page number variable
var pageNumber:uint;

mcContent.y = 30;

// Set up if for mouse click
if (e.type == MouseEvent.CLICK) {

    // Switch based on target name
    switch (e.currentTarget.name) {
        case "navBtn0" :
            trace(e.currentTarget.name);
            pageNumber = 1;

            mcContent.removeChildAt(0);

            mcContent.addChildAt(pageContent,0);

            pageContent.addChild(contentTxt);
            pageContent.addChild(headingTxt);

            break;

        case "navBtn1" :
            trace(e.currentTarget.name);
            pageNumber = 2;

            mcContent.removeChildAt(0);

            mcContent.addChildAt(pageContent,0);

            pageContent.addChild(contentTxt);
            pageContent.addChild(headingTxt);

            break;

        case "navBtn2" :
            ... code shortened
    }


    // Loop through the XML file
    for each (var page:XML in pageXML.pages.page) {

        // "page.@pagenumber" points to "pagenumber" in the XML file.
        if (page.@ pagenumber == pageNumber) {

            // Set the title
            headingTxt.htmlText = page.title;

            // Set the page content
            contentTxt.htmlText = page.content;
            contentRTopTxt.htmlText = page.contenttr;
            contentRBottomTxt.htmlText = page.contentbr;

            // Exit the loop
            break;
        }
    } // < /For Loop >
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:15:51+00:00Added an answer on May 25, 2026 at 3:15 pm

    I got lost in your code, but here is a quick example on how you could retrieve the correct page using E4X (var pageContent : XML = pageXML.pages.page.(@pagenumber == 1)[0];) and also a check if image or SWF exists.

    Test.as

    package
    {
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
    
        public class TestXMLPages extends Sprite
        {
    
            private var pageXML : XML;
    
            private var swfContainer : Sprite = new Sprite();
            private var imgContainer : Sprite = new Sprite();
            private var imgLoader : Loader = new Loader();
            private var swfLoader : Loader = new Loader();
    
            public function TestXMLPages()
            {
                super();
    
                var pageXMLLoader : URLLoader = new URLLoader();
                    pageXMLLoader.load(new URLRequest("xml/content.xml"));
                    pageXMLLoader.addEventListener(Event.COMPLETE, pageXMLLoaded);
            }
    
            private function pageXMLLoaded(e : Event) : void
            {
                pageXML = new XML(e.target.data);
    
                // select page with pagenumber 1
                var pageContent : XML = pageXML.pages.page.(@pagenumber == 1)[0];
    
                // has image?
                if(pageContent.image.length() > 0)
                    trace("add image!")
    
                // has swf?
                if(pageContent.swfURL.length() > 0)
                    trace("add swf!")
    
                trace(pageContent.toXMLString())
            }
        }
    }
    

    content.xml

    <?xml version="1.0" encoding="utf-8"?>
    <site>
    
        <!--<sitetitle><![CDATA[<strong>Transplant the Heart</strong>]]></sitetitle>-->
    
        <pages>
    
            <page pagenumber="1">
    
                <title><![CDATA[<h1>Page #1</h1>]]></title>
    
                <content><![CDATA[<p>Aliquam nec dui neque. Aenean rutrum suscipit turpis vel fringilla. </p>]]></content>
    
                <contenttr><![CDATA[Cras non risus nisi. Nam tincidunt lacinia massa, vel interdum massa ultricies.]]></contenttr>
    
                <contentbr><![CDATA[Aliquam erat volutpat. Etiam eget mauris ante, sit amet placerat tortor.]]></contentbr>
    
                <image>imgs/png/titleLarge.png</image>
    
                <swfURL>transplantSpecialists.swf</swfURL>
    
            </page>
    
            <page pagenumber="2">
    
                <title><![CDATA[<h1>Page #2</h1>]]></title>
    
                <content><![CDATA[<p>Aliquam nec dui neque. Aenean rutrum suscipit turpis vel fringilla. </p>]]></content>
    
                <contenttr><![CDATA[Cras non risus nisi. Nam tincidunt lacinia massa, vel interdum massa ultricies.]]></contenttr>
    
                <contentbr><![CDATA[Aliquam erat volutpat. Etiam eget mauris ante, sit amet placerat tortor.]]></contentbr>
    
            </page>
    
        </pages>
    
    </site>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.