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

Adapting AS2 function

New Here ,
Jul 09, 2020 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));
}

TOPICS
Code

Views

269

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

Community Expert , Jul 09, 2020 Jul 09, 2020

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

Votes

Translate

Translate
Community Expert ,
Jul 09, 2020 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

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

Copy link to clipboard

Copied

Thank you very much Joao,
it works perfectly!!

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 Expert ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

LATEST

Awesome! You're welcome!

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