Wednesday, May 4, 2011

Find out args length of a function

Here is a sample program to get the number of arguments that a function takes.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="initAPP()">

<mx:Script>
<![CDATA[

private function initAPP(one:int=0, obj:Object=null):void {
}

private function showFunctionArgumentsLength():void {
trace("Length: "+ (initAPP as Function).length)
}

]]>
</mx:Script>

<mx:Button label="Check" click="showFunctionArgumentsLength()" />

</mx:Application>



Note: This will give you all the arguments length, not only required params.


Wednesday, September 22, 2010

Reset Array in Flex

This is simple tip to reset the array in FLEX.

I am not sure why Array length setter method is public, may be because of this we have the hack.

var array:Array = [1,2,3,4];
trace(array.length); // 4
array.length = 0;
trace(array.length); // 0

Thursday, November 12, 2009

Lazy Loading

By Amy Blankenship

Definition: -

Wikipedia defines Lazy Loading as "a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed." Typically, we do this to make an RIA application more responsive–since we're not pulling huge amounts of data from the back end at one time, the user doesn't have to wait as long for the call(s) to complete. In particular, this pattern is especially useful with hierarchical data sets (grandparent, parent, child, etc.) where the number of nesting levels might not be known at design time.

Advantages of Lazy Loading

Flex caching mechanism

From Ted,

Flash Player 9 and above, adds support for caching the Flex Framework within the Flash Player. This feature is nothing short of a revolution for Flex applications deployed to Flash Player. Moving forward the Flex Framework will be cached within the Flash Player dramatically reducing the size of the output SWF files. Your application SWF files will only contain your code plus the Flex Preloader containing the caching/loading logic and will exclude by majority the Flex Framework. Simply put, the file size cost of using any additional component adds negligible size to your base SWF file.

In Details:

Cross-Domain:
The Player Cache allows the Flex Framework to be cached for use across domains. Say the end user visits Yahoo Web Messenger and receives the Flex Framework (Flex 3.0.0 Moxie) for caching. If they then visit Picnik.com or SlideRocket.com or Buzzword or BrightCove.com, and these sites are targeting Flex 3.0.0 Moxie), these sites will reuse the Flex Framework cached within the Flash Player. Because the Framework is cached across domains many sites can receive the benefits of reduced SWF size.

Versionable:
The Player Cache supports Flex 3.0 and future versions of the Flex Framework. Your application can pick which version of the Flex Framework to use and regardless of what changed in Flex moving forward, the legacy version will just work. Each RSL cached within the Flash Player is stored under a unique SHA256 hash based on its unique binary content and signature.

Easy to Use:
The MXMLC/COMPC compilers and Flex Builder 3 makes supporting this functionality easy to use. The Flex Preloader has been enhanced to support the Player Cache features.

Security and Code Signing:
Caching of RSL assets across domains opens many security issues if anyone can cache code in Flash Player. To eliminate this risk code signing was added in Flash Player and assets using this feature must be signed by Adobe. Without this tight security model this feature could never have been added to Flash Player. The upside is that with Flex 3 going Open Source, developers can get new features and components added into the Flex Framework which supports this feature.

Failover and Hosting:
The Flex Framework RSL can be located anywhere even in multiple locations. A site using this Player Cache is not dependent on an Adobe domain or any 3rd party site. The feature includes support for failover URLS so that the Flex Framework SWF can be located in multiple locations cross domains. If downtime on a server occurs, the application will download the Framework RSL from a failover URL.

Cross-Domain RSL:
In parallel with this feature, the Flex Framework now supports Runtime Shared Libraries (RSL's) to be loaded across domains with a Cross-Domain Policy File. Say for example Yahoo wanted to provide an RSL for all Yahoo properties using Flex 3, they could host an RSL that any team could load at runtime to allow code-reuse cross-team and cross-project hosted across Yahoo domains.

Thursday, November 5, 2009

Postgres PGDATA folder location change

Step1: stop the postgre service



Step2: Copy the PGDATA(data) folder to a new location

Step3: Goto regedit(Windows) HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->postgresql"version"



Step4: Edit ImagePath, change the location of the data* folder



Step5: Edit the postgre service, check "path to executable" the data folder should get changed.



Step6: Start the postgre service.

*note: The data folder location should have the Administrator writes in order to start the service

Configure Tomcat JVM heap size

Running Tomcat using catalina.bat

Windows
1. Set the CATALINA_OPTS -Xms512m -Xmx1024m in the environment variables.
2. Open the command %CATALINA_HOME%/bin catalina.bat run
3. Open browser- go to tomcat index.html
4. Click Status tab left side the screen
5. Check the JVM values

it should display what ever we entered in the CATALINA_OPTS parameter in the environment variable

*note: if a dos prompt is already open close it and open a new dos prompt and run the "catalina.bat run"

I am Flex Hacker







I am hackr



check out the link :- http://flashahead.adobe.com/challenges/fiawchallenge/

Wednesday, April 8, 2009

Javascript from Flex

Application calls Javascript from Flex

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
<![CDATA[

/* */
private function initApp():void
{
if(ExternalInterface.available)
{
ExternalInterface.call("alert", "Hello from java script");
}
}
]]>
</mx:Script>
<mx:Button label="Call JS" click="initApp()" />
</mx:Application>





AIR window status message

Application to set the status message in AIR window.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="initApp()"
statusBarBackgroundColor="#f0f0f0">
<mx:Script>
<![CDATA[
import mx.core.Application;
/*  */
private function initApp():void
{
Application.application.status = "Staus message goes here";
}
]]>
</mx:Script>
</mx:WindowedApplication>

Application to prevent window close

Application to prevent window close by default and do some action.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.controls.Alert;
/*  */
private function initApp():void
{
this.addEventListener(Event.CLOSING, onClosing);
}
/*  */
private function onClosing( event:Event ):void
{
event.preventDefault();
Alert.yesLabel = "yea";
Alert.noLabel = "na";
Alert.show("You want to exit?","Close", Alert.YES|Alert.NO, this, alertHandler, null, 2);
}
/*  */
private function alertHandler( event:CloseEvent ):void
{
if( event.detail == Alert.YES)
{
this.nativeApplication.exit();
}
}
]]>
</mx:Script>
</mx:WindowedApplication>