0

我想制作一个外部 ActionScript 3,当MOUSE_UP文本将更改以及何时MOUSE_DOWN不显示文本。

这是我制作的代码:

this.parent.getChildByName("planet_name").text = "EARTH";

我刚刚制作了这段代码以显示要点。=P

4

3 回答 3

0

因此,外部是指调用代码的显示对象(电影剪辑、精灵等)的父级吗?

假设 MOUSE_UP 和 MOUSE_DOWN 位于您编写代码的 displayObject 上,您可以执行以下操作:

this.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
this.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);

function handleMouseDown(event : MouseEvent) : void {
   this.parent.textFieldName.visible = false;
}

function handleMouseUp(event : MouseEvent) : void {
   this.parent.textFieldName.visible = true;
}
于 2012-08-06T15:13:56.003 回答
0

首先,您将其添加到您的文档类(主类)中:

public static var me:DocumentClassName;

这在您的文档类构造函数中:

me = this;

在外部 AS3 文件中只需添加 2 个事件监听器:

this.addEventListener(MouseEvent.MOUSE_UP, mouseup);
this.addEventListener(MouseEvent.MOUSE_DOWN, mousedown);

function mouseup(e:MouseEvent):void 
{
   DocumentClassName.me.textFieldName.text = "EARTH";
}

function mousedown(e:MouseEvent):void 
{
   DocumentClassName.me.textFieldName.text = " ";
}

用您的文档类名称更改 DocumentClassName。它通常是主要的。还将 textFieldName 更改为对象的实例名称。

于 2012-08-06T15:29:24.310 回答
0

Please check first. this.parent.getChildByName("plant_name") is Whether DynamicText or not

If not, you must change instance of DynamicText.

what is "plant_name" instance ? if is instance of MovieClip, you change DynamicText.

How to changed?

  1. MovieClip click
  2. ctrl+b
  3. property change to DynamicText

I will omit a more detailed description. the source code, refer to the following link. As you will see the source code, There are a DragAndDrop Class . this Class The role of this class of objects on the stage all the initialization and is responsible for managing.

DragAndDrop_Modification

Oh, and by the Class name must be start a capital letter. This is customary promise among the developers.

goodLuck

于 2012-08-06T16:06:20.673 回答