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

GOTO statement

Participant ,
May 09, 2007 May 09, 2007
I've seen in programming languages like Visual Basic, there is a command.... GoTo label:

Then, the control will be shifted to the label referred and will start executing from that position.

I wonder why Actionscript doesn't have this feature?

Ex: (like this)



TOPICS
ActionScript
2.3K
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 ,
May 09, 2007 May 09, 2007
As far as I know there is no such future.
But using goto is always bad habit in programing language.
There is always way to avoid using of it.

Can you be more specific why u need to use goto ??
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 ,
May 09, 2007 May 09, 2007
In actionscript:
that would be either:
gotoAndPlay("label");
or u may use
gotoAndStop("label");
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 ,
May 10, 2007 May 10, 2007
you could absolutely goto a frame.

Also you can do what you want by writing another function, rather than a labeled point in the code.
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
Participant ,
May 10, 2007 May 10, 2007
Thank you all for the nice responses. I think RaGlitter's idea is OK.

abrahamyan.com:

In some cases, I felt the difficulty of not having this feature.

But, absolutely........we have alternatives.
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 ,
May 10, 2007 May 10, 2007
gotoAndPlay() controls timeline, your question was about jumping inside function scope i guess.
they are different things.
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
Participant ,
May 10, 2007 May 10, 2007
Yes, you are right. I am asking about jumping from one line to another line within a code and not in the timeline.
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 ,
May 10, 2007 May 10, 2007
Yes, I agree a goto is never really needed. There are always better ways to go about it.

In your sample code, a simple if-else would work just fine. Inside your if-else, you could also call other functions as well if you find the code inside is long and reusable.

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
Participant ,
May 10, 2007 May 10, 2007
Of course.......we can achieve this with an else block. I think because of this only they might have not given importance to the label.
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 11, 2007 May 11, 2007
MurMeeKeer wrote:
> I've seen in programming languages like Visual Basic, there is a command....
> GoTo label:
>
> Then, the control will be shifted to the label referred and will start
> executing from that position.
>
> I wonder why Actionscript doesn't have this feature?
>
> Ex: (like this)
>
>
>
>
>
> function greater(a,b){
> if(a>b){
> goto lbl;
> }
> trace(b+" is greater than "+a)
> return b
> lbl:
> trace(a+" is greater than "+b)
> return a
> }
>
The bytecode that the Action Script is compiled into does support goto.
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 11, 2007 May 11, 2007
LATEST
Actionscript is based on ECMA. There is no GoTo statement in the standard.

http://www.ecma-international.org/publications/standards/Ecma-262.htm


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