Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Switch Case Statement Question

Posted on 2010-09-08
4
Medium Priority
?
293 Views
Last Modified: 2013-11-11
How can I change the view state in flex 3 within a case statement?

Non-working Example:

private function mssqlResult(event:ResultEvent):void
{
switch(event.token.param)
{
case "StartLogin":
RecordsReturned = event.result.results.record.CNT;
if(RecordsReturned==0)
{
Alert.show('You have entered an incorrect login', 'Error'";
}
else
{
currentState = loggedIn;
}
}
}
0
Comment
Question by:deross
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:apresence
apresence earned 664 total points
ID: 33633592
Try the attached.
private function mssqlResult(event:ResultEvent):void
{
  switch(event.token.param)
  {
    case "StartLogin":
      RecordsReturned = event.result.results.record.CNT;
      if(RecordsReturned==0)
      {
        Alert.show('You have entered an incorrect login', 'Error'";
      }
      else
      {
        currentState = 'loggedIn';
      }
  }
}

Open in new window

0
 
LVL 6

Expert Comment

by:apresence
ID: 33633596
Sorry, I didn't notice the Alert.show typo.  Please try this instead:
private function mssqlResult(event:ResultEvent):void
{
  switch(event.token.param)
  {
    case "StartLogin":
      RecordsReturned = event.result.results.record.CNT;
      if(RecordsReturned==0)
      {
        Alert.show('You have entered an incorrect login', 'Error');
      }
      else
      {
        currentState = 'loggedIn';
      }
  }
}

Open in new window

0
 
LVL 39

Accepted Solution

by:
blue-genie earned 668 total points
ID: 33636154
what is not working?
have you check your values of RecordsReturned and event.token.param? is your param a string?

also, a case statement needs a break;

0
 
LVL 1

Assisted Solution

by:ihaveitnow
ihaveitnow earned 668 total points
ID: 33659101
Hi deross,

I noticed you have no break; in your code. Without it actionscript will not be able to tell the beginning nor end of a case, and the program will run through all the code. So an error is to be expected.

Hope this helps, regards.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

650 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