Solved

Switch Case Statement Question

Posted on 2010-09-08
4
289 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
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:apresence
apresence earned 166 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 167 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 167 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Embedded Video Download (Flash) 3 1,162
Devices and printers wont load and flash files in print spooler 3 209
Flash Player Action Script Error 1090 5 216
You Tube Videos not playing 9 128
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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…
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.

860 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