Thursday, 22 September 2011

Self Closed Custom Alert Using Title Wndow.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Alert_PopUpManager_removePopUp_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        backgroundColor="white"
        initialize="init();">

    <mx:Script>
        <![CDATA[
         import mx.controls.Label;
         import mx.containers.TitleWindow;
         import mx.controls.Alert;
            import mx.events.CloseEvent;
          

            private var alrt:TitleWindow=new TitleWindow();
            private var alrtTimer:Timer;
private var newlbl:Label=new Label;
            private function init():void {
                alrtTimer = new Timer(5000, 1);
                alrt.title="Self Closed Alert";
                alrt.showCloseButton=true;
                alrt.addEventListener(CloseEvent.CLOSE,alrt_close)
                newlbl.text="This is custom alert which will be self closed";
                alrt.addChild(newlbl);
                alrtTimer.addEventListener(TimerEvent.TIMER_COMPLETE, removeAlert);
            }

            private function showAlert():void {
                alrtTimer.reset();
                alrtTimer.start();
                btn1.enabled=false;
                this.addChild(alrt);
            }

            private function alrt_close(evt:CloseEvent):void {
                alrtTimer.stop();
                btn1.enabled=true;
                this.removeChild(alrt);
                }

            private function removeAlert(evt:TimerEvent):void {
               this.removeChild(alrt);
               btn1.enabled=true;
            }
        ]]>
    </mx:Script>

    <mx:Button id="btn1" label="CLICK ME" click="showAlert();" />
  
</mx:Application>


Monday, 12 September 2011

To generate Random Numbers in AS-3


To generate random numbers : here Math.floor returns the floor of the number or expression specified in the parameter val. The floor is the closest integer that is less than or equal to the specified number or expression.
And Math.random returns a pseudo-random number n, where 0 <= n < 1. To avoid 0 we are using +1 at the end.
     <fx:Script>
    <![CDATA[
    var randNum:Number=Math.floor(Math.random()*100)+1;
    txtRandNum.text=""+randNum;
    ]]>
    </fx:Script> 
    <mx:Text  id="txtRandNum"/>


Setting Styles

Refer This for video inYoutube.
Refer This For CSS complete list of properties.

Tuesday, 6 September 2011

Actionscript vs Javascript


ActionScript is the primary programming language of Adobe's Flash Platform.
Flex is an Open Source SDK (Software Development Kit) for building Flash Platform Applications. The Flash Platform runtimes are primarily Adobe AIR and and the Adobe Flash Player browser plugin.
The Flex SDK includes a command line compiler and an ActionScript UI Framework. The UI Framework would be similar, at a high level, to something like JQuery. Most people use Flex as a generic term to refer to all things Flex without specifying "Flex Framework" of "Flex Compiler".
Adobe also provides a commercial IDE named Flash Builder which is used by many to build Flex applications. The 60 day trial you saw was probably for Flash Builder. However, you are more than welcome to use the command line compiler as part of the open source SDK without a purchase of Flash Builder.
JavaScript on the other hand is a language implemented inside web browsers; primarily for modifying a web page without having to reload the whole page.
Both languages are ECMA compliant; so share very similar syntax. The object model would be radically different, though.
 You wouldn't be able to use ActionScript to modify an HTML page's DOM. But, you can use ActionScript to modify and extend the display hierarchy of a Flash movie (SWF).

how to use '\n' within text property of mx:TextArea in flex 4?

Refer this Link.

Disabling Components which contains children(buttons), and preventing from mouse events.

I have many buttons in HBox. Instead of disabling each button, I've disabled HBox. But I am able to click buttons even though the HBox is disabled.


Solution:
setting the mouseChildren and mouseEnabled to false when you want to have your HBox disabled.

myHBox.enabled = false;
myHBox.mouseChildren = false;
myHBox.mouseEnabled = false;

Connecting Flex to SQLServer with .NET as intermediate.

To connect Flex with SQLServer  with .NET webService as intermediate. Refer below Blogs..
1)Refer this
2)Refer this
3)Refer this

Mouse Over and Roll Over in Flex

The mouseOver event is dispatched each time the mouse enters the area of any child object of the display object container, even if the mouse was already over another child object of the display object container. This is different behavior than the purpose of the rollOver event, which is to simplify the coding of rollout behaviors for display object containers with children. When the mouse enters the area of a display object or the area of any of its children from an object that is not one of its children, the display object dispatches the rollOver event. The rollOver events are dispatched consecutively down the parent chain of the object, starting with the highest parent that is neither the root nor an ancestor of the relatedObject and ending with the object.



Refreshing Browser in Flex


1)
var urlRequest:URLRequest = new URLRequest(FlexGlobals.topLevelApplication.url);
navigateToURL(urlRequest,"_self");
2)
var pageURL:String = ExternalInterface.call('window.location.href.toString');
navigateToURL(new URLRequest(pageURL),"_self");