- Home
- Tutorials
- Flash
- Intermediate
- ASSetPropFlags

Page 3 of 3
Guy Watson
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by Guy WatsonRe-define the properties value so we can use it again in the further examples:
myproperties.firstname="Guy";
Protect all properties from deletion:
ASSetPropFlags(myproperties,null,2,1);
Try to delete the properties:
delete myproperties.firstname;
delete myproperties.surname;
delete myproperties.icq;
Were the properties deleted?
trace(myproperties.firstname);
trace(myproperties.surname);
trace(myproperties.icq);
The output window shows:
Guy
Watson
71063418
Un-Protect all properties from deletion:
ASSetPropFlags(myproperties,null,0,1);
Try to delete the properties:
delete myproperties.firstname;
delete myproperties.surname;
delete myproperties.icq;
Were the properties deleted?
trace(myproperties.firstname);
trace(myproperties.surname);
trace(myproperties.icq);
The output window shows:
undefined
undefined
undefined
Re-define the property values so we can use them again in the further examples:
myproperties.firstname="Guy";
myproperties.surname="Watson";
myproperties.icq=71063418;
Protect a property from being over-written:
ASSetPropFlags(myproperties,["firstname"],4,1);
Try to over-write the property:
myproperties.firstname="Richard";
Was the property over-written?
trace(myproperties.firstname);
The output window shows:
Guy
Un-protect a property from being over-written:
ASSetPropFlags(myproperties,["firstname"],0,1);
Try to over-write the property:
myproperties.firstname="Richard";
Was the property over-written?
trace(myproperties.firstname);
The output window shows:
Richard
Re-define the property so that we can use it in further examples:
myproperties.firstname="Guy";
Protect all properties from being over-written:
ASSetPropFlags(myproperties,null,4,1);
Try to over-write all the properties:
myproperties.firstname="Richard";
myproperties.surname="Blackwood";
myproperties.icq=71063418;
Were the properties over-written?
trace(myproperties.firstname);
trace(myproperties.surname);
trace(myproperties.icq);
The output window shows:
Guy
Watson
71063418
Un-protect all properties from being over-written:
ASSetPropFlags(myproperties,null,0,1);
Dont forget that you can assign multiple behaviours at once, by choosing the appropriate argument value for 'n' from the table further up the page, so for example you can protect all the listed properties 'prop' from being over-written and from being deleted in the same function call, you could also do the same for only a selected list of properties by passing an array of the child names for the value 'prop', alternatively you could hide all the properties of an object and un-protect them from being deleted and over-written in the same function call. There are 7 different combinations of behaviours.
Personally, i usually use this undocumented feature to loop through all of the predefined objects to see what i can find lurking in the depths of hidden land, but i also use it to hide properties from for..in loop constructs and therefore also the 'Control>List Variables' output window when testing my scripts. This function comes in very handy when creating your own classes and also when you are defining methods and properties in the _global namespace, using ASSetPropFlags when defining methods and properties in the _global namespace can stop your code from being over-written or deleted.
For more information and examples related to ASSetPropFlags checkout the entry on the Flashcoders Wiki.

