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

as 2 to as3

New Here ,
May 18, 2016 May 18, 2016

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
836
Translate
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.

Translate
LEGEND ,
May 18, 2016 May 18, 2016

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

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

Translate
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

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

Translate
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

try changing the line to...

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

Translate
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

Thanks for the reply but now it's saying :

Incorrect number of arguments. Maximum expected : 0 .

Translate
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

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.

Translate
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

Thanks for the reply,

I will try this when i'm at home

also nice doc I will read it

Translate
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
LATEST

Working ty very much !

Translate
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