ForumsProgramming ForumWhere do i put my variables?

4 2881
HardSimse
offline
HardSimse
218 posts
Nomad

Where do i put my variables?
Just on a specified object or the frame ?

  • 4 Replies
PixelSmash
offline
PixelSmash
566 posts
Nomad

First off, in AS3 you can't put variables on an object anyway - though AS2 still has this functionality.

And look at it as you would with using functions. If you want to use a variable in every function and subfunction, declare them at the start of your frame or class. For one specific function, you should declare them inside that function, so only that function can access it - and it doesn't exist outside that function.

So, if you want to use a variable in more functions and objects on a certain frame, declare them on the frame itself. Otherwise, if it's only for that specific object, declare them on that object.

Good luck!

HardSimse
offline
HardSimse
218 posts
Nomad

Thanks that helped me alot but there was a thing that i didnt understand.

First you said this

First off, in AS3 you can't put variables on an object anyway

And then you said this
Otherwise, if it's only for that specific object, declare them on that object.


But thanks for the help. Helped me alot!
PixelSmash
offline
PixelSmash
566 posts
Nomad

That was assuming you'd use AS2... for AS3, ignore that :P

No problem!

HardSimse
offline
HardSimse
218 posts
Nomad

Ok thanks

Helped me very much!

Showing 1-4 of 4