< Day Day Up > |
Availability Flash MX 2004. Description The Layer object represents a layer in the timeline. The timeline.layers property contains an array of Layer objects, which can be accessed by fl.getDocumentDOM().getTimeline().layers. Property summary for the Layer objectThe following properties are available for the Layer object:
layer.colorAvailability Flash MX 2004. Usage layer.color Description Property; the color assigned to outline the layer, in one of the following formats:
This property is equivalent to the Outline color setting in the Layer Properties dialog box. Example The following example stores the value of the first layer in the colorValue variable: var colorValue = fl.getDocumentDOM().getTimeline().layers[0].color; The following example shows three ways to set the color of the first layer to red: fl.getDocumentDOM().getTimeline().layers[0].color=16711680; fl.getDocumentDOM().getTimeline().layers[0].color="#ff0000"; fl.getDocumentDOM().getTimeline().layers[0].color=0xFF0000; layer.frameCountAvailability Flash MX 2004. Usage layer.frameCount Description Read-only property; an integer that specifies the number of frames in the layer. Example The following example stores the number of frames in the first layer in the fcNum variable: var fcNum = fl.getDocumentDOM().getTimeline().layers[0].frameCount; layer.framesAvailability Flash MX 2004. Usage layer.frames Description Read-only property; an array of Frame objects (see Frame object). Example The following example sets the variable frameArray to the array of Frame objects for the frames in the current document: var frameArray = fl.getDocumentDOM().getTimeline().layers[0].frames; To determine if a frame is a keyframe, check whether the frame.startFrame property matches the array index, as shown in the following example: var frameArray = fl.getDocumentDOM().getTimeline().layers[0].frames; var n = frameArray.length; for (i=0; i<n; i++) { if (i==frameArray[i].startFrame) { alert("Keyframe at: " + i); } } layer.heightAvailability Flash MX 2004. Usage layer.height Description Property; an integer that specifies the percentage layer height; equivalent to the Layer height value in the Layer Properties dialog box. Acceptable values represent percentages of the default height: 100, 200, or 300. Example The following example stores the percentage value of the first layer's height setting: var layerHeight = fl.getDocumentDOM().getTimeline().layers[0].height; The following example sets the height of the first layer to 300 percent: fl.getDocumentDOM().getTimeline().layers[0].height = 300; layer.layerTypeAvailability Flash MX 2004. Usage layer.layerType Description Property; a string that specifies the current use of the layer; equivalent to the Type setting in the Layer Properties dialog box. Acceptable values are "normal", "guide", "guided", "mask", "masked", and "folder". Example The following example sets the first layer in the timeline to type "folder": fl.getDocumentDOM().getTimeline().layers[0].layerType = "folder"; layer.lockedAvailability Flash MX 2004. Usage layer.locked Description Property; a Boolean value that specifies the locked status of the layer. If set to TRue, the layer is locked. The default value is false. Example The following example stores the Boolean value for the status of the first layer in the lockStatus variable: var lockStatus = fl.getDocumentDOM().getTimeline().layers[0].locked; The following example sets the status of the first layer to unlocked: fl.getDocumentDOM().getTimeline().layers[0].locked = false; layer.nameAvailability Flash MX 2004. Usage layer.name Description Property; a string that specifies the name of the layer. Example The following example sets the name of the first layer in the current document to "foreground": fl.getDocumentDOM().getTimeline().layers[0].name = "foreground"; layer.outlineAvailability Flash MX 2004. Usage layer.outline Description Property; a Boolean value that specifies the status of outlines for all objects in the layer. If set to true, all objects in the layer appear only with outlines. If false, objects appear as they were created. Example The following example makes all objects on the first layer appear only with outlines: fl.getDocumentDOM().getTimeline().layers[0].outline = true; layer.parentLayerAvailability Flash MX 2004. Usage layer.parentLayer Description Property; a Layer object that represents the layer's containing folder, guiding, or masking layer. Acceptable values for the parent layer are a folder, guide, or mask layer that precedes the layer, or the parentLayer of the preceding or following layer. Setting the layer's parentLayer does not move the layer's position in the list; trying to set a layer's parentLayer to a layer that would require moving it has no effect. Uses null for a top-level layer. Example The following example uses two layers at the same level on the same timeline. The first layer (layers[0]) is converted into a folder and then set as the parent folder of the second layer (layers[1]). This action moves the second layer inside the first layer. var parLayer = fl.getDocumentDOM().getTimeline().layers[0]; parLayer.layerType = "folder"; fl.getDocumentDOM().getTimeline().layers[1].parentLayer = parLayer; layer.visibleAvailability Flash MX 2004. Usage layer.visible Description Property; a Boolean value that specifies whether the layer's objects on the Stage are shown or hidden. If set to TRue, all objects in the layer are visible; if false, they are hidden. The default value is TRue. Example The following example makes all objects in the first layer invisible: fl.getDocumentDOM().getTimeline().layers[0].visible = false; |
< Day Day Up > |