Highlighted

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

Community Beginner ,
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;

}
}

 

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

> 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

 

TOPICS
ActionScript, Code, Error, How to

Views

87

Likes

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

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

Community Beginner ,
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;

}
}

 

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

> 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

 

TOPICS
ActionScript, Code, Error, How to

Views

88

Likes

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
Nov 18, 2019 0
Adobe Community Professional ,
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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Nov 19, 2019 1
Community Beginner ,
Nov 25, 2019

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

 

Likes

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
Reply
Loading...
Nov 25, 2019 0
Adobe Community Professional ,
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

 

Likes

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
Reply
Loading...
Nov 20, 2019 1
Community Beginner ,
Nov 25, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Nov 25, 2019 0