Cross-product architecture
113
Here is an example:
RPCMethods.CreateAutoReleasePool();
var selObject = fw.selection.get(0);
RPCMethods.DestroyAutoReleasePool();
Calling the
CreateAutoReleasePool()
function marks the beginning of the auto-release
block, and calling the
DestroyAutoReleasePool()
function marks the end. Any object
allocated between these two calls is released by calling
DestroyAutoReleasePool()
. Using
these two functions, you can write ActionScript code and not worry about memory
management.
Accessing proxy objects
If you want to access a proxy object outside of an auto-release block, you must use
the
RemoveFromAutoReleasePool()
function. 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
selObject
is removed:
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.
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
ReleaseObject()
function
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 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 Macromedia website, you need to put them in your working directory (where the
new FLA file will reside).
2.
Open a new document in Flash 8.
NO
TE
You must remember to release the selObject object when you are done with it.
Summary of Contents for FIREWORKS 8-EXTENDING FIREWORKS
Page 1: ...Extending Fireworks ...
Page 4: ...4 Contents ...
Page 358: ...358 Fireworks JavaScript API ...
Page 372: ...372 Index ...