Solved

Switch Case Statement Question

Posted on 2010-09-08
4
288 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

770 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