?
Solved

Switch Case Statement Question

Posted on 2010-09-08
4
Medium Priority
?
295 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 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

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 …
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…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

850 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