hi
i have class inside library called hero , want move in stage useing keyboard error
c:\users\owner n\desktop\zelda advanture\hero.as, line 1 5006: actionscript file can not have more 1 externally visible definition: hero, onremovedfromstage
and here code class
package {
import flash.display.movieclip;
import flash.events.keyboardevent;
import flash.ui.keyboard;
import flash.events.event;
public class hero extends movieclip {
public function hero() {
addeventlistener(event.added_to_stage,onaddedtostage)
}
public function onaddedtostage(event:event):void
addeventlistener(event.enter_frame,onenterframe )
stage.addeventlistener(keyboardevent.key_down,onkeydown)
stage.addeventlistener(keyboardevent.key_up,onkeyup)
addeventlistener(event.removed_from_stage,onremovedfromstage)
}
public function onremovedfromstage(event:event):void{
removeeventlistener(event.added_to_stage,onaddedtostage)
removeeventlistener (event.enter_frame,onenterframe )
removeeventlistener(event.removed_from_stage,onremovedfromstage)
trace("player removed")
}
public function onenterframe(event:event):void{
}
public function onkeydown(event:keyboard):void{
if (event.keycode = keyboard.right){
gotoandstop(2)
x +=3
}
if (event.keycode == keyboard.left){
gotoandstop(3)
x -=3
}
}
public function onkeyup (event:keyboardevent):void{
if(event.keycode == keyboard.left){
gotoandstop(3)
}
else if (event.keycode == keyboard.right){
gotoandstop(4)
}
}
}
thank you
the problem might stem missing curly brace in beginning of onaddedtostage function.
public function onaddedtostage(event:event):void <--- {
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment