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.

The MovieClip.getNextHighestDepth() method used in this example requires Flash Player<br />

7 or later. If your SWF file includes a version 2 component, use the version 2 components'<br />

DepthManager class instead of the MovieClip.getNextHighestDepth() method.<br />

menu (TextField.menu property)<br />

public menu : ContextMenu<br />

Associates the ContextMenu object contextMenu with the text field my_txt. The<br />

ContextMenu class lets you modify the context menu that appears when the user right-clicks<br />

(Windows) or Control-clicks (Macintosh) in Flash Player.<br />

This property works only with selectable (editable) text fields; it has no effect on nonselectable<br />

text fields.<br />

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

Example<br />

The following example assigns the ContextMenu object menu_cm to the text field news_txt.<br />

The ContextMenu object contains a custom menu item labeled "Resize" with an associated<br />

callback h<strong>and</strong>ler named doResize(), which could be used to add resizing functionality (not<br />

shown):<br />

this.createTextField("news_txt", this.getNextHighestDepth(), 10, 10, 320,<br />

240);<br />

news_txt.border = true;<br />

news_txt.wordWrap = true;<br />

news_txt.multiline = true;<br />

news_txt.text = "To see the custom context menu item, right click (PC) or ";<br />

news_txt.text += "control click (Mac) within the text field.";<br />

var menu_cm:ContextMenu = new ContextMenu();<br />

menu_cm.customItems.push(new ContextMenuItem("Resize", doResize));<br />

function doResize(obj:TextField, item:ContextMenuItem):Void {<br />

// "Resize" code here<br />

trace("you selected: "+item.caption);<br />

}<br />

news_txt.menu = menu_cm;<br />

When you right-click or Control-click within the area of the text field, you see the custom<br />

menu item.<br />

Note: You cannot use a menu item that is already used by Flash. For example, Print... (with<br />

three dots) is reserved by Flash, so you cannot use this menu item; however, you could use<br />

Print.. (with two dots) or any menu item not already used by Flash.<br />

1210 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!