Solved

Flex4 issue, Alert message box is appearing backwards!??

Posted on 2010-08-21
10
1,101 Views
Last Modified: 2012-05-10
I have attached a graphics file to show exactly what I'm talking about. This is the first time I've used mx.controls.Alert since I've been using Flex 4.

How can I write an application in Flex with Alert boxes looking like this?

Has anyone encountered this problem? How did you resolve this??
problem.png
0
Comment
Question by:elepil
  • 6
  • 4
10 Comments
 
LVL 8

Expert Comment

by:IqAndreas
Comment Utility
Hehe, that is quite funny. It looks like some sort of april fools prank. :)

What code are you using to make the alert show up? Are you setting the "parent" parameter to anything, or are you keeping that at the default?

Are you flipping any of the other components (by setting "scaleX = -1")?

If all else fails, you can set the scaleX property of the alert to -1, and that should flip it correctly. If you provide some code, I can make the necessary changes for you.

Cheers,
Andreas
0
 
LVL 8

Expert Comment

by:IqAndreas
Comment Utility
And in case it comes in handy, here is the link for the Language reference page for the Alert class:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/Alert.html?allClasses=1
0
 

Author Comment

by:elepil
Comment Utility
Thank you for responding, Andreas.

My code is pretty standard, just the way I have been doing it in Flex 3:

private function btnDashBoardClickHandler(event:MouseEvent):void
{
    var alert:Alert = Alert.show("Unsaved changes you have made, if any, will be lost.\n" +
                                                 "Do you still wish to go back to the Dashboard?",
                                                 "WARNING", Alert.YES | Alert.NO,
                                                 this, alertClickHandler);
}

private function alertClickHandler(event:CloseEvent):void
{
}

As you can see, the parent is 'this'.

Can you please tell me where to put that scaleX = -1 you were talking about?

This is a bit upsetting to me because I just spent $299 upgrading to Flex 3, and then I get this. :(
0
 
LVL 8

Expert Comment

by:IqAndreas
Comment Utility
You should be able to write the code directly after you define the alert variable (before the first function closes) - See the attached code and try that.

If that doesn't work, try passing in "stage" as the parent container instead of "this".
var alert:Alert = Alert.show("Unsaved changes you have made, if any, will be lost.\n" +
											 "Do you still wish to go back to the Dashboard?",
											 "WARNING", Alert.YES | Alert.NO,
											 this, alertClickHandler);
											 
alert.scaleX = -1;

Open in new window

0
 
LVL 8

Expert Comment

by:IqAndreas
Comment Utility
If that doesn't work, try opening an entirely blank project, and creating that alert.

If the problem is still there, you have a Flex problem. If the problem goes away, then something else in your current code is interfering with the alert.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:elepil
Comment Utility
Andreas, that scaleX= -1 didn't work out too well. I attached the graphic on  how it looked like.

I created a new MXML application within the same project and pasted my code, now the alert box is just blank. You see the alert box and the buttons, but no text at all!

Are you using Flex 4? I just need to know if other Flex 4 users are having similar peculiar problems.
problem2.png
0
 
LVL 8

Expert Comment

by:IqAndreas
Comment Utility
That is VERY odd indeed. Yes, I'm using Flex 4, and it is working just fine for me.

Did changing the parent of the alert from "this" to "stage" work?

Perhaps try creating a NEW project, rather than using the existing one (to make sure no code is interfering at all) and test making an Alert in there. If it still shows up wacky, try installing the latest build of the Flex 4 SDK. I'm assuming you are using Flash Bulder 4 (previously known as Flex Builder), correct?
http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4
0
 

Author Comment

by:elepil
Comment Utility
stage? You never said to change the parent from 'this' to 'stage'. I tried that and got a compile time error.

I tried creating a totally brand new project in Flex 4, and the alert box worked fine. Damn, what could've gotten corrupted?? I'm already a bit far into the project I'm currently working on, now I have to gradually copy the files over to a new project, and I don't even know what caused this anomaly to begin with.

But I am relieved that it isn't my Flash Builder 4 installation that's corrupt, but rather, just the project. I remember starting this project as a Flex 4, then converting back to Flex 3 using the Flex 3 compatibility mode. I don't know if that might have done something.

How are you finding Flex 4? I had to retract from it because I felt like Adobe sold me an unfinished product. They give me Spark components that do not have a one-to-one counterpart with the mx.controls components (e.g. no datagrid). Not only that, the Spark components' methods are a bit different, even absent in some of the abilities of the mx.control components.

And I wasn't too happy with what they did to the mx:states. I haven't gotten into using Flex 4 states yet, but it sounded convoluted. The Flex 3 states were so much more programmatically logical.

But I'd be interested in hearing your opinion about Flex 4, if you don't mind, before I close this?

Thanks.
0
 
LVL 8

Accepted Solution

by:
IqAndreas earned 500 total points
Comment Utility
>stage? You never said to change the parent from 'this' to 'stage'. I tried that and got a compile time error.
Sorry, it was hidden in one of the posts as an additional suggestion in case changing the scale didn't work. But what error does that give you? Is it a "#1009" error? If so, it is quite easy to fix. Maybe also try writing "this.parent" instead.

If copying over the files to a new project still doesn't work, it's definitely somewhere in the code. Perhaps one of the display objects are "flipped", causing interference with the Alert? If so, we just need to keep going backwards (doing parent.parent etc) until we get to the parent that isn't flipped yet, as long as that doesn't interfere with your layout in any way.


To be honest, I actually don't use Flex unless I absolutely need to (which is practically never at all). I just don't often need to use forms in my AS3 projects. The times I have needed components, I have used MinimalComps, so I couldn't really give you a good opinion on Flex 4, sorry.
0
 

Author Closing Comment

by:elepil
Comment Utility
Ah, if your background is in AS3 applications, it isn't quite as easy to make a mistake in Flex to accidentally flip any display object backwards, especially an Alert Box. As I mentioned in my previous post, it was the project that was somehow corrupt because the Alert box displayed just fine in a totally brand new project.

Anyway, thanks for your time and help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

11 Experts available now in Live!

Get 1:1 Help Now