Skip to main content

Posts

Showing posts with the label Regular Expression

Spark TextInput for Currency values

In my project, I wanted to have an spark TextInput to show currency values. While formatting it should show unformatted number. The way I did it is by creating a new CurrencyTextInput class extending spark TextInput. Code for the component is (CurrencyTextInput.as): package com.abcd.component {     import flash.events.Event;     import flash.events.FocusEvent;     import spark.components.TextInput;     import spark.formatters.CurrencyFormatter;     public class CurrencyTextInput extends TextInput     {         public function CurrencyTextInput()         {             super();             formatter = new CurrencyFormatter();             formatter.currencySymbol ...

Download a file using FileReference in Flex

Following function gives an example of how to doanload a file in Flex. "file" object passed to the function is a simple object having following structure: file.fileName = "Abc.png" file.fileType = "image/png" file.url = "/documents/Abc.png" A pattern match-replacement is used to determine file extension, in case fileName does not have it. public function downloadFile(file:Object):void { if (file != null) { var fileName:String = (file.fileName != null && file.fileName.length > 0) ? file.fileName : (new Date()).time.toString(); var fileExtension:String = file.fileExtension; if (fileName.indexOf(".") = 0) fileExtension = fileExtension.slice(fileExtension.lastIndexOf("."), fileExtension.length); else if (fileExtension.lastIndexOf("/") >= 0) fileExtension = "." + fileExtension.slice(fileExtension.lastIndexOf("/...