0

Noobie flash programmer here. I am trying to get the flash movie to play an imported punch sound after the user clicks a button. I got this error: "1046: Type was not found or was not a compile-time constant: punch."

here is the code:

stop();


var punch:punch = new punch();

btn2.addEventListener(MouseEvent.CLICK, playSound2);


function playSound2(e:MouseEvent):void
{
    punch.play();
}

changing "var punch:punch = new punch();" to "var punchSound:punch = new punch();" solved my problem but I was wondering why "var punch:punch = new punch();" didn't work?

Thanks in advance

user701510
  • 5,563
  • 17
  • 61
  • 86

1 Answers1

2

you need to import the punch class
and the reason why var punch:punch did not work is because you can not have a var and a class named the same.
by standards the first letter of a class name should be capital so the following would work if you had a claass named Punch

var punch:Punch = new Punch( );
The_asMan
  • 6,364
  • 4
  • 23
  • 34