Adobe 65011817 Extended User Guide - Page 295
A simple RPC example
UPC - 883919157368
View all Adobe 65011817 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 295 highlights
Last updated 12/8/2009 EXTENDING FIREWORKS 291 Cross-Product Extensions A simple RPC example This example creates a 200 x 200 pixel rectangle in Fireworks when a button in a Flash application is clicked. To build a Flash application that uses RPC to create a Fireworks object: 1 Download the supporting ActionScript stub files (a series of supporting ActionScript files) from the Adobe website, you need to put them in your working directory (where the new FLA file will reside). 2 Open a new document in Flash. 3 In the first frame, add the following in the Actions panel to link the general fireworks stub file to the movie when it is published: #include "fwstubs.as" 4 Create a simple button which will activate the RPC script. 5 Insert the button in the first frame, in the middle of the Stage. 6 Attach the following ActionScript code to the button to activate the RPC code when the button is clicked: on(press){ RPCMethods.CreateAutoReleasePool(); var fw = new Fireworks(); //Hide all panels - this function commented out as it will crash if run from inside Fireworks //fw.setHideAllFloaters(true); //Define the document objects the long way var res = new Object(); res.units = "inch"; res.pixelsPerUnit = 72; var size = new Object(); size.x = 220; size.y = 220; //Create new doc var fwdoc = fw.createFireworksDocument(size, res, "#0033FF"); //Define a rectangle object the short way var rect = {left:10, top:10, right:210, bottom:210}; //Add Rectangle fwdoc.addNewRectanglePrimitive(rect,0.20); //Set its color fwdoc.setFillColor("#00CC99"); RPCMethods.DestroyAutoReleasePool(); } RPCMethods.DestroyAutoReleasePool(); 7 Publish the SWF file. When you publish the SWF file, make sure the stubs files are in the same directory as your FLA file.