Flash CS3 Documentation |
|||
| Using ActionScript 2.0 Components > Customizing Components > About skinning components > Applying new skins to a subcomponent | |||
In certain situations you may want to modify the skins of a subcomponent in a component, but the skin properties are not directly available (for example, there is no direct way to alter the skins of the scroll bar in a List component). The following code lets you access the scroll bar skins. All the scroll bars that are created after this code runs will also have the new skins.
If a component is composed of subcomponents, the subcomponents are identified in the component's entry in the ActionScript 2.0 Components Language Reference.
This adds the component to the Library panel, but doesn't make the component visible in the document.
This adds the symbol to the Library panel, but doesn't make it visible in the document.
import mx.controls.List; import mx.controls.scrollClasses.ScrollBar;
ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown";
You can then enter the following code on Frame 1 to create a list dynamically:
createClassObject(List, "myListBox", 0, {dataProvider: ["AL","AR","AZ", "CA","HI","ID", "KA","LA","MA"]});
Or, you can drag a List component from the library to the Stage.
import mx.controls.List
import mx.controls.scrollClasses.ScrollBar
var oldName = ScrollBar.prototype.downArrowDownName;
ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown";
createClassObject(List, "myList1", 0, {dataProvider: ["AL","AR","AZ", "CA","HI","ID", "KA","LA","MA"]});
myList1.redraw(true);
ScrollBar.prototype.downArrowDownName = oldName;
|
NOTE |
|
Set enough data so that the scroll bars appear, or set the |
You can also set subcomponent skins for all components in a document by setting the skin property on the subcomponent's prototype object in the #initclip section of a skin symbol.
This adds the symbol to the library without making it visible on the Stage.
Export in First Frame should be automatically selected; if it is not, select it.
#initclip 10
import mx.controls.scrollClasses.ScrollBar;
ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown";
#endinitclip
createClassObject(mx.controls.List, "myListBox1", 0, {dataProvider: ["AL","AR","AZ", "CA","HI","ID", "KA","LA","MA"]});
|
NOTE |
|
Add enough data so that the vertical scroll bar appears, or set |
The following example explains how to skin something that's already on the Stage. This example skins only List scroll bars; any TextArea or ScrollPane scroll bars would not be skinned.
Export in First Frame should be automatically selected; if it is not, select it.
MyVScrollBar symbol:
#initclip 10
import MyVScrollBar
Object.registerClass("VScrollBar", MyVScrollBar);
#endinitclip
import mx.controls.VScrollBar
import mx.controls.List
class MyVScrollBar extends VScrollBar{
function init():Void{
if (_parent instanceof List){
downArrowDownName = "MyScrollDownArrowDown";
}
super.init();
}
}
Flash CS3