[Papervision3D] Great White and buttonMode
Patrick Matte | BLITZ
PMatte at blitzagency.com
Mon Feb 11 14:25:05 PST 2008
I don't know if there's a way to do it easily...
But you could try to set the viewport's buttonMode property to true when you rollover the buttons and set it to false when you rollout... not sure if it's gonna work though... I never tried it.
BLITZ | Patrick Matte - 310-551-0200 x214
-----Original Message-----
From: papervision3d-bounces at osflash.org [mailto:papervision3d-bounces at osflash.org] On Behalf Of kylebuch8
Sent: Monday, February 11, 2008 2:09 PM
To: papervision3D at osflash.org
Subject: [Papervision3D] Great White and buttonMode
Hi everyone,
I've been searching for a few days on how to set buttonMode to true on
certain cubes within my project and I haven't been able to find an answer.
I'm using code from the Great White branch. I know that I can set the
buttonMode of the viewport to true but I don't want every 3d object to have
the hand cursor on a mouse over.
The gist of my project is that I have five cubes stacked vertically. When
you select a cube, it will move to the right and stop. I would like to set
the buttonMode of the cubes that were not selected to false. Any ideas as to
how I accomplish this?
Thanks,
Kyle
Here's my code in case you want to take a look
package{
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.FreeCamera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.render.BasicRenderEngine;
import caurina.transitions.*;
public class Main extends Sprite
{
private var viewport:Viewport3D;
private var scene:Scene3D;
private var camera:FreeCamera3D;
private var theLight:PointLight3D;
private var shadeMaterial:FlatShadeMaterial;
private var cube:Cube;
private var renderer:BasicRenderEngine;
private var cubeArray:Array = new Array();
public function Main():void
{
init();
}
private function init():void
{
initPapervision();
initObjects();
}
private function initPapervision():void
{
viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false,
true);
// i know this will set the buttonMode to true for all objects within the
viewport,
// but when I select a cube, I want all of the cubes that were not
selected to have
// a buttonMode set to false
viewport.buttonMode = true;
addChild(viewport);
// set up scene and camera
scene = new Scene3D();
camera = new FreeCamera3D();
camera.zoom = 3;
camera.y = 1000;
camera.rotationX = -30;
renderer = new BasicRenderEngine();
// add ENTER_FRAME listener to render the scene
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
// create lighting
theLight = new PointLight3D();
scene.addChild(theLight);
theLight.y = stage.stageHeight;
}
private function initObjects():void
{
// set up shade material
shadeMaterial = new FlatShadeMaterial(theLight, 0x333333, 0x000000);
shadeMaterial.interactive = true;
// create five cubes with materialList
for (var i:Number = 0; i < 5; i++)
{
cube = new Cube(new MaterialsList({all:shadeMaterial}), 300, 300, 300);
scene.addChild(cube);
// position the cube in a stack
cube.y = (i * 400) - 700;
// set the position of the cube to in
cube.extra = {cubePos:"in"};
// add click listener to cube
cube.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, toggler);
// add the cube to the cube array
cubeArray[i] = cube;
}
}
private function toggler(event:InteractiveScene3DEvent):void
{
// if the cube's position is "in", move it out else move it back
if (event.target.extra.cubePos == "in")
{
moveOut(event.target);
}
else
{
moveBack(event.target);
}
}
private function moveOut(object):void
{
// for each cube that was not selected, remove the click event listener
for each (var arrayCube in cubeArray)
{
if (arrayCube != object)
{
arrayCube.removeEventListener(InteractiveScene3DEvent.OBJECT_PRESS,
toggler);
}
}
// move the selected cube out 1000 and rotate 90 degrees once it has
finished moving out
Tweener.addTween(object, {x:1000, time:0.5, transition:"easeInOutSine",
onComplete:rotateCube, onCompleteParams:[object]});
// set the cube's position to "out"
object.extra = {cubePos:"out"};
// move the camera out 1000 and move it the to same y coordinate as the
selected cube
Tweener.addTween(camera, {x:1000, y:object.y, rotationX:0, time:0.5,
transition:"easeInOutSine"});
}
private function moveBack(object):void
{
// for each cube that was not selected, add the click event listener back
for each (var arrayCube in cubeArray)
{
if (arrayCube != object)
{
arrayCube.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS,
toggler);
}
}
// move the selected cube back to 0 and rotate 90 degrees once it has
finished moving back
Tweener.addTween(object, {x:0, time:0.5, transition:"easeInOutSine",
onComplete:rotateCube, onCompleteParams:[object]});
// set the cube's position to "in"
object.extra = {cubePos:"in"};
// move the camera back to its original position
Tweener.addTween(camera, {x:0, y:1000, rotationX:-30, time:0.5,
transition:"easeInOutSine"});
}
private function rotateCube(object):void
{
object.rotationX = 0;
Tweener.addTween(object, {rotationX:90, time:0.5,
transition:"easeOutSine"});
}
private function onEnterFrame(event:Event):void
{
renderer.renderScene(scene, camera, viewport);
}
}
}
--
View this message in context: http://www.nabble.com/Great-White-and-buttonMode-tp15421795p15421795.html
Sent from the Papervision3D mailing list archive at Nabble.com.
_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
More information about the Papervision3D
mailing list