...

View Full Version : Controlling Variables Within Flash



Psirus
05-28-2008, 12:04 AM
Ok I am relatively new to actionscript.
It is only a game of pong, but basically I have collision detection and when the ball hits the object I want it to speed up.

I have the collision detection (sort of) working:



onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
trace("Hit");
} else {
trace("Miss");
}
}

When 'ball' hits 'object' flash prints "Hit" in the output window, BUT, it does not print "Miss" when it is not hitting the object.

Anyway thats not what I am asking.
The 'ball' contains the variable:


this.fullspeed=25;

All I want to do is double it to 50, so if I change the collision to the following it should work:



onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
ball.fullspeed=50;
} else {
trace("Miss");
}
}

But alas it does not seem to work. I can't figure out how to control the variables in one object from another, as the variables do not seem to be global, if that makes sense.

Thanks for your help,
Dan

gnomeontherun
05-28-2008, 06:42 PM
Did you try putting
_root.ball.fullspeed=50; This will make sure the reference is correct.

Psirus
05-29-2008, 01:33 PM
That worked thank you.

How about having a variable coming through a third party program using 'flash server'
It brings a variable through onto the actionscript on the first frame, which is not assigned to an object.

How can I grab this variable for another object?

gnomeontherun
05-29-2008, 05:35 PM
You need to explain more about what your third party system is, perhaps an example and some code if you can?

Psirus
05-29-2008, 05:41 PM
Ok I have come across another problem. I am fine with your help now, thank you for that :)

Ill make a new thread about it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum