Archive for the 'Quick Fix' Category
Creating an MXML based icon for the Halo LinkButton control in Flex 4
The following example shows how you can create an MXML-based icon for the Halo/MX LinkButton control in Flex 4 by creating a custom component using the tag and setting the className property.
Full code after the jump.
<?xml version=”1.0″ encoding=”utf-8″?>
http://blog.flexexamples.com/2009/10/29/creating-an-mxml-based-icon-for-… –>
View original here:
Creating an MXML based icon for the Halo LinkButton control in Flex 4
Adding a gradient background to a Spark Application container control bar in Flex 4
The following example shows how you can create a gradient background Spark Application control bar in Flex 4 by creating a custom skin and setting the skinClass style.
Full code after the jump.
<?xml version=”1.0″ encoding=”utf-8″?>
http://blog.flexexamples.com/2009/09/03/adding-a-gradient-background-to-… –>
Continued here:
Adding a gradient background to a Spark Application container control bar in Flex 4
Setting the control bar layout on a Spark Application container in Flex 4
In a previous example, “Adding a control bar to a Spark Application container in Flex 4″, we saw how you could add a control bar to a Spark Application container in Flex 4 by setting the controlBarContent property.
The following example shows how you can change the layout direction of a control bar in a Spark [...]
Read the original here:
Setting the control bar layout on a Spark Application container in Flex 4
Creating a simple animated text ticker using the Spark TextInput control in Flex 4
The following example shows how you can create a simple, animated text ticker using a Spark TextInput control in Flex 4 by using the Animate and SimpleMotionPath classes to tween the horizontalScrollPosition property.
Full code after the jump.
<?xml version=”1.0″ encoding=”utf-8″?>
See more here:
Creating a simple animated text ticker using the Spark TextInput control in Flex 4
Dynamic Itemrenderer, reload when data changed
I had some troubles to re-load my itemrenderer. When the dataprovider of your collection (Tilebase or whatever) chage, the itemrenderer of exists items does not re-init, if your code is in creationComplete event. Finally I found a solution:in your itemrenderer file, on the creationComplete handler, add:
this.addEventListener(FlexEvent.DATA_CHANGE, dataChanged);dataChanged();
Then, in the dataChange function, you can do whatever you want for your itemrenderer when your dataprovider change.Hope this will help someone.
Pass by value
Actionscript 3 will always pass by reference unless the assignation is a primitive type (such as integer or string). I had an array and want to pass it by value (means it will copy the whole array’s value in it instead of referencing). It is because referencing will affect the referenced array when the new array is being changed in value.I came across with a script to deal with it. it may not be perfect, but have a look:
1 2 3 4 5 6 | public function clone(source:Object):*{ var myBA:ByteArray = new ByteArray(); myBA.writeObject(source); myBA.position = 0; return(myBA.readObject()); } |
Be aware that your objects in your array (or object)’s type may changed to Object/Array instead of it’s previous type.
Problem Downloading File
Click a button and download a file in Flex is very simple but Adobe’s official example has a problem which made me spent like 20 mins to find a work around.
This won’t work:
1 2 3 | var request:URLRequest = new URLRequest("index.xml"); var fileRef:FileReference = new FileReference(); fileRef.download(request); |
But this will:
1 2 3 4 5 | var fileRef:FileReference = new FileReference(); function downloadFile():void { fileRef.download(new URLRequest("index.xml")); } downloadFile(); |