Reputation: 199
I've been getting error 1120: Access of undefined property on two different symbols for a simple radial gravity simulator in Flash. So far the following fixes have not worked:
Giving the instance a name. The most common advice for this problem is to name an instance for the object. In the properties panel for one of my symbols it says that it's a Graphic and "Instance of: Earth" (sorry, I can't post images until I have 10 rep)
Putting it into a package. This doesn't make any difference for me.
Here's the code:
var yVelocity:Number = 0;
var xVelocity:Number = 0;
var gravityConstant:Number = 1;
var earthMass:Number = 5000;
var canPlay:Boolean = true;
function findAcceleration():Number {
var distance:Number = Point.distance(Ship, Earth);
return gravityConstant * earthMass / Math.pow(distance, 2);
}
function findAngle():Number {
var angle:Number = Math.atan((Ship._y - Earth._y) / (Ship._x - Earth._x));
return (180 / Math.PI) * angle; //converts from radians to degrees
}
function findXAcceleration():Number {
return findAcceleration() * Math.cos(findAngle());
}
function findYAcceleration():Number {
return findAcceleration() * Math.sin(findAngle());
}
function gravity():void {
yVelocity += findYAcceleration();
xVelocity += findXAcceleration();
Ship._x += xVelocity;
Ship._y += yVelocity;
}
do
{
gravity();
} while (canPlay == true);
The canPlay boolean is going to be implemented later.
Upvotes: 1
Views: 385
Reputation: 227
Did you export your movieclips to actionscript?
Library: Right click the movie-clip > properties > advanced > check the box "export to actionscript" write the name you wish to access the movieclip by in "class".
Upvotes: 1