03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

Create two button instances on the Stage called one_btn <strong>and</strong> two_btn. Enter the following<br />

<strong>ActionScript</strong> in Frame 1 of the Timeline:<br />

var one_btn:Button;<br />

var two_btn:Button;<br />

this.createTextField("output_txt", 999, 0, 0, 100, 22);<br />

output_txt.autoSize = true;<br />

one_btn.onRelease = function() {<br />

trace("clicked one_btn");<br />

trace(this._url);<br />

};<br />

two_btn.onRelease = function() {<br />

trace("clicked "+this._name);<br />

var url_array:Array = this._url.split("/");<br />

var my_str:String = String(url_array.pop());<br />

output_txt.text = unescape(my_str);<br />

};<br />

When you click each button, the file name of the SWF containing the buttons displays in the<br />

Output panel.<br />

useH<strong>and</strong>Cursor (Button.useH<strong>and</strong>Cursor property)<br />

public useH<strong>and</strong>Cursor : Boolean<br />

A Boolean value that, when set to true (the default), indicates whether a pointing h<strong>and</strong> (h<strong>and</strong><br />

cursor) displays when the mouse rolls over a button. If this property is set to false, the arrow<br />

pointer is used instead.<br />

You can change the useH<strong>and</strong>Cursor property at any time; the modified button immediately<br />

takes on the new cursor behavior. The useH<strong>and</strong>Cursor property can be read out of a<br />

prototype object.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

Example<br />

Create two buttons on the Stage with the instance names myBtn1_btn <strong>and</strong> myBtn2_btn.<br />

Enter the following <strong>ActionScript</strong> in Frame 1 of the Timeline:<br />

myBtn1_btn.useH<strong>and</strong>Cursor = false;<br />

myBtn1_btn.onRelease = buttonClick;<br />

myBtn2_btn.onRelease = buttonClick;<br />

function buttonClick() {<br />

trace(this._name);<br />

}<br />

When the mouse is over <strong>and</strong> clicks myBtn1_btn, there is no pointing h<strong>and</strong>. However, you see<br />

the pointing h<strong>and</strong> when the button is over <strong>and</strong> clicks myBtn2_btn.<br />

382 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!