DIGG IT!
Published
Saturday, June 07, 2003
at
10:43 AM
.
I got tired of referencing ASSetPropFlags at the FlashCoderWiki and wrote a wrapper method to make editing reference properties a bit easier. One of the problems with ASSetPropFlags is that the interface is not very intuitive and restricts usage to advanced developers.
ASSetPropFlags sets properties of a reference (everything in the AS Interpreter is a reference!). This method edits 3 basic properties of a reference:
1. Overwrite - Can the reference be overwritten?
2. Delete - Can the reference be deleted?
3. Hidden - Is the reference enumerable within loops?
The problem is that the property is similar in nature to Unix file settings as you must change all or no settings at all.
Here is the wrapper I wrote:
download protect.as
The wrapper provides access two ways:
//via PSDK
PSDK.protect ( target, props, action)
or
//via inheritance
myObject.protect ( props, action )
props - (string) references that you want an action applied to
action - (string or boolean) modifies the reference properties
Actions works in 3 different modes:
Strict (default) - This modifies the reference properties in an absolute manner
Additive - This adds the passed action to the current reference property setting
Subtractive - This removed the passed action from the current reference property settings
Actions use the characters o, d, h to provide support.
myObj.protect('myprop', true) // strict - adds overwrite, delete, hidden
myObj.protect('myprop', false) // strict - removes overwrite, delete, hidden
myObj.protect('myprop', 'odh') // strict - adds overwrite, delete, hidden
myObj.protect('myprop', 'hd') // strict - adds delete, hidden
myObj.protect('myprop', 'dh') // strict - adds delete, hidden
myObj.protect('myprop', '+dh') // additive - adds delete, hidden
myObj.protect('myprop', '+d') // additive - adds delete
myObj.protect('myprop', '-dh') // subtractive - removes delete, hidden
myObj.protect('myprop', '-d') // subtractive - removes delete
Hope this helps,
ted ;)
0 Responses to “Wrapper for ASSetPropFlags”
Post a Comment