Skip to main content

Using regular expressions to address multiple elements

Regular expressions let you address multiple elements within the Skin Editor with just one action. This will save time when setting up thumbnails or any other multiple element project.


Download the Skin

Download Video

Regular Expressions in Action[edit]

Try this out for yourself. You'll be adding the regular expressions to the Target fields. What will happen is that no matter which rectangle the mouse enters, the other three will fade to alpha 0.5

Open the Skin Editor and do the following:

  1. Add four rectangles to the skin. Name them 1, 2, 3, and 4. Set the Alpha of each to 0.5.
  2. Add the following actions to Rectangle 1:
    Mouse Enter, Change Element Alpha, Alpha: 1, Target: $self
    Mouse Enter, Change Element Alpha, Alpha: .5, Target: #Rectangle [2-4]
  3. Add the following actions to Rectangle 2:
    Mouse Enter, Change Element Alpha, Alpha: 1, Target: $self
    Mouse Enter, Change Element Alpha, Alpha: .5, Target: #Rectangle [13-4]
  4. Add the following actions to Rectangle 3:
    Mouse Enter, Change Element Alpha, Alpha: 1, Target: $self
    Mouse Enter, Change Element Alpha, Alpha: .5, Target: #Rectangle [1-24]
  5. Add the following actions to Rectangle 4:
    Mouse Enter, Change Element Alpha, Alpha: 1, Target: $self
    Mouse Enter, Change Element Alpha, Alpha: .5, Target: #Rectangle [1-3]


Characters in Regular Expressions[edit]

The following characters can be used to modify the number range that needs to be addressed; so leaving out certain numbers while including others.

1-3 means elements from range 1 to 3 are included. 13-4 means elements 1 and 3 to 4. 2 is not included.

#Rectangle [134] will address Rectangles 1, 3, and 4.
◊ NOTE: The Target ID must be preceded with the pound/hash character (#).


Use the pipe character (|) to separate element IDs. For example, to set two different elements to be visible:

Mouse Click > Show Element > Target: #Rectangle [134]|Button 2
Mouse Click > Show Element > Target: #Rectangle [134]|Button [2-8]


Using the Wild Card[edit]

The asterisk (*) can be used to address all within a range:

Mouse Click > Hide Element > Target: #Rectangle .* This will hide all rectangles in the skin.


Using more then one character to address many elements[edit]

So far the tip has looked at using a single character (numbers 1 to 9 or letters a to z).

If many elements in the skin need to be addressed, then the pipe (|) can be used as an OR. This also requires the variables to be encased in round brackets, ( ).

To address rectangles 00 to 19:

Mouse Click > Show Element > Target: #Rectangle (0[0-9]|1[0-9])


To address 00 to 29 add another OR block:

Mouse Click > Show Element > Target: #Rectangle (0[0-9]|1[0-9]|2[0-9])


To exclude rectangle 15, but address the rest:

Mouse Click > Show Element > Target: #Rectangle (0[0-9]|1[0-4/6-9])


Of course using letters will let you address more elements. aa to zz will give you 52 elements that can be addressed.

Example of the naming convention in the Skin:

Example of addressing all elements except for Rectangle bc.

Mouse Click > Show Element > Target: #Rectangle (a[a-z]|b[abd-z])


To increase the amount of elements that can be addressed add another OR block. This can address 78 skin elements in a single action, aa to cz:

Mouse Click > Show Element > Target: #Rectangle (a[a-z]|b[a-z]|c[a-z])


See also[edit]

Wikipedia:Regular expression</br> Using regular expressions in Actionscript 3