Tag Archives: load()

Previewing an image before uploading it using the FileReference class in Flash Player 10

The following example shows how you can browse for an image file from your local file system and preview the image before uploading it to a remote webserver by using the FileReference class’s new load() method in Flash Player 10. Once the user has browsed and selected an image from their local machine, you can call the load() method which dispatches a complete event when the image has successfully loaded, at which point you can display the image using a Flex Image control and setting the Image instance’s source property to the FileReference class’s data property (which is a ByteArray).

Full code after the jump.

Continue reading Previewing an image before uploading it using the FileReference class in Flash Player 10

Preventing an image from automatically loading in an Image control in Flex

The following example shows how you can prevent the Flex Image control to automatically loading an image when setting the Image control’s source property by setting the autoLoad property to false and then explicitly loading the image using the load() method.

Full code after the jump.

Continue reading Preventing an image from automatically loading in an Image control in Flex

Displaying an image saved as a Base64 encoded string in Flex 3

In a previous example, “Using the ImageSnapshot class to capture images as JPEGs or PNGs in Flex 3”, we saw how you could convert an item on the display list into a base64 encoded string.

The following example shows how you can take a base64 encoded string and load it into a Flex Image control using the decode() and toByteArray() methods in the mx.utils.Base64Decoder class, and the load() method in the mx.controls.Image class.

Full code after the jump.

Continue reading Displaying an image saved as a Base64 encoded string in Flex 3