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

Animate CC. Help convert code AS 3.0 to html5. Thanks a lot!

Community Beginner ,
Nov 18, 2019 Nov 18, 2019

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;

}
}

 

TOPICS
ActionScript , Code , Error , How to

Views

358

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

LEGEND , Nov 20, 2019 Nov 20, 2019

> 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

 

Votes

Translate

Translate
Community Expert ,
Nov 19, 2019 Nov 19, 2019

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

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 Beginner ,
Nov 25, 2019 Nov 25, 2019

Copy link to clipboard

Copied

LATEST

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;
	}
};

 

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
LEGEND ,
Nov 20, 2019 Nov 20, 2019

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

 

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 Beginner ,
Nov 25, 2019 Nov 25, 2019

Copy link to clipboard

Copied

Thanks so much. Because I'm newbie, and my English is not fluently. 

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