![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
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 allows you to 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 Components Dictionary.
This adds the component to the Library panel, but doesn't make the component visible in the document.
This adds the component to the Library panel, but doesn't make the component visible in the document.
import mx.controls.List import mx.controls.scrollClasses.ScrollBar ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown";
You can then either 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: You must set enough data to have the scroll bars show up, or set the vScrollPolicy
property to true
.
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. For more information about the prototype object, see Function.prototype
in ActionScript Dictionary Help.
This adds the symbol to the library without making it visible on the Stage.
Export in First Frame is automatically selected.
#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 vScrollPolicy
to true
.
The following example explains how to skin something that's already on the stage. This example skins only Lists; any TextArea or ScrollPane scroll bars would not be skinned.
Export in First Frame is automatically selected.
#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(); } }
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |