Copy link to clipboard
Copied
Hi Everyone,
I'm a newbie. Today i need your help.
I have a old game with code by ActionScript 3.0 so i want to convert the code to Java.
Can you please help me? This is my code. Please help me to convert it. Thanks a lot.
import flash.events.MouseEvent;
stop();
nextBtn2.addEventListener(MouseEvent.CLICK,jumpClick);
function jumpClick(event:MouseEvent):void
{
gotoAndPlay(3);
}
backBtn.addEventListener(MouseEvent.CLICK,backClick);
function backClick(event:MouseEvent):void
{
prevFrame();
}
ngoinha.visible = false;
mc1.visible = true;
import flash.events.MouseEvent;
stop();
checkBtn.addEventListener(MouseEvent.CLICK,checkClick);
function checkClick(event:MouseEvent):void
{
if(viet.text == "me")
{
hiends.text = "right";
ngoinha.visible = true;
mc1.visible = false;
}
else
{
hiends.text = "wrong";
ngoinha.visible = false;
mc1.visible = true;
}
}
> I have a old game with code by ActionScript 3.0 so i want to convert the code to Java.
No, you do not want to convert it to Java. You want to convert it to JavaScript, a completely different language with no relation to Java other than the first four letters of its name.
https://helpx.adobe.com/animate/kb/as-to-html5.html
Copy link to clipboard
Copied
Hi.
The difference won't be that much. The main change from AS3 to HTML5 Canvas is context.
AS3 code:
import flash.events.MouseEvent;
function jumpClick(event: MouseEvent): void
{
gotoAndPlay(3);
}
function backClick(event: MouseEvent): void
{
prevFrame();
}
function checkClick(event: MouseEvent): void
{
if (viet.text == "me")
{
hiends.text = "right";
ngoinha.visible = true;
mc1.visible = false;
}
else
{
hiends.text = "wrong";
ngoinha.visible = false;
mc1.visible = true;
}
}
if (!this.started)
{
stop();
ngoinha.visible = false;
mc1.visible = true;
nextBtn2.addEventListener(MouseEvent.CLICK, jumpClick);
checkBtn.addEventListener(MouseEvent.CLICK, checkClick);
backBtn.addEventListener(MouseEvent.CLICK, backClick);
this.started = true;
}
JavaScript code:
var root = this;
root.jumpClick = function(e)
{
root.gotoAndPlay(3);
};
root.backClick = function(e)
{
root.gotoAndStop(root.currentFrame - 1);
};
root.checkClick = function(e)
{
if (root.viet.text === "me")
{
root.hiends.text = "right";
root.ngoinha.visible = true;
root.mc1.visible = false;
}
else
{
root.hiends.text = "wrong";
root.ngoinha.visible = false;
root.mc1.visible = true;
}
};
if (!root.started)
{
root.stop();
root.ngoinha.visible = false;
root.mc1.visible = true;
root.nextBtn2.addEventListener("click", root.jumpClick);
root.checkBtn.addEventListener("click", root.checkClick);
root.backBtn.addEventListener("click", root.backClick);
root.started = true;
}
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Thank you so much.
I have a problem is : viet.txt is TextInput ( AS ), when i convert to HTML5,it doesn't work. So i replace it by Component -> User Interface -> TextInput. What can i do to code this ?
root.checkClick = function(e) { if (root.viet.text === "me") { root.hiends.text = "right"; root.ngoinha.visible = true; root.mc1.visible = false; } else { root.hiends.text = "wrong"; root.ngoinha.visible = false; root.mc1.visible = true; } };
Copy link to clipboard
Copied
> I have a old game with code by ActionScript 3.0 so i want to convert the code to Java.
No, you do not want to convert it to Java. You want to convert it to JavaScript, a completely different language with no relation to Java other than the first four letters of its name.
https://helpx.adobe.com/animate/kb/as-to-html5.html
Copy link to clipboard
Copied
Thanks so much. Because I'm newbie, and my English is not fluently.