Wednesday, March 17, 2010

Enabling Drag Drop in a Chart

Recently I was looking out for some samples to get the drag and drop working in my chart. All the examples that I went through had drag and drop implemented that enabled dragging from one container to another. While it was useful I was not able to find a sample to get drag drop in the same chart. This is a direct result of that. Hope it is useful for someone.

Monday, March 8, 2010

Getting Image Width at Runtime

Recently I ran with some requirements and needed to get the size of an uploaded image in Flex, which led me to getting an insight of the size data that the image stores.

So what we have and usually use is the width/height property of the Image control. This is a property that is explicitly set by the developer. If not set, the property takes the value of the image’s width and height. To find the final size one has to listen to the updateComplete event.

The other property of the image is the contentWidth/contentHeight. This property gives the size of the scaled image based on the scale ratios. Again this can be found if one listens to the updateComplete event.

The final property [the one that I was looking for :)], can be found inside the content property in the image. The image.content contains the unscaled width and height of the original image data. We can access it using the image.content.width/image.content.height property. What's good is that this property is updated on the complete event of the image load.

-- Cheers.