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

What asterix ("*") means in the variable declaration ?

Explorer ,
Mar 22, 2017 Mar 22, 2017

For example:

var _loc_2:* = Number(this.text_control.text);

Why this is not:

var _loc_2:Number = Number(this.text_control.text); ?

362
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 , Mar 22, 2017 Mar 22, 2017

What kglad said is most likely true, but the general use of asterisk is to be a wildcard, so that any variable type can come in. You can make an argument that it's sloppy programming, or that at least you're not doing as much as you could to show up compiler errors. But here's one example:

Suppose you want to let the user skip the loading of something, but if they don't skip things will proceed once the item is loaded. You might have something like this:

loader.addEventListener(Event.COMPLETE,proc

...
Translate
Community Expert ,
Mar 22, 2017 Mar 22, 2017

it means someone decompiled a fla (and the variable type isn't specified)

the reason, your decompiler goofed.

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
Explorer ,
Mar 22, 2017 Mar 22, 2017

Variable type is specified (Number), but decompiler replaced this word by "*". Why and what does it mean ? That variable was declared inside function. In case of global variables the word "Number" was not replaces by "*".

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 ,
Mar 22, 2017 Mar 22, 2017

What kglad said is most likely true, but the general use of asterisk is to be a wildcard, so that any variable type can come in. You can make an argument that it's sloppy programming, or that at least you're not doing as much as you could to show up compiler errors. But here's one example:

Suppose you want to let the user skip the loading of something, but if they don't skip things will proceed once the item is loaded. You might have something like this:

loader.addEventListener(Event.COMPLETE,proceed);

skipBtn.addEventListener(MouseEvent.CLICK,proceed);

One of those is a mouse event the other is just an event. In this case you could have:

function proceed(e:Event){

//go on to next thing

}

because MouseEvent is still Event. The other way to solve it would be:

function proceed(e:*){

//go on to next thing

}

As I said, this isn't necessarily a good way to work, but you have the option of doing it that way.

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
Explorer ,
Mar 22, 2017 Mar 22, 2017

Yes, asterix is a wildcard. By why the word "Number" was replaced by asterix ? And why only in case of variable declared inside function ?

And the decompiler changed also name of variable. That was not "_loc_2" but "liczba":

var liczba:Number = ...

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 ,
Mar 22, 2017 Mar 22, 2017
LATEST

The variable type is used during compiling. It's not needed in the final file, so the decompiler won't know what it is. Also, local variables get shortened. They're not needed outside of the function, so some space can be saved by giving it the shortest unique name it can have.

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