Need helping passing variables through frames

Uploading file for assistance [betawar?] :P

Page 1 of 1

7 Replies - 3546 Views - Last Post: 28 August 2008 - 05:44 AM

#1 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Need helping passing variables through frames

Posted 26 August 2008 - 06:54 PM

Hi guys

Im having an issue with something.

In my game, everything is done on frame 1 really. Frame 2 shows a nice menu with your money earned, multiplies it by your multiplier score, and then adds that new days total to your total gametime total.

Problem is, Im having trouble passing variables from frame 1, to frame 2, and back to frame 1. I can't even get them from frame 1 to 2.

Another thing I can't even seem to get is the pseudo-code for bringing the variables at the end of the day (end of frame 2) back to frame 1 since frame 1 declares all variables = 0 at frame load. How do I get passed this?

**note that day is being passed properly from frame 1 to 2 - and i think this is because it isnt inside ANOTHER movie clip on frame 2, just in the root**


If someone could quickly edit my code or at least download and look at my file then post what to do here, it would REALLY help me out. Thank you so much.

::CONTROLS::

Left , Right (temporarily adds money since no money objects have been created yet)


For some reason I can't upload a .fla here, so here is a link to my website - i will temporarily host it.
http://www.progressi...rachutegame.fla

Is This A Good Question/Topic? 0
  • +

Replies To: Need helping passing variables through frames

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1134
  • View blog
  • Posts: 7,094
  • Joined: 07-September 06

Re: Need helping passing variables through frames

Posted 26 August 2008 - 07:44 PM

Here is what I would suggest doing to get things working correctly.

Create a new layer on top of all the other layers that is called "actions" place all the variables that you want to be global in this layer which you have a singel keyframe with frames that span the entire length of the movie), then just call to the things like normal. I haven't looked at your file as of yet (so you may already be doing something like this) but I hope it is useful to you anyway.
Was This Post Helpful? 0
  • +
  • -

#3 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Need helping passing variables through frames

Posted 26 August 2008 - 07:55 PM

View PostBetaWar, on 26 Aug, 2008 - 07:44 PM, said:

Here is what I would suggest doing to get things working correctly.

Create a new layer on top of all the other layers that is called "actions" place all the variables that you want to be global in this layer which you have a singel keyframe with frames that span the entire length of the movie), then just call to the things like normal. I haven't looked at your file as of yet (so you may already be doing something like this) but I hope it is useful to you anyway.



How do I make the variables global?

global.variable=0; ?

And every time I want to refer to them, either from a movieclip inside of a movieclip, or from the root, do i just say global.variable+=5; or _global.variable+=5; or _root.global.variable+=5;

Sorry I understand what you meant by creating the actions layer but not by the referencing, which is what the topic is about :)
Was This Post Helpful? 0
  • +
  • -

#4 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Need helping passing variables through frames

Posted 26 August 2008 - 08:05 PM

Ok im getting somewhere.


i created a title screen that initializes all values. the game runs on frame 2, calculates variables and shows stats on frame 3, then brings you back to frame 2 to play on a new day

all variables in the root of their frames show up properly. the variables that im trying to display with graphical effects on frame 3 INSIDE a movie clip (so not in the root) do not show up properly. How do I load and work with these variables?


***FILE on my website UPDATED***

**EDIT AGAIN**

Wow, ok so I got the variables to load inside of the movie clip. I took a chance and made the dynamic text field have the variable _root.totalmoney instead of totalmoney... AND IT WORKED!

This post has been edited by Sonastylol: 26 August 2008 - 08:33 PM

Was This Post Helpful? 0
  • +
  • -

#5 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Need helping passing variables through frames

Posted 26 August 2008 - 11:03 PM

Heres what ive been working on in case anyone wants to see my progress!


http://progressionga...rachutegame.swf
Was This Post Helpful? 0
  • +
  • -

#6 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1134
  • View blog
  • Posts: 7,094
  • Joined: 07-September 06

Re: Need helping passing variables through frames

Posted 27 August 2008 - 05:46 AM

Yes, using the _root makes things goto the global instance (the one that was made on the new layer you created in my previous post).

It is an interesting game you are working on there I didn't realize at first that you were trying to hit th ecoins, I though you wanted to avoid them :) As such I made it through day 1 with no money :(
Was This Post Helpful? 0
  • +
  • -

#7 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Need helping passing variables through frames

Posted 27 August 2008 - 09:14 AM

My coins are spawning anywhere between the height of my game, 500.

the line that governs that is this:
this._y=random(500); 


what would I have to do to make the coins only spawn between 30 pixels from the bottom, and 50 from the top (numbers may change)

I know its like random(500)-50; or something from the top, or maybe - is the bottom, im not sure, but I need to have it randomize between 2 points not 1. thanks a lot
Was This Post Helpful? 0
  • +
  • -

#8 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1134
  • View blog
  • Posts: 7,094
  • Joined: 07-September 06

Re: Need helping passing variables through frames

Posted 28 August 2008 - 05:44 AM

Try something like so:
this._y = random(420)+50; //random Number between 0 and 420, (500- (30+50)), and then add 50 to it (to make it 50 pixels from the top).


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1