Flash (library & classes)

Categories:Flash

Overview

Summary

Miscellaneous methods and properties that should already be part of Flash (but aren't!)

Contents

Usage

Just use these new properties on native objects as if they were part of the spec.

API

Timeline.selectedLayers

Gets the selected layers of a Timeline

  • Type: String
  • Access: Read

The native function getSelectedLayers() only returns layer indices, which is a bit frustrating when you want to just go ahead and interrogate the layer objects. This JavaScript getter allows you to get the layers in one line of code.

The following example inspect the current timeline's selected layers as native Layer objects:

var layers = $timeline.selectedLayers;
inspect(layers, 2);
Inspect: Array (depth:2, objects:4, values:18, time:0.0 seconds)
--------------------------------------------------------------------------------
array => Array
[0] => Layer
name: "square"
layerType: "normal"
visible: true
locked: false
frameCount: 60
[frames] => Array
color: "#ff4fff"
height: 100
outline: false
parentLayer: null
[1] => Layer
name: "star"
layerType: "normal"
visible: true
locked: false
frameCount: 58
[frames] => Array
color: "#ff800a"
height: 100
outline: false
parentLayer: null

LibraryItem.shortName

The short name of an item

  • Type: String
  • Access: Read

Unfortunately, the Item name property in Flash behaves differently if you are getting or setting it:

  • Getting the name, returns the full path to the item
  • Setting the name sets only the end segment of the path, what we might see as the item name

The new shortName getter lets you get only this end segment of the item's name, and not the full path, in one line of code.

The following example gets both the native name and the xJSFL shortName of the selected item:

var item = $$(':selected').get(0);

trace(item.name);
trace(item.shortName);
3 - compositions/random shapes
random shapes

Comments are closed.