FUIComponentClass ActionScript Dictionary

FUIComponentClass is the base class of all of the Macromedia components, and you can use it too. But why would you want to? Well, it contains a lot of useful methods and can do a surprising number of things for you automatically. Hopefully this summary will help you get the most out of it.

This is not a dictionary in the same way as the official ActionScript Dictionary is, it is more a general sort of guide as to what you can expect from FUIComponentClass and how to use its features. Not all of the methods and properties listed here are defined by default, and others are defined with minimal functionality. You need to extend these methods, applying them to your own component, to take full advantage of them. Hopefully this is clear from the descriptions of each.

Peter Hall
www.peterjoel.com

last updated: 10/10/2002

This is a non-official document and its accuracy and completeness cannot be guaranteed. Please notify me of any glaring errors at webmaster@peterjoel.co.uk

Thanks to Jesse Warden, here is an MXP version of this document, which will install to your Flash MX reference panel and provide code hints and syntax colouring.

Contents

Method Summary

FUIComponentClass.cleanUINotSize Defines special rules to be applied when "cleaning" a component
FUIComponentClass.drawFocusRect Invoked when the component gains focus, to draw a rectangle
FUIComponentClass.drawRect Draws a rectangle
Method Description
FUIComponentClass.executeCallBack Executes a callback for the component
FUIComponentClass.getEnabled Retrieves the enabled state of the component
FUIComponentClass.init Initialises the component
FUIComponentClass.invalidate "Cleans" the component using the methods passed as an argument.
FUIComponentClass.pressFocus Gives the component keyboard focus
FUIComponentClass.setChangeHandler Sets a function that can be used as a callback
FUIComponentClass.setCustomStyleProperty Defines how a custom style property should be processed
FUIComponentClass.setEnabled Enables or disables the component
FUIComponentClass.setSize Resizes and refreshes the component
FUIComponentClass.setStyleProperty Sets a style property
FUIComponentClass.registerSkinElement Registers a skin element to a style property
FUIComponentClass.updateStyleProperty Callback used by FStyleFormat

| top |

FUIComponentClass.cleanUINotSize

Arguments

methodName String. The name of a method of your component.

Usage

Don't explicitly invoke this function.

Returns

Nothing.

Description

Extend this method to define more complex invalidation priorities. If setSize is invalidated then no other methods will be, but you can insert logic here to say which methods take precedence when setSize is not invalidated. By default, if setSze is not invalidated the all methods in the method table are invalidated and then methodTable is cleared.

| top |

FUIComponentClass.drawFocusRect

Arguments

None.

Usage

Don't explicitly invoke this function.

Returns

Nothing.

Description

This is a kind of callback, which is invoked when the component is tabbed onto. By default it uses the method drawRect to draw a rectangle, but you can override it with your own method to show visually that the component has tab-focus. Note, your method should involve creating a movieClip called focusRect, so that it will be automatically removed when the component loses tab-focus.

| top |

FUIComponentClass.drawRect

Arguments

xPos Number. The x-coordinate of the top left of the rectangle.
yPos Number. The y-coordinate of the top left of the rectangle.
width Number. The width of the rectangle to draw.
height Number. The height of the rectangle to draw.

Usage

myComponent.drawRect(xPos, yPos, width, height);

Returns

Nothing.

Description

This is the default focus rectangle that is drawn when you tab onto a component.

| top |

FUIComponentClass.executeCallBack

Arguments

None.

Usage

myComponent.executeCallback();

Returns

Nothing.

Description

Invoke this method to send a message to say that something has changed. It will call the function specified by setChangeHandler, passing a reference to the component (this) as an argument. Override this method if you want to pass more arguments.

| top |

FUIComponentClass.getEnabled

Arguments

none

Usage

myComponent.getEnabled();

Returns

Boolean. true if the component is enabled, otherwise false.

Description

Does what it sounds like!

| top |

FUIComponentClass.init

Arguments

none

Usage

MyComponentClass.init();

Returns

Nothing

Description

This method sets up the component so that everything else can work. You should always invoke this method from your constructor. You should also extend it, but make sure to call super.init() first thing.

| top |

FUIComponentClass.invalidate

Arguments

methodName String. The name of a method of your component.

Usage

myComponent.invalidate(methodName);

Returns

Nothing.

Description

This method is used to efficiently update the visual aspects of your component. It accepts a method name as an argument and adds it to an object called methodtable. Each method in the table will be invoked once after one frame has elapsed. That means that you can invalidate a function several times, but it will only be invoked once. The exception is setSize, which takes precedence. That means that if you invalidate setSize no other methods will be invalidated, since setSize refreshes the whole component.

The main use of this function is to be invoked from setCustomStyleProperty to update the component, after setting custom style properties. Pass it the name of a method that will apply the style property to the component. It mostly works out that you pass setSize as the argument.

Also, in data-aware components, which make use of DataProviderClass, it is likely that you will use invalidate to refresh the component in the modelChanged callback.

| top |

FUIComponentClass.pressFocus

Arguments

None.

Usage

myComponent.pressFocus();

Returns

Nothing.

Description

A simple but useful method which gives your component keyboard focus. Invoke it in an onPress handler or when the user clicks on your component. FUIComponentClass's focus control should take care of taking keyboard focus away. Note: clicking on empty space won't take focus away from your component; the user needs to click on a focusable object to do that. To make use of the keyboard focus, you should define callbacks called myOnKeyDown and myOnKeyUp. These odd names are to distinguish them from the the built-in MovieClip events so that they are only invoked when the component is focused

| top |

FUIComponentClass.registerSkinElement

Arguments

skinMC MovieClip reference. The movieClip to register to the style property.
propName String. The name of a style property.

Usage

myComponent.registerSkinElement(skinMC, propName);

Returns

Nothing.

Description

You don't need to do anything with this. Just use it to register skin elements from inside skins for your component. It adds the property to the styleTable and stores a reference to the movieClip. It also applies the style if it has been given a value already.

| top |

FUIComponentClass.setChangeHandler

Arguments

callBackFunc String. The name of a function to be used as a callback.
callbackObj Optional. Reference to the container of the callback function Default is theComponent._parent

Usage

myComponent.setChangeHandler(callbackFunc [, callbackObj]);

Returns

Nothing.

Description

You must have used this method before. It just lets the user specify a change handler so that your component knows where to make its callbacks to, when it changes.

| top |

FUIComponentClass.setCustomStyleProperty

Arguments

propName String. The name of a style property.
value The value to set the style property to.
isGlobal Optional Boolean. Determines if the property should be treated as a global property.

Usage

Don't explicitly invoke this method.

Returns

Boolean. true if the property name passed as an argument is a custom style. Otherwise false.

Description

This function will be invoked by setStyleProperty before it makes any style changes. It isn't defined at all by default, so you can define it and intercept any style changes to the component and do what you like with them. You can also define your own style properties, that can do more than simply change colours and text properties.

When this function is invoked, it is passed the property name and its new value, but these are already stored in the styleTable by setStyleProperty. You should return true if you want to intercept the property and false if you want the default behaviour to happen.

| top |

FUIComponentClass.setEnabled

Arguments

enable Boolean. Determines if the component should be enabled or not.

Usage

myComponent.setEnabled(enable);

Returns

Nothing

Description

Disables the component and performs makes sure that the component hasn't got focus. You need to extend this method to affect your component's graphics, as well as to prevent any user interaction not defined in FUIComponentClass.

| top |

FUIComponentClass.setSize

Arguments

width The new width for the component
height The new height for the component

Usage

myComponent.setSize(width, height);

Returns

Nothing.

Description

SetSize is the hub of your component. Invoking setSize should update and refresh everything. Extend this method so that it totally refreshes the graphical elements of your component.

Components use internal properties width and height to track the size. These values are set automatically by the default method and may not be exactly equal to the _width and _height properties for the component. In general, you should restrict yourself to allow only setSize to change the values of width and height, and no other methods.

| top |

FUIComponentClass.setStyleProperty

Arguments

propName String. The name of a style property.
value The value to set the style property to.
isGlobal Optional Boolean. Determines if the property should be treated as a global property.

Usage

myComponent.setStyleProperty(propName, value [, isGlobal]);

Returns

Nothing.

Description

Sets a style property and invalidates as necessary. This method manages text styles for any instances of FLabel used by the component and also the colouring of skin elements, registered to the component with registerSkinElement. It stores the property and value in an object called styleTable, along with any movieClips registered to it with registerSkinElement. It also makes sure that properties of globalStyleFormat have no effect on the component if that same style property has already been set from a non-global FStyleFormat.

| top |

FUIComponentClass.updateStyleProperty

Arguments

styleFormat FStyleFormat instance
propName String. The name of a style property

Usage

Don't explicitly call this method.

Returns

Nothing.

Description

This is a callback, used by FStyleFormat objects. You shouldn't need to do anything with this.

| top |

 

Event Summary

FUIComponentClass.myOnKeyDown Triggered when a key is pressed
FUIComponentClass.myOnKeyUp Triggered when a key is released
Event Description
FUIComponentClass.myOnKillFocus Triggered when the component loses focus
FUIComponentClass.myOnSetFocus Triggered when the component gains focus

| top |

FUIComponentClass.myOnKeyDown

Arguments

None.

Usage

Don't explicitly call this method.

Returns

Nothing.

Description

This event occurs when any key is pressed, but only if the component has keyboard focus. A component has keyboard focus after a call to pressFocus until the next myOnKillFocus event. myOnKeyDown is undefined by default.

| top |

FUIComponentClass.myOnKeyUp

Arguments

None.

Usage

Don't explicitly call this method.

Returns

Nothing.

Description

This event occurs when any key is pressed, but only if the component has keyboard focus. A component has keyboard focus after a call to pressFocus until the next myOnKillFocus event. myOnKeyUp is undefined by default.

| top |

FUIComponentClass.myOnKillFocus

Arguments

None.

Usage

Don't explicitly call this method.

Returns

Nothing.

Description

This event has a default value, which handles focus control and subscribing to the Key object to listen for Key events. If you extend myOnKillFocus, make sure to make a call to the super method. The default methods handle drawing the focus rectangle and subscribing to the Key object to listen for Key events.

| top |

FUIComponentClass.myOnSetFocus

Arguments

None.

Usage

Don't explicitly call this method.

Returns

Nothing.

Description

This event has a default value, which handles focus control and subscribing to the Key object to listen for Key events. If you extend myOnSetFocus, make sure to make a call to the super method.

| top |

 

Internal Property Summary

FUIComponentClass._accImpl Object. Holder for accessibility purposes.
Property Description
FUIComponentClass.controller A reference to a top-level component in a hierachy.
FUIComponentClass.enable Boolean. Determines if the component is enabled
FUIComponentClass.focused Boolean. Determines if the component has keyboard focus
FUIComponentClass.height Number. The internal height value for the component.
FUIComponentClass.hostComponent A reference to a host component
FUIComponentClass.hostStyle Object. Reference to a host component's styleTable
FUIComponentClass.methodTable Object. Stores method names for invalidation purposes.
FUIComponentClass.styleTable Object. Stores style information.
FUIComponentClass.tabFocused Boolean. Determines if the component has been tabbed into
FUIComponentClass.width Number. The internal width value for the component.

| top |

FUIComponentClass._accImpl

Description

This object is used for storing accessibility properties and broadcasting accessibility events. By default it is empty except for a property called stub, which is there to say that it is empty.

For a good example of how to implement accessibility in components, look at the source for FPushButtonClass.

| top |

FUIComponentClass.controller

Description

A reference to a parent component if the component is used as an asset of another component.

see hostComponent

| top |

FUIComponentClass.enable

Description

Boolean. This is an internal property that should not be confused with MovieClip.enabled. It is used to determine if the component is enabled.

| top |

FUIComponentClass.focused

Description

Boolean. Determines if the component has keyboard focus.

| top |

FUIComponentClass.height

Description

Internal property to store the height of the component. This property should be set only by setSize, but may be retrieved by any method. This property does not have to be equal to _height.

| top |

FUIComponentClass.hostComponent

Description

A reference to a parent component if the component is used as an asset of another component. The usage of hostComponent is slightly different to that of controller, which is normally set by the host component itself, but they are often the same thing.

see controller

| top |

FUIComponentClass.hostStyle

Description

This object is not created by default. When another component uses attachMovie to place an instance of this component inside itself, it may pass this property in the initialisation object. The value is a reference to the host component's styleTable and allows nested components to receive style information from a parent.

| top |

FUIComponentClass.methodTable

Description

This object temporarily stores the names of methods of the component when cleaning the component with invalidate. You should only access it from within the method cleanUINotSize. The property keys are the names of all the methods that were invalidated in the last frame, and the values are always true.

| top |

FUIComponentClass.styleTable

Description

This object stores style information set by setStyleProperty or by a FStyleFormat that the component is listening to. Its keys are the property names, which are objects with the following properties:

value The current value of that style property.
coloredMCs An object containing references to all movieClip registered to this property as skin elements
useGlobal Boolean. true if no value has been specified except globally

| top |

FUIComponentClass.tabFocused

Description

Boolean. Determines if the component has focus and that the focus was gained by the user pressing the TAB key.

| top |

FUIComponentClass.width

Description

Internal property to store the width of the component. This property should be treated as read-only by all methods except setSize. This property does not have to be equal to _width.

| top |