youwh
May 5th, 2008, 04:01 PM
I've duplicate a series of MC, but the thing is i can traced it and the result is its created with a random position, but it only shows 1 MC on stage, and the MC i traced, the 1st MC position is 0 by x,y,z where it should be random like the other MC.
And I can't seems to assign a buttonMode to it. It will somehow assign the buttonMode to the MCs and a Plane i created.
Whats wrong with my code here?
ActionScript Code:
public class pv3d extends Sprite {
private var viewport:Viewport3D;
private var scene:Scene3D;
private var camera:FreeCamera3D;
//private var camera:Camera3D;
private var renderer:BasicRenderEngine;
private var fc3d:FreeCamera3DController;
//----------------------------------------------------------------------------------------
private var p:Plane;
private var xml:XML;
private var xmlList:XMLList;
private var xmlLoader:URLLoader=new URLLoader;
private var pictureArray:Array=new Array;
private var textArray:Array=new Array;
//----------------------------------------------------------------------------------------
private var cube:Cube = new Cube(new MaterialsList({front:new MovieAssetMaterial("surFront",false,true),back:new MovieAssetMaterial("surBack",false,true),right:new MovieAssetMaterial("surRight",false,true),left:new MovieAssetMaterial("surLeft",false,true),top:new MovieAssetMaterial("surTop",false,true),bottom:new MovieAssetMaterial("surBottom",false,true)}), 40, 2, 42, 10, 10, 10);
//----------------------------------------------------------------------------------------
public function pv3d():void {
var base:MovieAssetMaterial=new MovieAssetMaterial("platform");
base.oneSide=false;
base.smooth=true;
//----------------------------------------------------------------------------------------
//primitive = new Plane(material applied to object, width, height, wSegments, hSegments);
p=new Plane(base,1000,750,3,3);
p.x=0;
p.y=0;
p.z=0;
scene.addChild(p);
//----------------------------------------------------------------------------------------
xmlLoader.load(new URLRequest("gallery/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE,xmlLoade d);
//----------------------------------------------------------------------------------------
cube.addEventListener(MouseEvent.CLICK, objectPress );
//cannot assign directly to cube
//----------------------------------------------------------------------------------------
}
private function xmlLoaded(event:Event):void {
xml=XML(event.target.data);
xmlList=xml.children();
var picList:XMLList=xml.pic;//list for pic
cube.name="cube" + i;// set instance name
trace(cube);
cube.x=Math.random() * 960 - 460;
cube.y=Math.random() * 710 - 330;
cube.z=-40;
cube.rotationZ=Math.random() * 360;
scene.addChild(cube);
}
//addEventListener(MouseEvent.CLICK,mousedown);
}
//----------------------------------------------------------------------------------------
private function objectPress( e:MouseEvent ):void {
trace("mouse is click");
}
}
}
This is what I get from tracing the cube
cube0: x:0 y:0 z:0
cube1: x:490 y:14 z:-40
cube2: x:311 y:45 z:-40
cube3: x:-294 y:215 z:-40
cube4: x:24 y:-109 z:-40
If its traced, why its not showing on the stage?
And I can't seems to assign a buttonMode to it. It will somehow assign the buttonMode to the MCs and a Plane i created.
Whats wrong with my code here?
ActionScript Code:
public class pv3d extends Sprite {
private var viewport:Viewport3D;
private var scene:Scene3D;
private var camera:FreeCamera3D;
//private var camera:Camera3D;
private var renderer:BasicRenderEngine;
private var fc3d:FreeCamera3DController;
//----------------------------------------------------------------------------------------
private var p:Plane;
private var xml:XML;
private var xmlList:XMLList;
private var xmlLoader:URLLoader=new URLLoader;
private var pictureArray:Array=new Array;
private var textArray:Array=new Array;
//----------------------------------------------------------------------------------------
private var cube:Cube = new Cube(new MaterialsList({front:new MovieAssetMaterial("surFront",false,true),back:new MovieAssetMaterial("surBack",false,true),right:new MovieAssetMaterial("surRight",false,true),left:new MovieAssetMaterial("surLeft",false,true),top:new MovieAssetMaterial("surTop",false,true),bottom:new MovieAssetMaterial("surBottom",false,true)}), 40, 2, 42, 10, 10, 10);
//----------------------------------------------------------------------------------------
public function pv3d():void {
var base:MovieAssetMaterial=new MovieAssetMaterial("platform");
base.oneSide=false;
base.smooth=true;
//----------------------------------------------------------------------------------------
//primitive = new Plane(material applied to object, width, height, wSegments, hSegments);
p=new Plane(base,1000,750,3,3);
p.x=0;
p.y=0;
p.z=0;
scene.addChild(p);
//----------------------------------------------------------------------------------------
xmlLoader.load(new URLRequest("gallery/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE,xmlLoade d);
//----------------------------------------------------------------------------------------
cube.addEventListener(MouseEvent.CLICK, objectPress );
//cannot assign directly to cube
//----------------------------------------------------------------------------------------
}
private function xmlLoaded(event:Event):void {
xml=XML(event.target.data);
xmlList=xml.children();
var picList:XMLList=xml.pic;//list for pic
cube.name="cube" + i;// set instance name
trace(cube);
cube.x=Math.random() * 960 - 460;
cube.y=Math.random() * 710 - 330;
cube.z=-40;
cube.rotationZ=Math.random() * 360;
scene.addChild(cube);
}
//addEventListener(MouseEvent.CLICK,mousedown);
}
//----------------------------------------------------------------------------------------
private function objectPress( e:MouseEvent ):void {
trace("mouse is click");
}
}
}
This is what I get from tracing the cube
cube0: x:0 y:0 z:0
cube1: x:490 y:14 z:-40
cube2: x:311 y:45 z:-40
cube3: x:-294 y:215 z:-40
cube4: x:24 y:-109 z:-40
If its traced, why its not showing on the stage?