This document provides a short example of how to get started with the AIR and Flex Toolkit.
Overview
This toolkit provides the needed libraries to communicate directly with your salesforce.com database records from within a Flex application, using native ActionScript packages and returning strongly typed classes.
- The documentation on the classes can be found here.
- The library is called as3Salesforce.swc, is in the bin directory just off the root of this zip file
- The sample code is very simple but tests most of the important methods for getting and updating data to and from salesforce.com using the Apex API.
- Note: you must have Flash 9.0 installed in your browser to run this Flex + Saleforce library.
Prerequisites
or
or
- (new) Adobe Flex Builder 3.
You can get access to these from Adobe's Flex.org site.
Quickstart with Flex Builder
Quick Start (Standalone Flex)
- Simply create a Flex project.
- Include bin\as3Salesforce.swc in the library path.
- Drag and Drop the salesforce.mxml file into the Flex project. Right click the file and choose "Set as Default Application".
- Edit the salesforce.mxml file to use your Developer Edition username and password. Search for username and password in the LoginRequest call in the login method.
- Drag and Drop the LeadLookup.mxml file into the Flex project.
- Run the application.
Quick Start (Flex in an S-Control)
- Compile and test localhost SWF
- Create a new scontrol in your salesforce.com organization, copy into the Content portion of the provided scontrol (see: the included file) :
flexScontrolContent.htm
- upload the compiled SWF to the binary portion of the your new scontrol, save this scontrol
- place the scontrol on a web tab. To test it out, click on that tab it should launch and login for you. When you click on the various buttons, callbacks are run, giving feedback on the soap messages sent and the ActionScript objects that result.
Quickstart with just the Flex 2 SDK
If you don't have Flex Builder installed yet, you can still edit and compile the source files. Download and install the Flex 2 SDK from Adobe.
- from the command line set your FLEX_HOME environment variable (in my case this var is set to )
FLEX_HOME='/Applications/Adobe Flex Builder 2 Plug-in/Flex SDK 2'
- run ant in the same directory where this file unpacks
$ ant
- in a web browser click on the local file ./bin/saleforce_test.html. you should see a message about editing the source file to insert your user name and password.
- edit salesforce.mxml to add your username and password for your Salesforce developer edition account
- re-run ant
- click again on the test html file. This should connect you to the salesforce database
Flex Trusted Sites and Directories
Actually ... you will probably get a security error, unless you are running from within Flex Builder, which takes care of this trusted directory for your.
In order for the local swf file to get information from across the network you will need to tell the Flash player that it should trust swf's that are in the dir you're using. You do this by setting the player's advanced options. For details see Trusted Sites and Directories at
you can manually update your trust file:
and
Resources
- AIR and Flex Toolkit - The home page of the AIR and Flex Toolkit, with links to articles, documentation, screencasts and more