Highlighted

Adapting AS2 function

New Here ,
Jul 09, 2020

Copy link to clipboard

Copied

Hi, I'm trying to transform an old educational simulation to HTML5 Canvas with Animate CC and I still can't find my way. If you can help me, I am very grateful. This is the function:

 

function alfafire() {
i++;
duplicateMovieClip ("alfas", "alfas" + i, 1000 + i);
clearInterval(afint);
afint = setInterval(alfafire, 200 + (Math.random() * 1000));
}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

 

Please tell us if this approach works for you:

 

 

var afint;

function alfafire(container)
{	
	var alfas = new lib.alfas(); // alfas is the linkage name in the Library for the symbol you want to add at runtime
	alfas.x = canvas.width * Math.random();
	alfas.y = canvas.height * Math.random();
	container.addChild(alfas);
	clearInterval(afint);
	afint = setInterval(alfafire, 200 + Math.random() * 1000, container);
}

alfafire(this);

 

 

 

Regards,

JC

TOPICS
Code

Views

45

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

Adapting AS2 function

New Here ,
Jul 09, 2020

Copy link to clipboard

Copied

Hi, I'm trying to transform an old educational simulation to HTML5 Canvas with Animate CC and I still can't find my way. If you can help me, I am very grateful. This is the function:

 

function alfafire() {
i++;
duplicateMovieClip ("alfas", "alfas" + i, 1000 + i);
clearInterval(afint);
afint = setInterval(alfafire, 200 + (Math.random() * 1000));
}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

 

Please tell us if this approach works for you:

 

 

var afint;

function alfafire(container)
{	
	var alfas = new lib.alfas(); // alfas is the linkage name in the Library for the symbol you want to add at runtime
	alfas.x = canvas.width * Math.random();
	alfas.y = canvas.height * Math.random();
	container.addChild(alfas);
	clearInterval(afint);
	afint = setInterval(alfafire, 200 + Math.random() * 1000, container);
}

alfafire(this);

 

 

 

Regards,

JC

TOPICS
Code

Views

46

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
Jul 09, 2020 0
Adobe Community Professional ,
Jul 09, 2020

Copy link to clipboard

Copied

Hi.

 

Please tell us if this approach works for you:

 

 

var afint;

function alfafire(container)
{	
	var alfas = new lib.alfas(); // alfas is the linkage name in the Library for the symbol you want to add at runtime
	alfas.x = canvas.width * Math.random();
	alfas.y = canvas.height * Math.random();
	container.addChild(alfas);
	clearInterval(afint);
	afint = setInterval(alfafire, 200 + Math.random() * 1000, container);
}

alfafire(this);

 

 

 

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...
Jul 09, 2020 0
New Here ,
Jul 09, 2020

Copy link to clipboard

Copied

Thank you very much Joao,
it works perfectly!!

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...
Jul 09, 2020 1
Adobe Community Professional ,
Jul 09, 2020

Copy link to clipboard

Copied

Awesome! You're welcome!

__________________________________________
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...
Jul 09, 2020 0