Thanks to the stackoverflow community, I could fix some problems in my flash project yesterday. I still get an error message but it is coming from a different behavior in the website. This is the error message I get:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-6()
This message appears again and again when I leave a page where snow flakes (particles) are falling. When I go back to this page the error message stops. My guess is that is is related to the snow flakes, when I try to remove the child from the parent.
I also get this error code mixed in with the other one but this one does not appear as often:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.at Snowflake/update()[C:\Users\JPL\Documents\ranchleblanc\New Ranch
Leblanc\website 2012\Snowflake.as:27]
Line 27 is this one in the following code: “parent.removeChild(this);”
I have been searching the internet for a way to fix this and I am stuck. Here is the snow flakes code. This movie clip is playing inside another movie clip.
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class Snowflake extends MovieClip
{
var yVel:Number;
var xVel:Number;
var stageheight:Number = 405;
function Snowflake(xvel:Number, yvel:Number)
{
yVel = yvel;
xVel = xvel;
this.addEventListener(Event.ENTER_FRAME, update);
}
function update(e:Event):void
{
this.x += xVel;
this.y += yVel;
if (this.y > stageheight)
{
this.removeEventListener(Event.ENTER_FRAME, update);
parent.removeChild(this);
}
}
}
}
Anyone can point me in the right direction?
replace the offending line (27) with
make sure parent actually exists first.
you’ll want to remove the event listener too, to prevent horrifying memory leakage.
In re MethodInfo-6()
So, I’ve seen that kind of message before but it’s been a long time. MethodInfo- functions are really internal functions in the Flash Player and should not be bugging you with their errors… If my memory serves me correctly, I encountered this in code someone else wrote in which they were trying to perform an action with a swf that had not yet loaded… or perhaps perform an action from inside the loaded swf that it was not yet actually able to perform at the time the code was called.
So here, let’s see if we can sort out your problems a little bit.
Inside your acuiel_fla file, you have a number of things you’re doing on frame 1 that assume that acuiel_fla is the main timeline which it will not be! Try something like this…