Solved

How do I set else for both and

Posted on 2011-02-19
3
280 Views
Last Modified: 2012-05-11
I have a situation where I am iterating a xml-string, with several id-nodes.
If one of the id-nodes equals a predefined number, the movie should show solution A, but if the predefined number does not exist as an id-node, it should show solution B.

The problem is that if I iterate the xml, both scenarios exist, if I compare IDs.
It equals an ID and it does not equals an ID.
Take a look:
var bookLength=myXML.Book;
for (var i:int; i < bookLength.length(); i++ ) {
if (myXML.Book[i].id==0684826976){
title_TF.x=30;
}
else{
title_TF.x=50;
}
}

Open in new window

The problem is that title_TF will show in both positions since both situations are correct.
But obviously I only want one of the solutions to show.


<Books>
 <Book>
  <id>0553212419</id>
  <title>Sherlock Holmes: Complete Novels and Stories, Vol 1</title>
  <author>Sir Arthur Conan Doyle</author>
</Book>
<Book>
  <id>0743273567</id>
  <title>The Great Gatsby</title>
  <author>F. Scott Fitzgerald</author>
</Book>
<Books>
 <Book>
  <id>0684826976</id>
  <title>Undaunted Courage</title>
  <author>Stephen E. Ambrose</author>
</Book>
<Book>
  <id>0743203178</id>
  <title>Nothing Like It In the World</title>
  <author>Stephen E. Ambrose</author>
 </Book>
</Books>

Open in new window

0
Comment
Question by:petersego
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
andreizz earned 500 total points
ID: 34933468
var bookLength=myXML.Book;
for (var i:int; i < bookLength.length(); i++ ) {
if (myXML.Book[i].id==0684826976){
title_TF.x=30; break;
}
else{
title_TF.x=50; break;
}
}

Open in new window


the break; command will exit the for after one executed path
0
 

Author Closing Comment

by:petersego
ID: 34933547
Ahh, brillant, Thanks alot.
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34933551
No problem, good luck!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question