Skip to main content
Known Participant
August 26, 2009
Answered

Converting AS3 to AS2, mouse event

  • August 26, 2009
  • 1 reply
  • 1329 views

Does anyone know how to convert this code to AS2, I need it to work with my AS2 component:

button_instance.addEventListener(MouseEvent.CLICK,loadNewXML)
button_instance2.addEventListener(MouseEvent.CLICK,loadNewXML)

function loadNewXML(e:MouseEvent):void{
switch(e.target)
case button_instance:
  myGallery.contentXML = "content.xml";
break;
case button_instance2:
  myGallery.contentXML = "yourNewXmlLocation2.xml";
break;
}

The error that I'm getting is The class or interface 'MouseEvent'could not be loaded (line 4)

and '{' expected (line 6)

This topic has been closed for replies.
Correct answer kglad

kglad wrote:

try:


button_instance.onRelease = loadNewXML;
button_instance2.onRelease = loadNewXML;

function loadNewXML():Void{
switch(this._name){
case "button_instance":
  myGallery.contentXML = "content.xml";
break;
case "button_instance2":
  myGallery.contentXML = "yourNewXmlLocation2.xml";
break;
}

}

1 reply

kglad
Community Expert
Community Expert
August 26, 2009

try:


button_instance.onRelease = loadNewXML;
button_instance2.onRelease = loadNewXML;

function loadNewXML():Void{
switch(this._name)
case "button_instance":
  myGallery.contentXML = "content.xml";
break;
case "button_instance2":
  myGallery.contentXML = "yourNewXmlLocation2.xml";
break;
}

Known Participant
August 26, 2009

I get an error when I try that code....it says line 22 '{' expected??