[FONT=Verdana]Hi,[/FONT]
[FONT=Verdana]I’m new on here so apologies if I’m posting in the wrong place.[/FONT]
[FONT=Verdana]I’m trying to build something in Papervision3D using AS3. I have a limited knowledge of both and as far as I know there isn’t any comprehensive documentation for Papervision3D yet (apart from lists of classes etc).[/FONT]
[FONT=Verdana]Basically I’m trying to create a line of planes along the z axis using a ‘for’ loop. Each has to have a movieclip applied to it as a MovieMaterial (which also needs to be clickable).[/FONT]
[FONT=Verdana]I’ve been getting a number of errors on out put and it seems that whenever I solve one issue my solution causes a new one. After a long struggle I’ve ended up with this:[/FONT]
[FONT=Verdana][COLOR=darkslategray]var planeArray1:Array = new Array();[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]var matArray1:Array = new Array();[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]// create base level planes[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]for(var e:Number = 1; e < 10; e++)[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]{[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]// create material[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]var MaterialClass:Class = getDefinitionByName(“Material” + e) as Class;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]var material:MovieMaterial = new MovieMaterial(new MaterialClass());[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]material.name = “page” + e;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]matArray1.push(material);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]material.interactive = true;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]material.animated = true;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]material.smooth = true;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]// create plane[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]var plane: Plane = new Plane(material, 350, 260, 1, 1);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.useOwnContainer = true;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.name = “plane” + e;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]planeArray1.push(plane);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.x = 0;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.y = 0;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.z = placer + 250;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]placer += 250;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]scene.addChild(plane);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]}[/COLOR][/FONT]
[FONT=Verdana]As you can see I name each plane and material with this code:[/FONT]
[FONT=Verdana][COLOR=darkslategray]material.name = “page” + e;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]plane.name = “plane” + e;[/COLOR][/FONT]
[FONT=Verdana]I can’t seem to reference these names in the way I want to though. I’ve been trying to use them as you might use a movieclip instance name but whenever I do this I get an error on output stating that these ‘variables’ (plane1, plane2… etc) have not been defined. Have I misunderstood the function of ‘name’ in this instance?[/FONT]
[FONT=Verdana]I eventually put everything into arrays and tried referencing the array contents. Now my line of planes builds fine… but none of the event listeners for my material ‘click’ events are working.[/FONT]
[FONT=Verdana]Here’s an example…[/FONT]
[FONT=Verdana][COLOR=darkslategray]matArray1[0].addEventListener(MouseEvent.CLICK, planeClick1);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]function planeClick1(e:MouseEvent):void[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]{[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]if(planeArray1[0].x == 0)[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]{[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]if(level == 1)[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]{[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]returnPages_l1(Event);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]}[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]returnPages(Event);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]count = 1;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]level = 0;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]Tweener.addTween(planeArray1[0], {rotationY: -45, x: 500, time: 2} );[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]matArray1[0].gotoAndPlay(“open”);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]}[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]else if(planeArray1[0].x == 500)[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]{[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]count = 0;[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]Tweener.addTween(planeArray1[0], {rotationY: 0, x: 0, time: 2} );[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]matArray1[0].gotoAndPlay(“close”);[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]}[/COLOR][/FONT]
[FONT=Verdana][COLOR=darkslategray]}[/COLOR][/FONT]
[FONT=Verdana]I’ve been going round in circles for a while now.[/FONT]
[FONT=Verdana]If you can see anything really obvious… or stupid… that I’m doing wrong here please let me know.[/FONT]
[FONT=Verdana]Many thanks in advance.[/FONT]
[FONT=Verdana]S.[/FONT]