Forum Topic: 'Execute' commans=d

(268 views • 22 replies)

This topic is 1 page long.

<< < > >>
None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/2/09 07:13 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

In AS2, or AS3, I don't really care, is there any command that executes a block of code stored in a variable?

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/2/09 07:23 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

Gaha, how the fuck could I spell the title like that

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

Montycarlo

Reply To Post Reply & Quote

Posted at: 11/2/09 08:06 PM

Montycarlo LIGHT LEVEL 19

Sign-Up: 03/14/05

Posts: 720

Yes, there is, it's called a function.

final public function memberFunction():void{
     trace("look, it's working!");
}
var varFunc:Function = memberFunction
....


varFunc();

None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/2/09 08:14 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

I didn't really understand that code

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

K-Guare

Reply To Post Reply & Quote

Posted at: 11/2/09 08:17 PM

K-Guare FAB LEVEL 17

Sign-Up: 05/23/08

Posts: 2,406

I think he actually wants to run custom code
saved as a String that the user wrote.

I've never done it, but this little guide says you can do it with PHP.

i work alone. i wore cologne.

BBS Signature

None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/2/09 08:21 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

Too bad I don't use PHP...

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

zrb

Reply To Post Reply & Quote

Posted at: 11/2/09 08:57 PM

zrb LIGHT LEVEL 11

Sign-Up: 08/08/06

Posts: 4,537

At 11/2/09 08:21 PM, 7IsUnlucky wrote: Too bad I don't use PHP...

So what exactly do you want ? What K-Guare mentionned, a user writing codes and your thing making it run OR just a function that does things you tell it to ?

School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/2/09 10:31 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

At 11/2/09 08:57 PM, zrb wrote: So what exactly do you want ? What K-Guare mentionned, a user writing codes and your thing making it run OR just a function that does things you tell it to ?

Is there any way to have code in a variable, and then have it be done when a button is pressed or something?

I don't just mean a line of code; a full physics engine or something

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

YoinK

Reply To Post Reply & Quote

Posted at: 11/2/09 11:36 PM

YoinK LIGHT LEVEL 53

Sign-Up: 01/05/01

Posts: 6,086

why would you want to put code within a variable???? that doesn't make sense.....
you should use variables to enable certain codes.

Kanye West Did What??????
They should make a black guy the manager, they know how to run shit!
2 Girls 1 Cup .... THE SONG!!!!


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 11/3/09 03:44 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,378

You can't. Actionscript is dealt with by the editor program, Flash Player doesn't understand Actionscript as you see it.

Reconsider if you really need it, you probably don't know what you're doing and want a magical function to do something you don't actually need it for.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

henke37

Reply To Post Reply & Quote

Posted at: 11/3/09 06:28 AM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,582

I feel like we talked about this like yesterday, it is a bad idea, but possible in as 2, as 3 does not have this bad idea.

Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


None

Nayhan

Reply To Post Reply & Quote

Posted at: 11/3/09 06:49 AM

Nayhan LIGHT LEVEL 13

Sign-Up: 09/08/06

Posts: 390

At 11/2/09 10:31 PM, 7IsUnlucky wrote: Is there any way to have code in a variable, and then have it be done when a button is pressed or something?
I don't just mean a line of code; a full physics engine or something

What your meant to do is make a variable and an if listener, then variable equals one thing it executes one set of code and if it equals something else it executes a different line of script.


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 11/3/09 06:50 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,378

At 11/3/09 06:28 AM, henke37 wrote: I feel like we talked about this like yesterday, it is a bad idea, but possible in as 2, as 3 does not have this bad idea.

Like I said previously, 'eval' only evaluates paths, not code.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

sasuke2910

Reply To Post Reply & Quote

Posted at: 11/3/09 08:29 AM

sasuke2910 LIGHT LEVEL 09

Sign-Up: 06/11/06

Posts: 1,660

I said this to some one just a couple days ago:

No because code is pre-compiled. So when you export your flash as a .swf file all the code is converted in to a different language that flash player can read better. And flash player had no function for re-compiling the code. Sorry

What were you trying to do. There may be an alternative.

BBS Signature

None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/3/09 09:15 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

There is a really cool actionscript interpreter you can get somewhere.. it's not actually actionscript, but like as it is based on ecmascript and has a lot of the same features as as2, as well as being able to give access to your own classes and variables so you can really do a lot with it. I forget what it's called, but googling flash scripting engine or something like that will probably help.. not that I think you'd be able to use it to it's full extent, because you don't seem to know what you want :P


None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/3/09 05:35 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

So, could I have the code be in a variable and have something like

execute = false;
if (execute) {
    codevariable;
}

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

CloudEater

Reply To Post Reply & Quote

Posted at: 11/3/09 10:30 PM

CloudEater LIGHT LEVEL 02

Sign-Up: 10/17/09

Posts: 266

At 11/3/09 05:35 PM, 7IsUnlucky wrote: So, could I have the code be in a variable and have something like

No you can't place code in a variable. So you just go:

event1 = false;
if (event1) {
    //one set of code
} else {
    //the other set of code
}

None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/4/09 05:44 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

Didn't you read my original post?

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

knugen

Reply To Post Reply & Quote

Posted at: 11/4/09 06:02 PM

knugen LIGHT LEVEL 35

Sign-Up: 02/07/05

Posts: 4,648

I don't know why but you seem to ignore the posts who actually answer your question.

To sum up what has already been said:
- It is not possible to execute AS stored in a string variable with any native function
- There are however libraries for this, interpreters, which seems to work to some extent

If you know what your code will do at compile time (i.e. it will not change during runtime) use functions, as mentioned in the very first reply.


None

7IsUnlucky

Reply To Post Reply & Quote

Posted at: 11/4/09 06:22 PM

7IsUnlucky FAB LEVEL 25

Sign-Up: 06/12/07

Posts: 1,953

I asked another guy, he said it's possibly

Programming languages I know: AS2 and TRS-80 BASIC

BBS Signature

None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/4/09 06:44 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 11/4/09 06:22 PM, 7IsUnlucky wrote: I asked another guy, he said it's possibly

Oh, well, never mind then. Ignore what I and these other guys said, it doesn't really matter if your friend it's possible(y). I guess your best option would be to ask another forum, maybe e-mail Adobe and ask them why a 13 year old can't get what he wants when he wants it in a professional piece of software like flash. I'm sure they will be sympathetic and tell you about the "compileAtRunTime()" function we're neglecting to mention.


None

blackqat

Reply To Post Reply & Quote

Posted at: 11/4/09 09:30 PM

blackqat EVIL LEVEL 13

Sign-Up: 12/17/06

Posts: 847

It was El-Presidente

PROUD '06 USER


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 11/4/09 10:54 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,567

At 11/4/09 06:44 PM, liaaaam wrote: some stuff

maybe someone should have told him about the stringToCode("") method?

but seriousally, if that someone told you its possible, please ask him how and come and tell us

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 11:22 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!