Home Tutorial Flex Flex4 Components Window Container in Flex4

 
 

Share on Google+Share on Google+
Window Container in Flex4
Posted on: May 12, 2010 at 12:00 AM
Advertisement
This container are use window applications in flex 4. Spark Window container is provide a way if user want to create own window.

Window Container in Flex4 :

This container are use window applications in flex 4. Spark Window container is provide a way if user want to create own window. The Window container are provide layout and content of operating system window that's created after the application are initiated. In this example user can see how to create Window container in Flex4. The MXML tag for creating Window container is <s:Window/>. User can set the main characteristic for the window container. In this example user can see how to create a window container component. First  we have create a main application and after that we have create Window component and used this component in own application that's have a login process.

Example:

<?xml version="1.0" encoding="utf-8"?>

<!-- aircomponents/src/WindowSplash.mxml -->

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

creationComplete="init();">

<fx:Script>

<![CDATA[

import myComponents.formWindow;

private const startTime:int = 10;

private var endTime:int = 0;

private var timer:Timer;

private var formWindowobj:myComponents.formWindow;

private function init():void {

var screenBounds:Rectangle = Screen.mainScreen.bounds;

nativeWindow.x = (screenBounds.width - nativeWindow.width) / 2;

nativeWindow.y = (screenBounds.height - nativeWindow.height) / 2;

timer = /font>new Timer(1000);

timer.addEventListener(TimerEvent.TIMER, incrementTime);

timer.start();

}

private function incrementTime(event:TimerEvent):void {

endTime++;

if ((startTime - endTime) == 0)

{{

timer.stop();

timer.removeEventListener(TimerEvent.TIMER, incrementTime);

timer = /font>null;

nativeWindow.close();

formWindowobj = new formWindow();

formWindowobj.open();

}}

}

]]>

</x:Script>

<s:VGroup horizontalCenter="0" verticalCenter="0">

<s:Label text="This is Original Screen" fontFamily="New Times Roman" fontSize="20" fontWeight="bold"/>

<s:Label text="Wait.." fontFamily="New Times Roman" fontSize="20" fontWeight="bold"/>

</s:VGroup>

</s:WindowedApplication>

This is the code of main application and the code of window component is

<?xml version="1.0" encoding="utf-8"?>

<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

width="250" height="200" title="Login Window">

&l<s:layout>

<VerticalLayout/>

</s:layout>

<fx:Script>

<![CDATA[

private function login():void {

if(username.text==""){

uname.text = "Please enter User Name";

uname.visible=true;

}

if(password.text==""){

pass.text = "Please enter password";

pass.visible=true;

}

if(username.text!="" && password.text!=""){

uname.text = "Welcome "+username.text;

uname.visible=true;

pass.visible=false;

}

}

]]>

</fx:Script>

<mx:Form>

<mx:FormItem label="User Name:">

<s:TextInput id="username" width="100%"/>

</mx:FormItem>

<mx:FormItem label="Password:">

<s:TextInput id="password" width="100%" displayAsPassword="true"/>

</mx:FormItem>

</mx:Form>

<s:HGroup horizontalAlign="center">

<s:Button label="Login" click="login();" />

</s:HGroup>

<s:VGroup>

<mx:Text id="uname" visible="false"/>

<mx:Text id="pass" visible="false"/>

</s:VGroup>

</s:Window>

The system provide a native window but user want to create own window then use this process.

Output:

After some time system remove this window and give window that's have a login process like this

Download this code
Advertisement

Related Tags for Window Container in Flex4:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com