Posts in Category "Flex"

Notes about caching

1. caching to the disk is controlled by browser, not by flex/flash. The browser cache can be saved to the disk, flash player cache will only be in the memory.
2. By default, browsers can cache content over http ( if you didn’t set no-store no-cache in the header ).
3. However, browsers may not cache content to disk over https by default and you need to configure it.
For IE, you can turn on the feature by change setting at:
Tools > Internet Options > Advanced tab > Security section > Do not save encrypted pages to disk
For Firefox, see details in
4. Only signed RSLs can be stored in the player cache, unsigned will be in browser cache. Only Adobe can create signed RSLs. If you create an RSL that contains a customer library, it will be unsigned, so can’t be in player cache. There is no workaround for this at the moment. Your option is to use unsigned with browser’s cache.
5. If your app get an connect problem over the first request, but works fine after a refresh, that usually is caused by the content cache over https issue. See above for how to correct it.

RTMFP — Real-Time Media Flow Protocol

A great new article about RTMFP

using webtier compiler with flex 3

In flex 2, the webtier compiler is included in the SDK. But in flex 3, it is no longer included in the flex 3sdk install. You have to install and configure it separately. The following links will show you how to install and configure it.

There are two type of configuration:

1. config with Apache or IIS connector. If you are using Apache or IIS as your web server, then this may be the approach you want to take.

2. install as a J2EE app. This approach will install a webtier.war to your machine. Then you can deploy this war file to the app server you are using. You should deploy it as extracted app, and put your flex app page under the web root.


When you run a flex app page with the webtier compiler, it runs fine the first time you request it. If you modify anything in the code and recompile that page, then you may see the following Error:

at mx.styles::StyleManagerImpl/initProtoChainRoots()
at mx.styles::StyleManager$/

See bug for details.

By default, we are using incremental compile to do the compiling, but the incremental compile has some issues. The workaround is to not use the incremental compile.

in flex-webtier-config.xml; set the incremental-compile to false:

Once the change is made, the webtier compiler will work properly.

How to turn on debug trace in Flex

When you encounter issue wit your flex app, one useful tool for troubleshooting is to turn on debug in flex to get some output that will provide some clue of the cause of he problem. Here is how to turn it on from server-side as well as from client-side:
1. From server side:
In the services-config.xml, set the logging level to debug, and set filters to include the service you need:

<target class=”flex.messaging.log.ConsoleTarget” level=”debug”>
<prefix>[Flex hotfix2] </prefix>

See available pattern in doc:

2. To turn on trace in JGroup:
in jgroups-tcp.xml, add <TRACE/> tag just before the </config> line :


3. To turn on from client-side:
Make sure flashlog.txt is enabled, i.e, have the following setting in mm.cfg
See more details in the doc here
There is a good blog regarding mm.cfg here as well.

Then in your flex app, add the following tag:

4. To turn on the flash player policy logging


Tips for working with time zone in flex app

From flex doc we can see:


Control Panel –> Date and time –>Time Zone.

See more details in here


— if you are using Solaris, you may need this patch

Download time.jsp from there, and run it on your server.
java.args=-Xms32m -Xmx384m -Duser.timezone=Etc/UCT

3. synchronize time znoe on client and server


How to apply chart license to flex 3

Also see Blog entries:

Basically, here are the things you need to know:
3. To apply the license in flex-config.xml:



4. To apply the license in file:



1. create a customer event ActionScript class:


     import mx.core.Application;

    public class myEvent extends Event
            public var myAlbum:String;
            public function myEvent(selectedAlbum:String,type:String) {
                     this.myAlbum = selectedAlbum;
           public override function clone():Event{
                    return new myEvent(myAlbum,type);

2.  Create the main application:







main flex page looselyCoupled.mxml:








                      import mx.collections.ArrayCollection;


                      public var selectedAlbum:String;

                      public var eventObj:myEvent;


                      private var initDG:ArrayCollection = new ArrayCollection([


                      Price:11.99, SalePrice: true },


                      Price:11.99, SalePrice: false }


        private function itemClickEvent(event:ListEvent):void {


                                    eventObj = new myEvent(selectedAlbum,"passID");




                             private function eventHandler(stateView:String):void{

                             //the stateView must be created before the event dispatch.

                                    this.currentState = stateView;



                      private function dispatchEvt():void{

                                    eventObj = new myEvent(selectedAlbum,"passID");











                        <mx:State name="child">

                                      <mx:AddChild position="lastChild">

                                                                <v:looselyCoupledChild />





3. create the child component:




import mx.core.Application;
import myEvent;
private function initHandler():void{
Application.application.addEventListener("passID", passIDHandler);

private function passIDHandler(event:myEvent):void {
tinput.text = event.myAlbum;




Note, Application.application.addEventListener("passID", passIDHandler);

To test the sample,




Links to nice flex 2 examples

1. Design loosely coupled Flex 2 components

2. Export datagrid to Excel:

3.Internationalizing Flex Apps

4. Coloring the Background of Cells

Scaling an image with smoothing

6. Unicode support
In order for it to work, you have to make sure
1).your font must support those characters.
2). you need to set the correct fontFamily,
3). you need to set character ranges

Here are couple of simple examples: to come ….

MouseWheel support on MacOS X

It seams that flex is unable to receive the MOUSE_WHEEL MouseEvent on Mac computers. This is because Flash MouseWheel is not supported on Mac by default. This has been submitted as an enhancement request already. At the meantime, there are add-on examples you can consider. See one of them here:

How to access cfc on your Coldfusion server from flex app on a separate server.

Coldfusion 7.0.2 added flex feature support, hence you can access your cfc service from flex app. See a good article by Kyle about how this works at here.

The above article described how to access cfc using RemoteObject in flex app when your cfc and mxml pages are both on the same Coldfusion server. If you have your cfc services in an existing Coldfusion app, and you want to create new flex app on a remote server, how do you access the existing cfc services now? Here we will go through the steps to make that configuration work.

The reason the example works in above article is because CF 7.0.2 implemented gateway to access AMF, and by default a destination/channel is defined in CF app WEB-INF/flex/services-config.xml. When running the flex app on a remote server, we will need to use flex app gateway instead, and configure destination/channel in the flex app.

Let us use the example in the above article, download to your machine.

1. Extract HelloWorld.cfc to your Coldfusion app root. For me, it is C:\flex\jrun4\servers\cfusion\cf702. Here, cfusion is a server instance, /cf702 is the context root. It uses port 8300.

2. Extract folder HelloWorld_ro to your flex app root. For me, it is C:\flex\jrun4\servers\default\samples2, default is a server instance, /samples2 is the context root. It uses port 8700.

3. Copy the following and Paste it into your flex app WEB-INF/flex/remoting-config.xml, inside the <service> tag, parallel to other destination tag.

<destination id=”ColdFusion”><channels> <channel ref=”my-cfamf”/> </channels> <properties> <source>*</source> </properties> </destination>

4. Copy the following and Paste into your flex app\’s WEB-INF/flex/services-config.xml, inside <channels> tag, parallel to other channel-definition.

<channel-definition id=”my-cfamf” class=”mx.messaging.channels.AMFChannel”> <endpoint uri=”http://{}:{server.port}{context.root}/flex2gateway/” class=”flex.messaging.endpoints.AMFEndpoint”/> <properties> <polling-enabled>false</polling-enabled> <serialization> <instantiate-types>false</instantiate-types> </serialization> </properties> </channel-definition>

5. Define your endpoint. You can configure the destination in servicees-config.xml. See above channel-definition you just added. You can change uri=”http://{}:{server.port}{context.root}/flex2gateway/” to point to your real server name and port. For this example, it is http://linIp:8300/cf702/flex2gateway.

Or you can override it in your RemoteObject tag:

<mx:RemoteObject endpoint=”http://linIp:8300/cf702/flex2gateway/”
source=”HelloWorld”><mx:method name=”sayHelloString” result=”handleStringResult(event)” fault=”” /></mx:RemoteObject>

6. Make sure both Coldfusion and flex server are running.

7. run HelloWorld_ro.mxml either from flex builder or by request
http://localhost:8700/samples/HelloWorld_ro/ HelloWorld_ro.mxml,
you should see a button with label "get String Remote Object", click on it, you should see "Hello World!" displayed on top of the button.

8. If you are using standalone Coldfusion with default install, then put HelloWorld.cfc under C:\CFusionMX7\wwwroot. Note the context root now is /. If you are using port 8500 for this server, then your endpoint would be:

Note, step 3 to step 6 is to configure channel in the configuration files. You can also assign channels on the client at run time by creating a ChannelSet object that contains one or more Channel objects, and assigning the ChannelSet to a service componen. See flex doc for details.