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 8324513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:06:04+00:00 2026-06-09T00:06:04+00:00

I am using Flash CS6 – Adobe AIR 3.3: Instead of typing exactly what

  • 0

I am using Flash CS6 – Adobe AIR 3.3:
Instead of typing exactly what I’d like to search for in my XML, I’d like to use a dynamic variable that can be changed to search for different categories and days. The following is something like the code I’d like to use:

var someCategory:String = new String("food");
var someDay:String = new String("monday");

var locationsLoader:URLLoader = new URLLoader();
locationsLoader.load(new URLRequest("http://www.myfile.xml"));
locationsLoader.addEventListener(Event.COMPLETE, init);

//load xml

function init(e:Event):void
{
theXML = new XML(e.target.data);
theXML.ignoreWhitespace = true;
e.currentTarget.close();

for(var i:int = 0; i < theXML.someCategory.length(); i++) 
{
if(theXML.someCategory[i].somdDay != "un")
{
//do soemthing
}
}

This code works currently ONLY if I actually type “food” and “monday” in the ‘for’ and ‘if’ loop. Any suggestions?

The XML would be…

<xml>
<food>
<monday>yes</monday>
</food>
<food>
<monday>yes 2</monday>
</food>
<food>
<monday>un</monday>
</food>

</xml>

Here’s what currently works:

var someCategory:String = new String("food");
var someDay:String = new String("monday");

var locationsLoader:URLLoader = new URLLoader();
locationsLoader.load(new URLRequest("http://www.myfile.xml"));
locationsLoader.addEventListener(Event.COMPLETE, init);

//load xml

function init(e:Event):void
{
theXML = new XML(e.target.data);
theXML.ignoreWhitespace = true;
e.currentTarget.close();

for(var i:int = 0; i < theXML.food.length(); i++) 
{
if(theXML.food[i].monday != "un")
{
//do soemthing
}
}
  • 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-06-09T00:06:05+00:00Added an answer on June 9, 2026 at 12:06 am

    Copied your code and stepped through changing each part step by step and seemed to get the same result with each change I made so I believe what’s below is correct.

    package
    {
        import flash.display.Sprite;
    
        public class TestAS3Project extends Sprite
        {
            public var theXML:XML = new XML(<xml>
                    <food>
                        <monday>yes</monday>
                    </food>
                    <food>
                        <monday>yes 2</monday>
                    </food>
                    <food>
                        <monday>un</monday>
                    </food>
    
                </xml>);
            public function TestAS3Project()
            {
                init();
            }
            private function init():void
            {
    
                var someCategory:String = new String("food");
                var someDay:String = new String("monday");
    
                theXML.ignoreWhitespace = true;
    
                for(var i:int = 0; i < theXML[someCategory].length(); i++) 
                {
                    if(theXML[someCategory][i][someDay] != "un")
                    {
                        //do soemthing
                        trace(theXML[someCategory][i][someDay]);
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPad app using Flash CS6 to compile to AIR 3.3
Using Adobe Flash Professional CS6, AS3 Please let me know if I need to
Using Flash Builder 4.6, I am following http://www.flex-blog.com/adobe-air-sqlite-example (edit: link seems to be broken)
I'm using Flash Builder to build an AIR android app. To prevent the app
I'm using Flash CS 5 and Flex 4, both to build an AIR application
I'm using Flash CS4 and Flex 3.4.0. I'd like to create a vector-graphic button
I am trying to edit an existing flash template. Using Flash CS6 and ActionScript
I'm working on creating a game in Adobe Flash CS6, and the game starts
I am using flash (AS3) and have a dynamic movie clip that I want
I am using flash.utils.getDefinitionByName in an attempt to grab an art asset. I use

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.