Adobe COLDFUSION 9 Manual page 664

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:local="com.*" creationComplete="init()" xmlns:cf="coldfusion.service.mxml.*">
<mx:Script>
<![CDATA[
import coldfusion.service.events.*;
import com.CFCredential;
import mx.collections.ArrayCollection;
import mx.binding.utils.BindingUtils;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import flash.events.*;
import flash.net.FileReference;
import flash.net.FileReferenceList;
import flash.net.URLRequest;
import flash.net.URLVariables;
import coldfusion.service.Util;
public var fileTypes:Array = new Array();
public var imageTypes:FileFilter = new FileFilter("Images (*.jpg; *.jpeg; *.gif; *.png)"
,"*.jpg; *.jpeg; *.gif; *.png");
public var documentTypes:FileFilter = new FileFilter("Documents (*.pdf), (*.doc), (*.rtf),
(*.txt)",("*.pdf; *.doc; *.rtf, *.txt"));
[Bindable]
private var fileslist:ArrayCollection;
private var filereflist:FileReferenceList
public var fileRef:FileReference = new FileReference();
[Bindable]
public var mailPartArray:Array = [{type:"text",content:"Plain text only"},
{type:"html",content:"<B>bold text man!!</B>"}];
public var uploadURL:URLRequest = new URLRequest();
[Bindable]
public var attachCollection:Array = new Array();
public var urlcnt:int=0;
public function init():void
{
fileslist = new ArrayCollection();
filereflist = new FileReferenceList;
fileRef = new FileReference;
uploadURL.url =
"http://"+conf.cfServer+":"+conf.cfPort+"/"+conf.contextRoot+"/"+Util.UPLOAD_URL;
var variables:URLVariables = new URLVariables();
variables.serviceusername = conf.serviceUserName;
variables.servicepassword = conf.servicePassword;
uploadURL.data = variables;
uploadURL.method = "POST"; //this can also be set to "POST" depending on your needs
uploadURL.contentType = "multipart/form-data";
fileTypes.push(imageTypes);
fileTypes.push(documentTypes);
//Add Event Listeners to UI
attachbutton.addEventListener(MouseEvent.CLICK, browseFiles);
sendbutton.addEventListener(MouseEvent.CLICK,uploadFiles);
filereflist.addEventListener(Event.SELECT, selectHandler);
//mailtest.send();
}
//Browse for files
Last updated 8/5/2010
659

Advertisement

Table of Contents
loading

Table of Contents