In a previous example, Creating an undraggable Alert control in Flex, we saw how you could create a Flex Alert control that isn’t draggable by listening for the mouseDown event and calling the stopImmediatePropagation() method in the event handler.
The following example shows how you can create an undraggable Flex Alert control by setting the Boolean isPopUp property.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/10/creating-an-undraggable-alert-control-in-flex-redux/ -->
<mx:Application name=""
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var a:Alert;
private function showAlert():void {
var title:String;
if (checkBox.selected) {
title = "Draggable Alert";
} else {
title = "Undraggable Alert";
}
a = Alert.show("The quick brown fox jumped over the lazy dog.", title);
a.isPopUp = checkBox.selected;
a.status = Capabilities.version;
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true" horizontalGap="40">
<mx:CheckBox id="checkBox"
label="isPopUp:"
labelPlacement="left"
selected="true" />
<mx:Button id="button"
label="Launch Alert"
click="showAlert();" />
</mx:ApplicationControlBar>
</mx:Application>
View source is enabled in the following example.



Some time ago I worked on building a Swing framework that was going to be used to build some applications at work, it wasn’t..:-s, you know the reason, the business changed their mind and decided to go thin!!!.. thats another story, but for those that worked on Swing you know that if you go deep on Swing you learn a lot, and i never though that 5 years later I was going to use all that on a new technology.
Now I am working on building a framework on top of Flex, the main reason for that is to simplify the developers coding and to keep the application source code clean, following guidelines and standards, so while researching and playing with Flex I realized that Swing and Flex are very similar, bot are event based frameworks and the basic idea of how they run on the browser is very similar but in different technologies, so to help others understand Flex I usually compare Flex to Swing, I know, I know, the comparison is ridiculous, actually I like Flex better for many reasons that I will explain later, but the way to code it is very similar (if you do everything with actionscript), basically you create a container and then you add children, then you add listeners and so on and so forth. To tell you the truth its been very easy to get into Flex thanks to Swing.
Now I have one question for those that used Swing before, do you remember the memory problems we used to have with it? Just Google it and you will see hundreds of results with the same type of problems, objects that keep referenced by others and the garbage collection never release them, listeners that never get removed and keep listening forever, etc, etc. Also you will find a lot of ways to avoid those problems (after so many years dealing with them), there are some advices about using weak listeners, there some guidelines to develop Swing applications and there are a lot of tools to find the problems. For Flex there is a profiler, but i bet is not perfect yet, meanwhile we have to be really careful developing our applications.
One of the most common memory leak issues in Swing is : Unknown or unwanted object references, and guess what?… thats the most common problem in Flex application too.
_______________________
Submited by : Libros Gratis