Element selection and manipulation

Categories:Working with Flash
This page is a work in progress due to an unfinished API

Overview

Please note that "Stage selection" in the context of this page encompasses all elements that relate to the Flash stage, including:

  • Layers
  • Frames
  • Elements

Stage selection

This section is not yet complete due to the stage selection functions not being ready. When it is, you'll be able to select items on stage with expressions like the following:

$layers(':empty');
$frames(':animated');
$(':movieclip');

In the meantime, you can make selections using vanilla JSFL methods, as well as the Context class below.

Collections

Each of the selection functions above will return the appropriate Collection type:

Currently the ElementCollection type is finished, allowing you to manipulate collections of elements on the Flash stage.

As discussed in the Introduction to Collections, Collections allow you to manipulate multiple items using an object-oriented API, performing operations on the encapsulated elements as a group. ElementCollection currently has 14 methods available to call, including attr(), orderBy(), toGrid(), and randomize().

Right now, and until the stage selection functions are ready, you will need to create an ElementCollection manually:

var collection = new ElementCollection(dom.selection);

Once created, the elements within the collection can be manipulated using the Collection's methods:

collection
    .rename('Item ###')
    .toGrid(20, 20)
    .randomize({width:10, height:10})
    .select();

Please note that Collections and selection methods are currently still a work in progress, but the public API shouldn't change too much between now and the Beta release.

Next Steps

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>