View comments | RSS feed

Button


Object
    |
    +-Button

public class Button
extends Object

All button symbols in a SWF file are instances of the Button object. You can give a button an instance name in the Property inspector, and use the methods and properties of the Button class to manipulate buttons with ActionScript. Button instance names are displayed in the Movie Explorer and in the Insert Target Path dialog box in the Actions panel.

The Button class inherits from the Object class.

Availability: ActionScript 1.0; Flash Player 6

See also

Object

Property summary

Modifiers

Property

Description

 

_alpha:Number

The alpha transparency value of the button specified by my_btn.

 

blendMode:Object

The blend mode for the button.

 

cacheAsBitmap:Boolean

If set to true, Flash Player caches an internal bitmap representation of the button.

 

enabled:Boolean

A Boolean value that specifies whether a button is enabled.

 

filters:Array

An indexed array containing each filter object currently associated with the button.

 

_focusrect:Boolean

A Boolean value that specifies whether a button has a yellow rectangle around it when it has keyboard focus.

 

_height:Number

The height of the button, in pixels.

 

_highquality:Number

Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality.

Specifies the level of anti-aliasing applied to the current SWF file.

 

menu:ContextMenu

Associates the ContextMenu object contextMenu with the button object my_button.

 

_name:String

Instance name of the button specified by my_btn.

 

_parent:MovieClip

A reference to the movie clip or object that contains the current movie clip or object.

 

_quality:String

Property (global); sets or retrieves the rendering quality used for a SWF file.

 

_rotation:Number

The rotation of the button, in degrees, from its original orientation.

 

scale9Grid:Rectangle

The rectangular region that defines the nine scaling regions for the button.

 

_soundbuftime:Number

The property that specifies the number of seconds a sound prebuffers before it starts to stream.

 

tabEnabled:Boolean

Specifies whether my_btn is included in automatic tab ordering.

 

tabIndex:Number

Lets you customize the tab ordering of objects in a SWF file.

 

_target:String [read-only]

Returns the target path of the button instance specified by my_btn.

 

trackAsMenu:Boolean

A Boolean value that indicates whether other buttons or movie clips can receive mouse release events.

 

_url:String [read-only]

Retrieves the URL of the SWF file that created the button.

 

useHandCursor:Boolean

A Boolean value that, when set to true (the default), indicates whether a pointing hand (hand cursor) displays when the mouse rolls over a button.

 

_visible:Boolean

A Boolean value that indicates whether the button specified by my_btn is visible.

 

_width:Number

The width of the button, in pixels.

 

_x:Number

An integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip.

 

_xmouse:Number [read-only]

Returns the x coordinate of the mouse position relative to the button.

 

_xscale:Number

The horizontal scale of the button as applied from the registration point of the button, expressed as a percentage.

 

_y:Number

The y coordinate of the button relative to the local coordinates of the parent movie clip.

 

_ymouse:Number [read-only]

Indicates the y coordinate of the mouse position relative to the button.

 

_yscale:Number

The vertical scale of the button as applied from the registration point of the button, expressed as a percentage.

Properties inherited from class Object

constructor, __proto__, prototype, __resolve


Event summary

Event

Description

onDragOut = function() {}

Invoked when the mouse button is clicked over the button and the pointer then dragged outside of the button.

onDragOver = function() {}

Invoked when the user presses and drags the mouse button outside and then over the button.

onKeyDown = function() {}

Invoked when a button has keyboard focus and a key is pressed.

onKeyUp = function() {}

Invoked when a button has input focus and a key is released.

onKillFocus = function(newFocus:Object) {}

Invoked when a button loses keyboard focus.

onPress = function() {}

Invoked when a button is pressed.

onRelease = function() {}

Invoked when a button is released.

onReleaseOutside = function() {}

Invoked when the mouse is released while the pointer is outside the button after the button is pressed while the pointer is inside the button.

onRollOut = function() {}

Invoked when the pointer moves outside a button area.

onRollOver = function() {}

Invoked when the pointer moves over a button area.

onSetFocus = function(oldFocus:Object) {}

Invoked when a button receives keyboard focus.

Method summary

Modifiers

Signature

Description

 

getDepth() : Number

Returns the depth of the button instance.

Methods inherited from class Object

addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch



Version 8

Comments


2m said on Oct 24, 2005 at 12:12 AM :
It should be stated, that there is an important difference in the scope a script (attached to a) button is executed:

In a setup, where you have a button with the instance name “myButton_btn” on the main timeline (_level0 aka _root):

If you place the following script on your button. (With the button selected – in the actions panel)

on (release){
trace(this);
}

It will trace “_level0” – the scope of the script is that of the timeline/MovieClip, the button sits on.

But if you place the comparable script on the timeline (In the actions panel with the frame selected):

myButton_btn.onRelease = function() {
trace(this);
};

It will trace “_level0.myButton_btn” – With this script you’d have to address objects on the same timeline as the button with “this._parent. …”.

(This may be widely known by Flash veterans, but newcomers might have problems understanding this difference, and there are a lot of Flash 5 style tutorials and examples out in the web.)
No screen name said on Nov 24, 2005 at 1:54 AM :
my_button.blendMode = 8;
trace (my_button.blendMode) // add
zuumm said on Dec 20, 2005 at 3:52 PM :
There is a new option, in the Script Assit mode, for mouse events for buttons: "Component:".
I haven't found any reference to this in the Help files, not even in the live docs.
What is its purpose and how to use it?
Thanks.
Marcos.
No screen name said on May 1, 2006 at 3:51 PM :
Useful to note that when working with HotSpots (Invisible buttons - where content is placed ONLY in the Hit frame), the _width attribute will always return 0. If you attempt to dynamically adjust this attribute you will lose the button.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001984.html