Necessary tools
The following software is required for the instances in this article:
- Flash remoting component-download the flash remoting component.
- ColdFusion MX-a single user test can be downloaded from here.
- Flash MX-test version can be downloaded from here.
- Microsoft Access-the simple database used in the example in this article uses the. mdb Format (ACCESS). However, as long as your data table maintains the consistency between the name and field name, other types of databases can also be used (datasource Name:Flash_cf, Table Name:Sitecontent).
- Demo file-download the file used for the demo.
Flash remoting and ColdFusion components are integrated in five steps.
1st: Data Source
Open the ACCESS database used in this article (find from the downloaded .zip file) and log on as the ColdFusion MX administrator. The name of a table isSitecontent.SitecontentA data table consists of four fields:Pageid,Pagetitle,PagetextAndPagelink. Figure A shows the ACCESS database screen.
Figure
Access Database Screen
2nd: Install the flash remoting component
The Flash remoting Component enables interaction between flash and ColdFusion. For simple directory classification and installation instructions, refer to the instructions on the Macromedia Website.
3rd: ColdFusion component
Access and download the ColdFusion component (CFC) in the ZIP file )(Flash_cf.cfc) And read the source code. ColdFusion's new CFC has the so-called "self-document" feature, that is, they can automatically share their attributes, methods, and other information. CFC is basically a set of functions called methods. They have multiple methods rather than attributes (attributes are required for custom tags), and CFC uses parameters that have already set the application scope when calling methods.
We use CFC to query our access database and display data in flash.
First, observe CFC carefully. OpenFlash_cf.cfc, You can notice that there is a simple method calledGetpageall.GetpageallMethod contains<Cfquery>Label to select the data sourceFlash_cfSitecontent.GetpageallThe method returns the query object to the Flash MX animation through Flash remoting.
Since many CFC are packaged in different categories, they are usually stored in their own directories. So you must ensure thatFlash_cf.cfcSave the file inCFCDirectory.
4th: Flash Interface
OpenFlash_cf.fla, Four layers are found:ActionScript, Dynamic content, layout, and background (Figure B ). ClickActionScriptLayer to open the actions Panel.
Figure B
Demonstration flash Interface
Connect to flash remoting services.Program ListConnect toFlash_cf.cfcAnd expose all the methods.
Port Data through interfaces. On the Dynamic Content layer, you will find the text boxSite_title, Instancename_0 andSite_link. We useProgram list BMentioned inActionScriptFunction fill data.
Text BoxSite_linkIt will contain HTML data. This is also a method to link websites from flash. ClickSite_linkThe HTML formatting button is selected in the text box.
5th: test the application
The last step is to test the application. You should release your own Flash animation, and observe how the simple flash interface extracts data from the access data through CFC. Figure C shows the screenshot of the Flash animation.
Figure C
Demonstration of Flash Animation screenshots