Storing a changing variable

Started by: Shadow801 | Replies: 10 | Views: 828

Shadow801

Posts: 0
Joined: Jun 2026
Jun 16, 2008 9:27 PM #158397
Hey

I hope this is the right forum for this; there doesn't seem to be a forum specifically designed for ActionScripting, unless I was dumb enough to miss it. Anyway onwards with my question:

I have a MC that has a constantly changing _x and _y variable. Now for the aim of my game to work, I need to store the MC's variable and keep it frozen at diffrent points of time.

For example, if for one second the _x position was 70, in the next second it would change to 80. What I want is a way of storing the 70, while the _x continues to change constantly.

If anyone could shed some light on this topic for me, I would be very thankfull.

~ Shadow
Komaru
2

Posts: 263
Joined: Jan 2008
Rep: 10

View Profile
Jun 16, 2008 9:33 PM #158402
On the frame that it is at 70, put "YOURVARIABLE = _root.YOURMC._x"
Shadow801

Posts: 0
Joined: Jun 2026
Jun 16, 2008 9:44 PM #158412
I dont think you understand my question.
Komaru
2

Posts: 263
Joined: Jan 2008
Rep: 10

View Profile
Jun 16, 2008 9:51 PM #158416
Quote from Shadow801
I dont think you understand my question.

I guess I don't. Is it where you need something else to have the same _x and _y? Cause then it's just an enterFrame event of _x = _x .etc.

I think that what it is is that you just need a bunch of different variables for each of the times you need the number stored.
Shadow801

Posts: 0
Joined: Jun 2026
Jun 16, 2008 10:01 PM #158423
Yes, but if I do that the variable constantly changes because the _x of my MC is constantly changing. I need a variable that stores a frozen _x variable, while MC's variable continues to change
Steyene

Posts: 2,060
Joined: Apr 2006
Rep: 10

View Profile
Jun 16, 2008 10:23 PM #158433
Make a function that captures the objects x and y coords.

Position = new Function(){
XVARIABLE = this._x OR _root.OBJECTNAME._x
YVARIABLE = this._y OR _root.OBJECTNAME._y
}
WHAT EVER(WHAT EVER YOU WANT){
Position
}
Shadow801

Posts: 0
Joined: Jun 2026
Jun 17, 2008 8:11 AM #158839
And that would freeze it, I assume?
Bonk
2

Posts: 2,778
Joined: Mar 2008
Rep: 10

View Profile
Jun 17, 2008 8:55 AM #158851
As long as you're making a new variable that is separate from the one that changes to the MC's position, then yes.
Steyene

Posts: 2,060
Joined: Apr 2006
Rep: 10

View Profile
Jun 17, 2008 10:08 AM #158856
You can run that function at anytime. As it is a funtion.
Shadow801

Posts: 0
Joined: Jun 2026
Jun 17, 2008 4:21 PM #158945
Thanks, I'll try that =]
Automaton
2

Posts: 4,779
Joined: Nov 2007
Rep: 10

View Profile
Jun 17, 2008 9:48 PM #159133
sorry offtopic but Noob_Of_Doom - i loled at your sig. that person must be such a dumbass.