Solved

Switch Case Statement Question

Posted on 2010-09-08
4
287 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 how to record live broadcast.

929 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now