aodz

Archive for the ‘flex’ Category

Caching of  image data  in your Flex application is one of the best ways to avoid loading those large images again and again, and this  can  improve performance and reduce overhead of loading external resources.

We are not discussing about using the cacheAsBitmap property to improve rendering performance or the cachePolicy property to speed up animations. Its the caching of actual bitmap data of an image. As the 2 are different in one case we just cache the image data of an image that has to be animated and component doesnot reload any image. in the other case we  reload the data on demand  for example user profile with display picture. In this case the picture mostly does not change (well it does but  we can handle it differently) so we dont need to reload the image at each time the user profile data of the same person is called.. so we can impliment a cache here.

You’ll need a hash map to store the image data. A Dictionary or an associative array will also work just fine. Loading an image for the first time is the same as usual. You create a new Image object and add a listener for the COMPLETE event or it could be any of your custom event for the sake of example we will follow :

var image : Image = new Image ();
image.addEventListener (Event.COMPLETE, onImageLoad);

Once the image has finished loading, you add a copy of the bitmap data to the hash map using the image URL as the hash key as the URL for any image will always be distinct:

private var imageCache : hashMap = new hashMap(); // create hashmap only once

private function onImageLoad (event : Event) : void{
var image : Image = event.target as Image;
var imageURL : String  = image.source;
if (! imageCache.containsKey (imageURL))
{
var bitmapData : BitmapData = new BitmapData
(image.content.width, image.content.height, true);
bitmapData.draw (image.content);
imageCache.put (imageURL, bitmapData);
}
}

The above method is called and the image is cached in the hash map. Now you can use the image as many times as we want without ever having to load it again. A good exapmle of this could be  loading user profile whenever you reload the profile data one need not fetch the  user profile picture. the picture can directly be accessed from the hashmap.

How do we use the image we stored, Its simple you need to check the hash map each time you call for the loading the image just check if you’ve already cached it:

// check the hashmap when ever next you want to load the image

if (imageCache.containsKey (imageURL)){
image.source = new Bitmap (imageCache.getValue (imageURL));
}

thats it now you can use the cache whenever required.

Advertisements

Date objects don’t have a built-in compare() method, but comparing dates  easy.Don’t  look at the Date objects , but rather the values represented by the objects using the Date.getTime() method:

Date.getTime() : Returns the number of milliseconds since midnight January 1, 1970, universal time, for a Date object. Use this method to represent a specific instant in time when comparing two or more Date objects.

This makes comparing dates as trivial as comparing numbers. Here’s a simple method that compares two dates, returning minus one (-1) if the first date is before the second, zero (0) if the dates are equal, or one (1) if the first date is after the second:

public function compare (date1 : Date, date2 : Date) : Number {
var date1Timestamp : Number = date1.getTime ();
var date2Timestamp : Number = date2.getTime ();
var result : Number = -1;
if (date1Timestamp == date2Timestamp){
result = 0;
} else if (date1Timestamp > date2Timestamp){
result = 1;
}
return result;
}

regular-expressions-cheat-sheet-v2

to see large version, right click save as image

Today Imtiyaz and I did a small hack in the Flex charting code and removed the Trial message from the Charting component by writing 1 simple actionscript lines.

what you need to do is in the creationcomplete of any charting component write the following code

//            var arra : Array = new Array();
//            for(var i:int =0;i<this.numChildren;i++){
//                arra.push(this.getChildAt(i));
//            }

// the above 4 lines are just to check  what r the childs added

(this.getChildAt(this.numChildren-1) as TextField).htmlText = ” “;

we  tried to set visible false but that dint work we also tried to remove the textfield child alltogether  but that too dint work 😛 but finally it was the html text property of the textfield that gave way 😀

now you can also add your custom  trial message to your application 🙂

just replace the blank with your text for example:

(this.getChildAt(this.numChildren-1) as TextField).htmlText = ” YOUR MESSAGE”;

But its better that you buy your own licence key for charting. The above example was basically for educational purpose. have fun 🙂

trial

The upcoming version of the tool to build your flex applications is called Flash Builder! (formally known as Adobe Flex Builder). The flex framework will continue to be known as Flex. The naming is appropriate given the fact that every one who is building a Flex / Flash / AIR app today is building it on top of the “Adobe Flash Platform”

Welcome, Flash Builder!

Tags:

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”>
<properties>
<prefix>[Flex hotfix2] </prefix>
<includeDate>true</includeDate>
<includeTime>true</includeTime>
<includeLevel>true</includeLevel>
<includeCategory>true</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Protocol.*</pattern>
<pattern>Message.*</pattern>
<pattern>DataService.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>

See available pattern in doc:
http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/lcds/help.html?content=services_logging_3.html

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

<config>
….
<TRACE/>
</config>

3. To turn on from client-side:
Make sure flashlog.txt is enabled, i.e, have the following setting in mm.cfg
TraceOutputFileEnable=1
ErrorReportingEnable=1
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:
<mx:TraceTarget/>

4. To turn on the flash player policy logging

see http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_05.html

Original post

Tags: , ,

Here is an example of Data grid filtered using a H slider  with 2 thumbs to select the range of date for which to  filter the data grid. The combo box is used to select the specific column on which the filter has to be applied to. The check box is used to either enable or disable the filter functionality.

Screenshot:

testfilterdg

For source please read the complete article Read the rest of this entry »


I have moved to a different location

check out my new home Flexout

calendar

September 2017
M T W T F S S
« May    
 123
45678910
11121314151617
18192021222324
252627282930  

Blog Stat

  • 83,725 Hop's so far!!!

follow me

Archives

Linkedin Blogger Twitter Youtube Orkut

Top Clicks

  • None

latest flickr photos

top rated