Solved

Switch Case Statement Question

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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,…
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.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

708 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

13 Experts available now in Live!

Get 1:1 Help Now