RedSuns
10-03-2008, 10:57 PM
Hey there, new to these forums.
Anyway, I'm pretty new to papervision and AS3, so forgive me if this is a dumb question.
So far I am trying to make a 3D Menu, which consists of a lot of duplicated planes with movieclips assigned as a material. These planes need to be structured in some sort of grid pattern and load in images through dynamic instance names through xml.
anyway, is the best way to achieve the grid and xml loading by using arrays to give each duplicate an instance name??? then matching it up with the xml?
Also really need help with making a camera that zooms in on and targets the plane that has been clicked..
anyone have some code that could create this effect please????
thanks.
this is my code below:
//-----------IMPORT PV3D-------------//
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import caurina.transitions.Tweener;
//-----------DEFINE VARIABLES --------//
var container:Sprite=new Sprite();
container.x=stage.stageWidth*0.5;
container.y=stage.stageHeight*0.5;
addChild(container);
var scene:Scene3D=new MovieScene3D(container);
var camera:Camera3D = new Camera3D();
camera.x = 0;
camera.y = 0;
camera.zoom=5;
var material:MovieAssetMaterial = new MovieAssetMaterial("F");
material.oneSide=false;
material.smooth=true;
var itemWidth:int;
itemWidth += 200;
var itemDistance:int
itemDistance += 10;
var columnAmount:int
columnAmount = 4;
var iTest:int
iTest = 0
var mcArray:Array = new Array();
mcArray[i] = p;
//--------------PLANE CONSTRUCTOR/ADD TO SCENE---------------//
var myPlaneDictionary:Dictionary=new Dictionary();
for (var i:uint=0; i<50; i++) {
container.getChildByName(name)
var p:Plane=new Plane(material,itemWidth,200,2,2);
scene.addChild(p);
p.x = (itemWidth + itemDistance) * iTest;
iTest ++;
//----------USE THE CONTAINER SPRITE PROPERTY FOR PLANE-----------//
//----------CONTAINER AS KEY AND PLANE AS VALUE-------------------//
var myPlaneContainer:Sprite = p.container;
myPlaneDictionary[myPlaneContainer]=p;
myPlaneContainer.buttonMode = true;
//-----------DEFINE MOUSE EVENTS----------------------------------//
myPlaneContainer.addEventListener( MouseEvent.ROLL_OVER, doRollOver );
myPlaneContainer.addEventListener( MouseEvent.CLICK, clicker );
myPlaneContainer.addEventListener( MouseEvent.ROLL_OUT, doRollOut );
}
//------------------DEFINE MOUSE EVENT FUNCTIONS---------------------//
//USE THE CONTAINER SPRITE TO CHANGE ALPHA, NOT THE PLANE ITSELF
function doRollOver(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 0.5;
}
function doRollOut(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 1;
}
//we have our index value ( container sprite )
//we use the value to retrieve the correct plane
function clicker(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
var p:Plane=myPlaneDictionary[sprit]
var newY:int = p.rotationY+180;
Tweener.addTween( camera, {zoom: 6, time: 2} );
Tweener.addTween(p,{rotationY:newY,time:1,transiti on:"easeoutquint"});
}
//------------------------------CAMERAS----------------------------------//
this.addEventListener(Event.ENTER_FRAME,render);
function render(e:Event):void {
Tweener.addTween(camera,{x:stage.mouseX-(stage.stageWidth),time:2,transition:"easeoutquint"});
Tweener.addTween(camera,{y:stage.mouseY-(stage.stageHeight),time:2,transition:"easeoutquint"});
scene.renderCamera(camera);
}
Anyway, I'm pretty new to papervision and AS3, so forgive me if this is a dumb question.
So far I am trying to make a 3D Menu, which consists of a lot of duplicated planes with movieclips assigned as a material. These planes need to be structured in some sort of grid pattern and load in images through dynamic instance names through xml.
anyway, is the best way to achieve the grid and xml loading by using arrays to give each duplicate an instance name??? then matching it up with the xml?
Also really need help with making a camera that zooms in on and targets the plane that has been clicked..
anyone have some code that could create this effect please????
thanks.
this is my code below:
//-----------IMPORT PV3D-------------//
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import caurina.transitions.Tweener;
//-----------DEFINE VARIABLES --------//
var container:Sprite=new Sprite();
container.x=stage.stageWidth*0.5;
container.y=stage.stageHeight*0.5;
addChild(container);
var scene:Scene3D=new MovieScene3D(container);
var camera:Camera3D = new Camera3D();
camera.x = 0;
camera.y = 0;
camera.zoom=5;
var material:MovieAssetMaterial = new MovieAssetMaterial("F");
material.oneSide=false;
material.smooth=true;
var itemWidth:int;
itemWidth += 200;
var itemDistance:int
itemDistance += 10;
var columnAmount:int
columnAmount = 4;
var iTest:int
iTest = 0
var mcArray:Array = new Array();
mcArray[i] = p;
//--------------PLANE CONSTRUCTOR/ADD TO SCENE---------------//
var myPlaneDictionary:Dictionary=new Dictionary();
for (var i:uint=0; i<50; i++) {
container.getChildByName(name)
var p:Plane=new Plane(material,itemWidth,200,2,2);
scene.addChild(p);
p.x = (itemWidth + itemDistance) * iTest;
iTest ++;
//----------USE THE CONTAINER SPRITE PROPERTY FOR PLANE-----------//
//----------CONTAINER AS KEY AND PLANE AS VALUE-------------------//
var myPlaneContainer:Sprite = p.container;
myPlaneDictionary[myPlaneContainer]=p;
myPlaneContainer.buttonMode = true;
//-----------DEFINE MOUSE EVENTS----------------------------------//
myPlaneContainer.addEventListener( MouseEvent.ROLL_OVER, doRollOver );
myPlaneContainer.addEventListener( MouseEvent.CLICK, clicker );
myPlaneContainer.addEventListener( MouseEvent.ROLL_OUT, doRollOut );
}
//------------------DEFINE MOUSE EVENT FUNCTIONS---------------------//
//USE THE CONTAINER SPRITE TO CHANGE ALPHA, NOT THE PLANE ITSELF
function doRollOver(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 0.5;
}
function doRollOut(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 1;
}
//we have our index value ( container sprite )
//we use the value to retrieve the correct plane
function clicker(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
var p:Plane=myPlaneDictionary[sprit]
var newY:int = p.rotationY+180;
Tweener.addTween( camera, {zoom: 6, time: 2} );
Tweener.addTween(p,{rotationY:newY,time:1,transiti on:"easeoutquint"});
}
//------------------------------CAMERAS----------------------------------//
this.addEventListener(Event.ENTER_FRAME,render);
function render(e:Event):void {
Tweener.addTween(camera,{x:stage.mouseX-(stage.stageWidth),time:2,transition:"easeoutquint"});
Tweener.addTween(camera,{y:stage.mouseY-(stage.stageHeight),time:2,transition:"easeoutquint"});
scene.renderCamera(camera);
}