隐藏在AS3一个按钮?按钮

由网友(‖独着烟灬想着你°)分享简介:我有一个名为myBtn按钮。在我的第1帧中的动作,我已经试过两个:myBtn.visibility = FALSE;myBtn.enabled = FALSE;这两个给我同样的错误:1120:未定义的属性myBtn的访问解决方案 确定。有几个方法可以做到这一点。第一只涉及使用时间轴。方法1 - 时间线步骤1.转到窗...

我有一个名为myBtn按钮。

在我的第1帧中的动作,我已经试过两个:

  myBtn.visibility = FALSE;

myBtn.enabled = FALSE;
 

这两个给我同样的错误:

  

1120:未定义的属性myBtn的访问

解决方案

确定。有几个方法可以做到这一点。第一只涉及使用时间轴。

方法1 - 时间线

Flash AS3 怎么做返回上一帧的按钮

步骤1.转到窗口选项卡,然后选择组件。将一个按钮实例拖到舞台上。

步骤2.在属性面板中,它说:实例名称,改为myBtn(确保你没有使用引号:P)

步骤3.在时间轴中框输入验证code 1.

  myBtn.visible = FALSE;
 

方法2 - 文档类

步骤在舞台上1.将一个实例的时间轴中

步骤2.创建一个类,让我们把它叫做资源。

第三步:添加

 进口flash.display.SimpleButton;
 

步骤4.创建一个公共静态成员

 公共静态无功BTN_MY_BUTTON:SimpleButton的;
 

步骤5.在您的文档类中添加这对contstructor。

 的addEventListener(Event.ADDED_TO_STAGE,初始化,假,0,真正的);
 

步骤6.添加此功能

 私有函数初始化(五:事件):无效

 Resource.BTN_MY_BUTTON = myBtn;
}
 

步骤7.现在,在任何类,你可以去访问按钮

  Resource.BTN_MY_BUTTON.visible = FALSE;
 

I have a button called myBtn.

In my actions in Frame 1, I have tried both:

myBtn.visibility = false;

myBtn.enabled = false;

Both give me the same error:

1120: Access of undefined property myBtn.

解决方案

ok. There are a couple of ways that you can do this. The first just involves using the timeline.

Method 1 - Timeline

Step 1. Go to Window tab, then select components. Drag a Button instance onto the stage.

Step 2. In the properties panel, where it says 'Instance Name', replace with "myBtn" (make sure you don't use the quotes :P)

Step 3. On the timeline enter this code in frame 1.

myBtn.visible = false;

Method 2 - Document Class

Step 1. Place an instance on the stage as in the timeline

Step 2. Create a class, lets call it Resource.

Step 3. add

import flash.display.SimpleButton; 

Step 4. Create a public static member

public static var BTN_MY_BUTTON:SimpleButton;

Step 5. In your document class add this to the contstructor.

addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);

Step 6. Add this function

private function init(e:Event):void

 Resource.BTN_MY_BUTTON = myBtn;
}

Step 7. Now in any class you can access the button by going

Resource.BTN_MY_BUTTON.visible = false;

阅读全文

相关推荐

最新文章