Accessing proxy objects
If you want to access a proxy object outside of an auto-release block, you must use
the
RemoveFromAutoReleasePool()
function manually removes an object reference from the auto-release pool before exiting the
auto-release block.
In this example, the reference to the object defined as
RPCMethods.CreateAutoReleasePool();
var selObject = fw.selection.get(0);
RPCMethods.RemoveFromAutoReleasePool(selObject);
RPCMethods.DestroyAutoReleasePool();
Now you can use the selObject object outside the auto-release block.
Note: You must remember to release the selObject object when you are done with it.
Additionally, you can nest auto-release blocks, that is, you can create an auto-release block and
then call a function that creates its own auto-release block. The
iterates through an object's properties and releases any proxy objects it finds.
A simple RPC example
This example creates a 200 x 200 pixel rectangle in Fireworks when a button in a Flash
application is pressed.
To build a Flash application that uses RPC to create a Fireworks object:
Download the supporting ActionScript stub files (a series of supporting ActionScript files) from
1
the Macromedia website, you need to put them in your working directory (where the new FLA
file will reside).
Then, in Flash MX 2004 or Flash MX Professional 2004, open a new document.
2
In the first frame, add the following in the Actions panel to link the general fireworks stub file
3
to the movie when it is published:
#include "fwstubs.as"
Create a simple button which will activate the RPC script.
4
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
6
is pressed:
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;
88
Chapter 3: Cross-Product Extensions
function. The
RemoveFromAutoReleasePool()
selObject
is removed:
function
ReleaseObject()
Need help?
Do you have a question about the FIREWORKS MX 2004-EXTENDING FIREWORKS and is the answer not in the manual?
Questions and answers