Strona 1 z 1

[mx 2004]Jak utworzyć custom style declaration

: pt maja 27, 2005 1:24 pm
autor: rabit
Witam!
Czy ktoś może wie jak tworzy się deklaracje custom style. Chciałbym zmienić tło dla textarea a ten komponent ma taką deklarację dla kilku właściwości więc globals nie działają . Proszę o pomoc.

Re: [mx 2004]Jak utworzyć custom style declaration

: sob maja 28, 2005 3:21 pm
autor: Marek_bf
Czy to jest Flash MX 2004 i czy chodzi o to:

Kod: Zaznacz cały

instance_name.setStyle("backgroundColor", 0xff0000);

Re: [mx 2004]Jak utworzyć custom style declaration

: sob maja 28, 2005 11:58 pm
autor: rabit
Nie całkiem o to, przed chwilą właśnie znalazłem w helpie, a miałem to pod nosem, trochę się wkurzyłem, że tego wcześniej nie zauważyłem będąc obok , więc do rzecz wygląda to tak:

To create a custom style declaration for specific components:
1.Make sure the document contains at least one component instance.
For more information, see Adding components to Flash documents.

This example uses three button components with the instance names a, b, and c. If you use different components, give them instance names in the Property inspector and use those instance names in step 9.

2.Create a new layer in the Timeline and give it a name.
3.Select a frame in the new layer on which (or before) the component appears.
4.Open the Actions panel in expert mode.
5.Use the following syntax to create an instance of the CSSStyleDeclaration object to define the new custom style format:
var styleObj = new mx.styles.CSSStyleDeclaration;

6.Set the styleName property of the style declaration to name the style:
styleObj.styleName = "newStyle";

7.Place the style on the global style list:
_global.styles.newStyle = styleObj;

Note: You can also create a CSSStyleDeclaration object and assign it to a new style declaration by using the following syntax:

var styleObj = _global.styles.newStyle = new mx.styles.CSSStyleDeclaration();

8.Use the following syntax to specify the properties you want to define for the myStyle style declaration:
styleObj.fontFamily = "_sans";
styleObj.fontSize = 14;
styleObj.fontWeight = "bold";
styleObj.textDecoration = "underline";
styleObj.color = 0x336699;
styleObj.setStyle("themeColor", "haloBlue");

9.In the same Script pane, use the following syntax to set the styleName property of two specific components to the custom style declaration:
a.setStyle("styleName", "newStyle");
b.setStyle("styleName", "newStyle");

You can also access styles on a custom style declaration using the setStyle() and getStyle() methods. The following code sets the backgroundColor style on the newStyle style declaration:

_global.styles.newStyle.setStyle("backgroundColor", "0xFFCCFF");