Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I set else for both and

Posted on 2011-02-19
3
Medium Priority
?
287 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.

972 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