tflock
asked on
Flash Actionscript 3 CS4: Incorrect return value assigned to variable
I have a created a .as file that reads from an XML file and returns a boolean value from the initializer function if the value was found or not. However, when I call the .as with my .fla file, it returns a "false" value regardless if the element was found in my XML file. Can anyone assist? I have attached all required files.
CompatibilityTester.zip
CompatibilityTester.zip
ASKER
Thanks for the response blue-genie,
However, I didn't think the returnMostCompatible value could return a false value, because it is set to false at the begining of the Initialize function then set it to true in my case statement. The case statement is in another if that checks to see if the XML attribute value equals the passedType parameter, see below.
if (passedType==compatibility Element.at tributes() )
At any rate, it would improve perfomance if I break out of the for each loop instead of checking ever node, but I'm not sure how to do that. I tried adding a break after my Switch statement just before the closing if "}", but that didn't work. Any other suggestions?
However, I didn't think the returnMostCompatible value could return a false value, because it is set to false at the begining of the Initialize function then set it to true in my case statement. The case statement is in another if that checks to see if the XML attribute value equals the passedType parameter, see below.
if (passedType==compatibility
At any rate, it would improve perfomance if I break out of the for each loop instead of checking ever node, but I'm not sure how to do that. I tried adding a break after my Switch statement just before the closing if "}", but that didn't work. Any other suggestions?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can i write entire new code for ur solution or should i edit only..
ASKER
Hi blue-genie,
I attempted to set a break after the for loop, but that didn't work either. I traced the returnMostCompatible var and it shows true for me each time it goes through the loop. I have no clue where it is being set to false. I have attached my current .as file for review. Not sure were or how to break out of the for loop. Any help you can provide would be appreciated.
mostCompatible.as
I attempted to set a break after the for loop, but that didn't work either. I traced the returnMostCompatible var and it shows true for me each time it goes through the loop. I have no clue where it is being set to false. I have attached my current .as file for review. Not sure were or how to break out of the for loop. Any help you can provide would be appreciated.
mostCompatible.as
ASKER
vishalreddy57,
I would prefer you edit, but as I am a novice, I welcome any actionscript conventions in object oriented programming. This was the only way I could get the file to run as a .as file.
I would prefer you edit, but as I am a novice, I welcome any actionscript conventions in object oriented programming. This was the only way I could get the file to run as a .as file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vishalreddy57 thanks for your assistance.
Your code is much cleaner, but I did get my code to run by calling the initialize function from the contructor in my .as file. And putting return statement in switch statements in my parse function to get it to stop the execution of the for each loop.
Your code is much cleaner, but I did get my code to run by calling the initialize function from the contructor in my .as file. And putting return statement in switch statements in my parse function to get it to stop the execution of the for each loop.
You could do a break as soon as a true value is returned.