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

as 2 to as3

New Here ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

Hy,

I'm having an issu for a line, i need to convert it to as3 but idk how to do that 😕

there is the line to convert :

if (MovieClip(root).flagSound)

{

    this.random_RO.gotoAndStop(random(this.random_RO._totalframes - 1) + 2);

}

And it says :

"Call to a method that does not seem set, random ."

TOPICS
ActionScript

Views

613

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 , May 19, 2016 May 19, 2016

This stuff is all very well documented on the internet. ECMAScript Math.random() doesn't take any arguments, it just returns a float between 0 and 1. So you'd do this:

this.random_RO.gotoAndStop(Math.random() * (this.random_RO.totalFrames - 1) + 2);

Note that _totalframes was wrong too. In AS3 it's totalFrames.

Votes

Translate

Translate
LEGEND ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

Because random() in AS3 is Math.random().

Actually it's Math.random() in AS2 too. random() has been deprecated since at least 2005.

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 ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

but can you convert it pls ? It's not working for me 😕

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 ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

try changing the line to...

random_RO.gotoAndStop(int(Math.random(random_RO._totalframes - 1)) + 2);

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 ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

Thanks for the reply but now it's saying :

Incorrect number of arguments. Maximum expected : 0 .

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 ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

This stuff is all very well documented on the internet. ECMAScript Math.random() doesn't take any arguments, it just returns a float between 0 and 1. So you'd do this:

this.random_RO.gotoAndStop(Math.random() * (this.random_RO.totalFrames - 1) + 2);

Note that _totalframes was wrong too. In AS3 it's totalFrames.

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 ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

Thanks for the reply,

I will try this when i'm at home

also nice doc I will read it

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 ,
May 20, 2016 May 20, 2016

Copy link to clipboard

Copied

LATEST

Working ty very much !

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