Adobe 65011817 - Fireworks CS4 - Mac Extended User Manual page 295

Extending guide
Hide thumbs Also See for 65011817 - Fireworks CS4 - Mac:
Table of Contents

Advertisement

Last updated 12/8/2009
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).
Open a new document in Flash.
2
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.
Insert the button in the first frame, in the middle of the Stage.
5
Attach the following ActionScript code to the button to activate the RPC code when the button is clicked:
6
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();
Publish the SWF file.
7
When you publish the SWF file, make sure the stubs files are in the same directory as your FLA file.
291
EXTENDING FIREWORKS
Cross-Product Extensions

Advertisement

Table of Contents
loading

This manual is also suitable for:

Fireworks cs4

Table of Contents