blog.ashier.com flash / flex / air development
rss rss comment

Posts Tagged ‘Flex’

Deferred instantiation is a common technique used to improve Flex application start-up time and to control when and how to instantiate child components within a container when the creationPolicy is set to none.

Last week, I was able to implement this into an application we’re currently developing at work. It took me a while to figure it out but I must say, it is really handy. A ViewStack for example will allow switching from one child to another, but as the child of that container gets to be really complicated, it may highly affect your application’s performance.

Why???
If no creationPolicy is specified for a container, that container inherits its parent’s creationPolicy. If no creationPolicy is specified for the Application, it defaults to ContainerCreationPolicy.AUTO.

This is where Deferred Instantiation can save your day.

I have below a basic example of how you can implement Deferred Instantiation using createComponentFromDescriptor()

createComponentFromDescriptor allows you to create one child at a time.

Read the rest of this entry…

Tags: ,

When creating Flex components, all child components (buttons, combobox, etc..) you add are always publicly accessible. There is a way to hide this and this is by using the Metadata tag "Exclude"

Here is a common Flex Component Example:

Actionscript:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
  3.     <mx:Button x="167.5" y="146" label="Click Me" id="btn"/>
  4. </mx:Canvas>

In the example above, "btn" property is publicly accessible outside that component. For you to hide it, you must add an "Exclude" metadata tag.

Here's is an example:

Actionscript:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
  3.     <mx:Metadata>
  4.         [Exclude(name="btn", kind="property")]
  5.     </mx:Metadata>
  6.     <mx:Button x="167.5" y="146" label="Button" id="btn"/>
  7. </mx:Canvas>

Now, the "btn" property won't be accessible outside that component. will still be accessible but it won't show up in the code hinting. Thanks to Sid Maskit for pointing this out.

Sid Maskit provided ways on how to do this not using the [Exclude] metadata/

Other Exclude kinds are

[Exclude(name="direction", kind="property")]
[Exclude(name="setFocus", kind="method")]
[Exclude(name="focusIn", kind="event")]
[Exclude(name="horizontalGap", kind="style")]
[Exclude(name="focusInEffect", kind="effect")]

Resource Blog

Tags: ,

There are alot of ways to connect to a remote service in Flex / Flash.

You can do it tag based:

Actionscript:
  1. <mx:Application
  2.     xmlns:mx="http://www.adobe.com/2006/mxml"
  3.     layout="absolute">
  4.    
  5.     <mx:RemoteObject id="blazeService" fault="onFault(event)" source="hello.Hello" endpoint="http://localhost:8400/hello/messagebroker/amf/" destination="Hello">
  6.         <mx:method name="sayHello" result="onResult(event)" />
  7.     </mx:RemoteObject>
  8.  
  9.     <mx:Script>
  10.    
  11.         <![CDATA[
  12.             import mx.messaging.channels.AMFChannel;
  13.             import mx.rpc.events.ResultEvent;
  14.             import mx.rpc.events.FaultEvent;
  15.            
  16.             private function onResult(e:ResultEvent):void {
  17.                 trace("Result" + e.result);
  18.             }
  19.            
  20.             private function onFault(e:FaultEvent):void {
  21.                 trace("fault");
  22.             }
  23.         ]]>
  24.     </mx:Script>
  25.    
  26. </mx:Application>

or actionsript based:
Read the rest of this entry...

Tags: , , , , ,

Here's how I managed to setup BlazeDS on my windows local machine.

Steps:

1. Download the latest BlazeDS.
2. Extract it.
3. Download the latest Java Development Kit (JDK), Install it.
4. Set JAVA_HOME environment variable.

Setting up Environment Variable in Windows

1. Open Control Panel
2. Click the System icon then a window will pop up
3. Go to the Advanced tab
4. Click the "Environment Variables"
5. Select "New" in System Variables.
6. In the Variable Name textbox type JAVA_HOME
7. In the Variable Location textbox type the JDK directory

you should be able seeing this:

jdk.jpg

8. Click Ok.
9. Click Ok.

4. You're done installing BlazeDS.

Running Installed Sample Applications.

1. Start Tomcat by double clicking [blazeds directory]tomcat\bin\startup.bat
2. Now, check if it works by running http://localhost:8400/ in your browser.

You should be able to see this in your browser

Read the rest of this entry...

Tags: , , ,

Why Flex? - Ben Forta

http://www.30onair.com/

Tags: ,

While reading at Ted Patrick's blog, I found out that they are already working on flex to run on mobile platforms. This again is a good news for us. Just like what Ted said, Flex is really revolutionizing development, either its in the web, desktop, and mobile.

Ted Patrick's Blog
What is Flex?

Tags: ,