• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Button error, 1061 error,

New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

I am new to ActionScript 3. I created a simple button that I imported into the stage and I named  and saved it as Microwave_btn
and I wrote a simple script for it that says:

stop ();

import flash.display.*;
import flash.events.*;

Microwave_btn.addEventListener(MouseEvent.CLICK, Trace);
function Trace (event:MouseEvent): void {
trace("Microwave!");
}

The properties for the Microwave_btn has the
class labeled as: Microwave_btn
and the
Base class as: flash.display.SimpleButton

When I test the movie I get this error:
1061: Call to a possibly undefined method addEventListener through a reference with static type Class.

TOPICS
ActionScript

Views

4.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 11, 2010 Oct 11, 2010

i assume this thread is closed and i see your other thread has a responder.  good luck!

Votes

Translate

Translate
Community Expert ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

try:



import flash.display.*;
import flash.events.*;

var btn:Microwave_btn=new Microwave_btn();

addChild(btn);

btn.addEventListener(MouseEvent.CLICK, Trace);
function Trace (event:MouseEvent): void {
trace("Microwave!");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

Thank you so much. What I don't  understand is that I have two buttons on my screen now and the button  that works is located on the top left corner of my screen. My original  button which is located on top of the background image (microwave) does  not invoke the Microwave Trace function.

How do I get that  to work and remove the Microwave_btn image from the top left corner of  my screen and get original button to work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

the code i suggested created that top-left button.  if you want to use the one on-stage, click it (to select it) and in the properties panel assign an instance name (eg, btn).   you can then use:

btn.addEventListener(MouseEvent.CLICK, Trace);


function Trace (event:MouseEvent): void {
trace("Microwave!");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

I have only one button on the stage which is the Micowave_btn. I also named the instance name for the button Microwave_btn.

When I try compiling the movie I get a new error message that says:

1046: Type was not found or was not a compile-time constant: Microwave_btn.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

a class name can't be the same as an instance name.  fix that and use the above code i suggested.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

Ok!  I reposted my question with screen shots at

http://forums.adobe.com/message/3200329#3200329

I changed the Microwave_btn instance name to microwave_mc and I still get two images of the Microwave_btn on the stage and the one at the top left corner works.

I would like tpl create 5 buttons total:

Dishwash_btn        dishwash_mc (instance name)

Faucet_btn             faucet_mc (instance name)

Microwave_btn       microwave_mc (instance name)

Refrig_btn              refrigwash_mc (instance name)

Stove_btn               stove_mc (instance name)

If you read my reposted question you should be able to have a better understand of what I want to accomplish.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

i assume this thread is closed and i see your other thread has a responder.  good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

LATEST

Thanks for your assistance. I was able to figure most of it out.

Date: Mon, 11 Oct 2010 19:13:19 -0600

From: forums@adobe.com

To: edaddy@hotmail.com

Subject: Button error, 1061 error,

i assume this thread is closed and i see your other thread has a responder. good luck!

>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2010 Oct 11, 2010

Copy link to clipboard

Copied

Thank you so much. What I don't

understand is that I have two buttons on my screen now and the button

that works is located on the top left corner of my screen. My original

button which is located on top of the background image (microwave) does

not invoke the Microwave Trace function. How do I get that to work and remove the Microwave_btn image from the top left corner of my screen and get original button to work?

Date: Mon, 11 Oct 2010 11:52:31 -0600

From: forums@adobe.com

To: edaddy@hotmail.com

Subject: Button error, 1061 error,

try:

import flash.display.*;

import flash.events.*;

var btn:Microwave_btn=new Microwave_btn();

addChild(btn);

btn.addEventListener(MouseEvent.CLICK, Trace);

function Trace (event:MouseEvent): void {

trace("Microwave!");

}

>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines