Chimp is permission based filtering component for Adobe Flex and AIR. Applications implement Chimp by adding metadata within the Flex UIComponents. Based on the metadata it will remove components completely, enable/disable, and update visibility.
Quick Setup:
1) Download and add the chimp.swc to your project library
2) Add compiler argument to keep necessary metadata:
-locale en_US -keep-as3-metadata+=Protected
3) Load the Chimp in your application. The Chimp must be loaded but before children are added because they are tracked with an event listener on the add to stage system event:
Chimp.load(perms);
4) Add metadata to your Flex components:
[Protected(permissions="ROLE_ADMIN",notInPermissionAction="removeChild",componentId="this")] [Protected(permissions="ROLE_UPDATE",inPermissionAction="enable",componentId="updateButton")]
[Protected] Metadata properties:
- permissions: A comma delimited string of the permissions to use for the protected operation.
- componentId: This is the string name of the component that is to be protected. This can be omitted or set to ‘this’ for current component. To protect a child, set the componentId to the ‘id’ string of the component.
- notInPermissionAction: If the user does not have any of the permissions, then the action provided is performed (use only this or inPermissionAction – not both).
- inPermissionAction: If the user has any of the permissions, then the action provided is performed (use only this or notInPermissionAction – not both).
Possible actions:- removeChild: Removes the component completely, by calling ‘comp.parent.removeChild()”
- removeFromLayout: Use the includeInLayout property to remove components
- invisible: Sets the comp.visible property to false
- visable: Sets the comp.visible property to true
- disable: Sets the comp.enable property to false
- enable: Sets the comp.enable property to true