Skip to main content
Participant
December 23, 2013
Answered

What is more optimized?

  • December 23, 2013
  • 1 reply
  • 741 views

Dear Adobe users,

I want to make a turn based game. In the game you have more then one frame, but the vars of one frame need to be ajusted by another frame. I thought, lets make a class as a var holder, named varHolder.as. Then put all the vars that I need for more frames in that class and import it to the framecontroll classes.

My questions are:

What is more optimized?

Everytime calling to the class (example: varHolder.wood ==1 )

Or,

creating new vars, giving them the value of the varHolders var and then at the end of the turn send the vars value's back to the varHolder.as. (example: wood = varHolder.wood

Or,

Is there a better way of doing this ?

I'm really just a starter so sorry if this is a noob question. I personally think the second option, because then you don't have to call the other class all the time. Although I don't know is that is hard on your pc or not.

Hope you guys/girls can help,

Casper

This topic has been closed for replies.
Correct answer kglad

creating less variables is more efficient than creating more variables.

variables created on any frame of a timeline are available on all other frames of that timeline.  and they are available on other timelines but you need to use a path between the timelines.

by using a class with static variables you don't have to pay attention to timelines and paths.  of course, that obviates one of the upsides of oop.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 23, 2013

creating less variables is more efficient than creating more variables.

variables created on any frame of a timeline are available on all other frames of that timeline.  and they are available on other timelines but you need to use a path between the timelines.

by using a class with static variables you don't have to pay attention to timelines and paths.  of course, that obviates one of the upsides of oop.

KasszzAuthor
Participant
December 23, 2013

So you would say option 1 of my list ?

kglad
Community Expert
Community Expert
December 23, 2013

i didn't say.

but i infer that would be easier for you and that's often the determining factor.