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

Get value of a variable

Community Beginner ,
Dec 11, 2011 Dec 11, 2011

Copy link to clipboard

Copied

Hello:

In other language I can use this kind of sentences:

function DoSomething (n:uint):void

{

   

    var Myvalue:Object;

    Myvalue="image"+n+"_mc");

    Myvalue.gotoAndPlay(2);

}

How can achieve this? because the above code does not work.

Many thanks

TOPICS
ActionScript

Views

448

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 , Dec 11, 2011 Dec 11, 2011

You have an unmatched closing parenthesis so that will not work, but to use a String to target an object you can use the bracket notation...

this["image"+n+"_mc"].gotoAndPlay(2);

I show it without the variable since that is an unnecessary step, though you can use it if you prefer.

Votes

Translate

Translate
LEGEND ,
Dec 11, 2011 Dec 11, 2011

Copy link to clipboard

Copied

LATEST

You have an unmatched closing parenthesis so that will not work, but to use a String to target an object you can use the bracket notation...

this["image"+n+"_mc"].gotoAndPlay(2);

I show it without the variable since that is an unnecessary step, though you can use it if you prefer.

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