Hi,
I’m building something in Papervision3D.
I often get a problem when I try to use ‘getChildByName()’ which throws up this error:
[COLOR=darkslategray]TypeError: Error #1009: Cannot access a property or method of a null object reference.[/COLOR]
[COLOR=darkslategray]at pages_test_72_fla::MainTimeline/loop()[/COLOR]
Here’s the example which caused this instance.
The code which causes it is inside a [COLOR=darkred]function loop(e:Event):void{}.[/COLOR]
This code works fine:
[COLOR=darkslategray]if(camera.rotationY == -45)[/COLOR]
[COLOR=darkslategray]{[/COLOR]
[COLOR=darkslategray]camera.z += zDist * 0.1;[/COLOR]
[COLOR=darkslategray]}[/COLOR]
But I have a number of planes in this movie and I want this scroll to suspend when those planes are at certain coordinates. The problem occurs when I add this to my code ([COLOR=#8b0000]planePos [/COLOR][COLOR=black]is a number var I set up earlier[/COLOR])…
[COLOR=darkslategray]if((camera.rotationY == -45) [COLOR=darkred]&& (getChildByName(“plane” + planePos).x < 500) || (getChildByName(“plane” + (planePos + 10)).x < 1700)[/COLOR][COLOR=darkslategray])[/COLOR]
{
camera.z += zDist * 0.1;
}[/COLOR]
The ‘planes’ in question (numbered ‘plane1’ to ‘plane18’) are defined well before my loop occurs using the following code:
[COLOR=darkslategray]var plane1: Plane = new Plane(this.mm1, 350, 260, 2, 2);[/COLOR]
[COLOR=darkslategray]scene.addChild(plane1);[/COLOR]
[COLOR=darkslategray]plane1.y = 0;[/COLOR]
[COLOR=darkslategray]plane1.x = 0;[/COLOR]
[COLOR=darkslategray]plane1.z = 0;[/COLOR]
Am I just missing something really obvious here? Can anyone see what I’m doing wrong?
Many thanks in advance.
S.