I have done a papervision 3d cube tutorial, which works great, I have the flash movie enmbedded in an html page using:
<script type=“text/javascript” src=“swfobject.js”></script>
<div id=“flashcontent”>
<div align=“center”><a href=“http://www.macromedia.com/go/getflash/” target="_blank">Get Flash</a></div>
<script type=“text/javascript”>
var so = new SWFObject(“myCube.swf”, “cube”, “640”, “400”, “8”, “#000000”);
so.write(“flashcontent”);
</script>
I’m usre you guys have seen the SWFobject thing before, all this works great and the cube works beautifully, I’m using the cube as a kind of navigation menu if you like, when you click on a face it while navigate to another html page of mine (this opens in the current window, not a new window, using this code in flash:
function face3Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.gibsonmedia.co.uk/Photo_Gallery/index.html"),"_self”);
}
Again, this all works great… the problem…
When I navigate back to the page with the 3d cude, the cube does not load…just nothing shows? Any ideas? Something to do with the way the .swf id coded…onload funcction perhaps??
I’m stumped!!!
THanks agian.
[quote=gibry21;2345205]I have done a papervision 3d cube tutorial, which works great, I have the flash movie enmbedded in an html page using:
<script type=“text/javascript” src=“swfobject.js”></script>
<div id=“flashcontent”>
<div align=“center”><a href=“http://www.macromedia.com/go/getflash/” target="_blank">Get Flash</a></div>
<script type=“text/javascript”>
var so = new SWFObject(“myCube.swf”, “cube”, “640”, “400”, “8”, “#000000”);
so.write(“flashcontent”);
</script>
I’m usre you guys have seen the SWFobject thing before, all this works great and the cube works beautifully, I’m using the cube as a kind of navigation menu if you like, when you click on a face it while navigate to another html page of mine (this opens in the current window, not a new window, using this code in flash:
function face3Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.gibsonmedia.co.uk/Photo_Gallery/index.html"),"_self”);
}
Again, this all works great… the problem…
When I navigate back to the page with the 3d cude, the cube does not load…just nothing shows? Any ideas? Something to do with the way the .swf id coded…onload funcction perhaps??
I’m stumped!!!
THanks agian.[/quote]
Hi,
This may be helpful:
I’ve recently done a very similar thing and my cube does not suffer this problem. It just may be that it is indeed somthing to do with the way the webpage code embeds the swf.
So for what it’s worth, here is how I embed my swf:
<div id=“3dDiv1” style=“position:absolute;top:100;left:100;width:0;height:0;visibility:hidden”>
<script language="javascript">
if (AC_FL_RunContent == 0)
{
alert("This page requires AC_RunActiveContent.js.");
}
else
{
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', m_nFlashMovieWidth,
'height', m_nFlashMovieHeight,
'src', 'GW1',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'GW1',
'bgcolor', '#000000' ,
'name', 'GW1',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','always',
'movie', 'GW1',
'salign', ''
); //end AC code
}
</script>
</div>
So as you see, I use AC_RunActiveContent.js and I have my swf on it’s own DIV so I can easily manipulate its position.
Mitch.
Perhaps using th swfObject to embed is outdated now, the reason I use this is because its stops the annoying “click here to activate” when flash appears online.
I also tried using a simpl html page and using the “insert - flash” from the menu, the used a similar technique to yours I believe and used "C_RunActiveContent.js " not actually sure where this file came from, is it created automatically by flash? But I still had the same problem, maybe I should ry that way and remove the swobject.js from my server.
I noticed that in ur div for the cube you have visiblity= hidden…why is this?
Does this code:
‘width’, m_nFlashMovieWidth,
‘height’, m_nFlashMovieHeight
Take the width and height from whatever ur movie is set to?
And finally just so I know what I’m editing, is “GW1” the name of your flash .swf? And do I not have to include the .swf file extension?
This looks like a good way of doing it so I will try (unfortunately at work at the moment, but want to get home and try it out!)
I’ve always being bad at using the positioning tags, am I right saying that what you have positions ur cube 100 px in from the left and 100px down from the top? I want to centre mine so I’m sure I can change that.
Thanks mate. I was going crazy with this!!
Oh yeah…
Do you have a link to your site, would be interested in having a look?
Cheers.
[quote=gibry21;2345488]Oh yeah…
Do you have a link to your site, would be interested in having a look?
Cheers.[/quote]
Hi,
‘width’, m_nFlashMovieWidth,
‘height’, m_nFlashMovieHeight
Are just javascript variables declared at the htop of my webpage code - should come from swf but havn’t finished everything yet.
GW1 is indeed the name of my swf.
My div is positioned at 100,100 and is initially invisible. I have a javascript function for centering the swf (this is called when the page loads (and here after recentering I make div visible) and when the user resizes the browser).
You can check it out and view the javascript here:
http://www.gnits.x10hosting.com/3D/GW1.html
You can drag the cube with left mouse button down.
Click once on the swf to set cube spinning,
Roll mouse wheel to explode/implode the cube.
Let me know if this method of embedding solves your refresh problems.
AC_FL_RunContent also circumvents 'Click here to activate'. swfObject should be fine too - certainly not outdated to my knowledge.
I’m looking into lighting the cube now - not having great success - have you done any lighting in Papervision?
Mitch.
Your site looks good.
Couple of points, looking at your script below…I cant see where it calls your .swf into your div?
I dont know much about javascript so thats whats gettin me I think.
Love what you’ve done with the cube, unfortunately I am just a novice with papervision and have just started playing around with it, to get your cube to only spin on click, was that done in flash?
I would like my cube to spin only when users first mouse over it, perhaps this what be done using a mask or something…again stretching my knowledge!!
I’ll play around, thanks for the help and any more is welsome.
Cheers
hi again…
tried ur code, but no cube showing, here is my html:
<code>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1” />
<title>GibsonMedia - Web Design x IT Support x PC Repairs</title>
<script language=“javascript”>AC_FL_RunContent = 0;</script>
<script src=“AC_RunActiveContent.js” language=“javascript”></script>
<style type=“text/css”>
<!–
body {
background-color: #000000;
margin-top: 100px;
}
–>
</style>
</head>
<body>
<div id=“myCube_div” align=“center”>
<script language=“javascript”>
if (AC_FL_RunContent == 0)
{
alert(“This page requires AC_RunActiveContent.js.”);
}
else
{
AC_FL_RunContent(
‘codebase’, ‘http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0’,
‘src’, ‘myCube’,
‘quality’, ‘high’,
‘pluginspage’, ‘http://www.macromedia.com/go/getflashplayer’,
‘align’, ‘middle’,
‘play’, ‘true’,
‘loop’, ‘true’,
‘scale’, ‘showall’,
‘wmode’, ‘window’,
‘devicefont’, ‘false’,
‘id’, ‘myCube’,
‘bgcolor’, ‘#000000’ ,
‘name’, ‘myCube’,
‘menu’, ‘true’,
‘allowFullScreen’, ‘false’,
‘allowScriptAccess’,‘always’,
‘movie’, ‘GW1’,
‘salign’, ‘’
); //end AC code
}
</script>
</div>
<div align=“center”><img src=“images/gibsonmedia.png”/></div>
</body>
</html>
</code>
Is the “AC_RunActiveContent.js” file specific to my .swf or is it a general piece of js, cos I seem to have the file and presume its correct but doesnt work…
Also what is this doing and do I need it:
<script language=“javascript”>AC_FL_RunContent = 0;</script>
and the “if” statement?
I’m stumped!!
[FONT=Arial]Ok,
I have this one div on may page. It is defined by the
[/FONT][FONT=Arial][COLOR=Green]<div id=“3dDiv1” style=“position:absolute;top:100;left:100;width:0;height:0;visibility:hidden”>
</div>[/COLOR]
[/FONT][FONT=Arial][SIZE=3]Everything between these tags will be on the div. The only thing between these tags is my call to[/SIZE][/FONT][FONT=Arial][COLOR=SeaGreen]AC_FL_RunContent[/COLOR].
[/FONT]
[SIZE=3][FONT=Arial]You won’t find the phrase “swf” anywhere in the code. The [/FONT][/SIZE]
[FONT=Arial][COLOR=SeaGreen]AC_FL_RunContent[/COLOR][/FONT] [SIZE=3][FONT=Arial]function only takes the name of the swf file and not it’s extension - so you will only see reference to “GW1”.
To get my cube to spin when clicked was indeed done in flash - in the acrionscript. When the user presses the left mouse button down I store the x,y coordinates of this.
When they release the button I look to see if the coordinates of this are the same - if they are NOT then the user is dragging the cube, if they are then they have not dragged only clicked.
To get your cube to spin when the user first moves the mouse over it you can either catch the mousemove of the swf (thus the cube will spin when the user moves their mouse over ANY part of the stage) or you
can use the papervision InteractiveScene3DEvent.OBJECT_MOVE event on the cube. This way the cube will only rotate if the user moves the mouse over the cube and no other part of the stage. Say your cube is called Cube1 then
you would call:
Cube1.addEventListener([/FONT][/SIZE][SIZE=3][FONT=Arial]InteractiveScene3DEvent.OBJECT_MOVE,objectMove);
and then define the function objectMove like:
function objectMove(e:InteractiveScene3DEvent):void
{
// your code
}
[/FONT][/SIZE]As a starting point for getting your cube to show, if you just point your browser to your swf file directly does it show then?
If not then the problem is with the swf. If it does then the problem is with the embedding html. Flash AS3 will publish a basic HTML container - does that work? (It had better!)
If all this works then you know your html/javascript is in error.
AC_RunActiveContent.js is a generic file.
AC_FL_RunContent is defined inside that js file. If that file is not found then
the line:
<script language=“javascript”>AC_FL_RunContent = 0;</script>
will ensure that AC_FL_RunContent IS deined but equal to zero on your page.
You test for this later. You say IF AC_FL_RunContent == 0 then tell the user that the js
file was not found. Without this your page would just be blank with no explanation.
Mitch.
I manged to sort the problme before your last post, it was something to do with js I think, but its all good now.
However, regarding th spinning when mouse in, great thanks for…
To use the “[FONT=Arial][SIZE=3]InteractiveScene3DEvent.OBJECT_MOVE” are you saying I add that into my flash action script, or in mhtml as a java function?[/SIZE][/FONT]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
[FONT=Arial][SIZE=3]I tried manipulation my action script but got an error, thats what got me thinkin maybe its java function![/SIZE][/FONT]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
[FONT=Arial][SIZE=3]Or do I have to import something else from Papervision?[/SIZE][/FONT]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
[FONT=Arial][SIZE=3]This is my action script, (with old code that works commented out):[/SIZE][/FONT]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
[COLOR=silver]/addEventListener(Event.ENTER_FRAME, loop);[/COLOR]
[COLOR=silver]function loop(e:Event):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}[/COLOR]
[COLOR=silver]/[/COLOR]
[COLOR=red]addEventListener(InteractiveScene3DEvent.OBJECT_MOVE,objectMove);[/COLOR]
[COLOR=red][/COLOR]
[COLOR=red]function objectMove(e:InteractiveScene3DEvent):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}[/COLOR]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
[FONT=Arial][SIZE=3]Any ideas…at the moment when I test no cube on stage.[/SIZE][/FONT]
[FONT=Arial][SIZE=3][/SIZE][/FONT]
Sorry again…
Just had a thought, when you said catch the “mouseover” of the swf… you mean use js or html to play the .swf when the user mouse overs?
Is that possible?
This is what I would do for simplicity.
Comment back in the code you had previously which worked and modify the body of your [COLOR=red]objectMove [COLOR=Black]function so that it just looks like this:
[/COLOR][/COLOR][COLOR=red]addEventListener(InteractiveScene3DEvent.OBJECT_MO VE,objectMove);[/COLOR]
[COLOR=red]function objectMove(e:InteractiveScene3DEvent):void
{
trace(“Hello”);
}
[/COLOR] Now run your swf. This will test if the objectMove method is being called. REMEMBER, when you create your new cube in your flash code, the first parameter you pass is a material, say it’s called mat1, then you must have mat1.interactive = true.
Once you get the trace message appearing whenever you roll over the cube then you know it’s working. Next I woulod have a global variable called say
var:m_bCanRotate = false;
And then modify your code to the below:
[COLOR=Red]addEventListener(Event.ENTER_FRAME, loop);
[/COLOR] [COLOR=Red]function loop(e:Event):void
{
if(m_bCanRotate)
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
}
renderer.renderScene(scene, camera, viewport);
}[/COLOR]
[COLOR=red]addEventListener(InteractiveScene3DEvent.OBJECT_MOVE,objectMove);[/COLOR]
[COLOR=red]function objectMove(e:InteractiveScene3DEvent):void
{
m_bCanRotate = true;
}
[COLOR=Black]So now, your cube will only begin rotating once the mouse has been moved over it.[/COLOR]
[/COLOR]
[quote=gibry21;2345756]Sorry again…
Just had a thought, when you said catch the “mouseover” of the swf… you mean use js or html to play the .swf when the user mouse overs?
Is that possible?[/quote]
This is certainly possible. If you want the rotation to start only when the user rolls over the cube (and not any other part of the stage) then the method I just posted is what you need.
Communication between the flash and javascript of the web page is easily acheived throught flash’s ExternalInterface methods. If you’ve never used that I’d start by Googleing it - it is very straightforward.
With this you can call methods of the flash swf directly from javascript and the other way around - very very useful.
Infact, if you look in the code of my cube page you’ll see that when the flash movie calls the FlashReady function I call SetBorderColour. This function calls a method in my flash code which sets the border colour of the swf to the same as the background of the webpage. This is great because I can simply change the colour of the background of the webpage in HTML and the flash will follow to match without me having change and re-publish the swf. (I sorted out lighting on the cube too at last!).
I will try your first post first and see how I get on. Not that confident I’ll manipulate the code correctly but I’ll give it a shot!
With regards to the javscript stuff loading flash, are you suggesting I create a “stop” on my flash, then great a “start” function and then call this start function using java when somebody mouse over the swf?
Am i getting that right? ha, ha
Your lighting looks great, did you see a tutorial for that?
Do I have to import anything more into my flash from Papervision in order for this “[COLOR=#ff0000]InteractiveScene3DEvent” to work??[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000]THanks again for your speedy and in depth help.[/COLOR]
[COLOR=#ff0000][/COLOR]
No worries.
import.org.papervision3d.events.InteractiveSceene3DEvent
I couldn’t find a lighting tutorial that covered what I needed in a clear enough manner - so I read what I could and spent around 4 hours playing with everything until I finally understood it.
You could indeed have start/stop functions to start/stop your swf from javascript.
I have tried everything you said, and I’m able to compile my code with no errors ( as long as I dont add the “import.org.paper…”, however when I publish I am getting error messages, which I’m sure related to not known what the class is or perhaps a clash of classes!! Its driving me crazy and now I’ve started I really want to get this to work, so the cube only starts spinning when the user enters it, however I still want the user to have full control of the cube using the mouse control… here is my entire code thats works ( ur additions have been commented out)…help!!!
<code>
import org.papervision3d.scenes.;
import org.papervision3d.cameras.;
import org.papervision3d.objects.;
import org.papervision3d.objects.special.;
import org.papervision3d.objects.primitives.;
import org.papervision3d.materials.;
import org.papervision3d.materials.special.;
import org.papervision3d.materials.shaders.;
import org.papervision3d.materials.utils.;
import org.papervision3d.lights.;
import org.papervision3d.render.;
import org.papervision3d.view.;
import org.papervision3d.events.;
import org.papervision3d.core.utils.;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;
[COLOR=gray]//import.org.papervision3d.events.InteractiveScene3DEvent.*;[/COLOR]
var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
addChild(viewport);
viewport.buttonMode = true;
var renderer:BasicRenderEngine = new BasicRenderEngine();
var scene:Scene3D = new Scene3D();
var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100;
var mam:MovieMaterial = new MovieMaterial(face);
mam.interactive = true;
mam.smooth = true;
mam.animated = true;
var mam2:MovieMaterial = new MovieMaterial(face2);
mam2.interactive = true;
mam2.smooth = true;
mam2.animated = true;
var mam3:MovieMaterial = new MovieMaterial(face3);
mam3.interactive = true;
mam3.smooth = true;
mam3.animated = true;
var mam4:MovieMaterial = new MovieMaterial(face4);
mam4.interactive = true;
mam4.smooth = true;
mam4.animated = true;
var mam5:MovieMaterial = new MovieMaterial(face5);
mam5.interactive = true;
mam5.smooth = true;
mam5.animated = true;
var mam6:MovieMaterial = new MovieMaterial(face6);
mam6.interactive = true;
mam6.smooth = true;
mam6.animated = true;
var cube:Cube = new Cube(new MaterialsList({front:mam, back:mam2, left:mam3, right:mam4,top:mam5, bottom:mam6}), 200, 200, 200, 10, 10, 10);
scene.addChild(cube);
addEventListener(Event.ENTER_FRAME, loop);
[COLOR=gray]/** as far as I understand the code, its the code below that controls the cube movement depending on the distance from the pointer to the centre, so I dont wont this function to start untill the user first enters the cube **[/COLOR]
function loop(e:Event):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}
[COLOR=gray]/[/COLOR]
[COLOR=gray]addEventListener(InteractiveScene3DEvent.OBJECT_MOVE,objectMove);[/COLOR]
[COLOR=gray]function objectMove(e:InteractiveScene3DEvent):void
{
trace(“Hello”);
}[/COLOR]
[COLOR=gray]/[/COLOR]
face.addEventListener(MouseEvent.CLICK, faceClick);
function faceClick(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.yahoo.com”));
}
face2.addEventListener(MouseEvent.CLICK, face2Click);
function face2Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.google.com”));
}
face3.addEventListener(MouseEvent.CLICK, face3Click);
function face3Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.gibsonmedia.co.uk/Photo_Gallery/index.html"),"_self”);
}
face4.addEventListener(MouseEvent.CLICK, face4Click);
function face4Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.youtube.com”));
}
face5.addEventListener(MouseEvent.CLICK, face5Click);
function face5Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.facebook.com”));
}
face6.addEventListener(MouseEvent.CLICK, face6Click);
function face6Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.adobe.com”));
}
</code>
Sorry again…I’m sure you have better things to do!!!
[quote=gnitsuk;2346292]No worries.
import.org.papervision3d.events.InteractiveSceene3DEvent
I couldn’t find a lighting tutorial that covered what I needed in a clear enough manner - so I read what I could and spent around 4 hours playing with everything until I finally understood it.
You could indeed have start/stop functions to start/stop your swf from javascript.[/quote]
I can get it to run now, but the compile error I get is something to do with not being able to convert mouse events to import.org.papervision3d.events.InteractiveScene3DEvent!!?
Perhaps this is not worth it…if you could help me with a simple function that I could call using java, so that when a user entered my .swf on the page, then it calls a function that starts the cube spinning!!
I’m going crazy with what is such a simple thing, and I cant find anybody or any reference to this online…hence why your my only hope!! lol
Well start with this.
This code
face4.addEventListener(MouseEvent.CLICK, face4Click);
function face4Click(e:MouseEvent):void
{
navigateToURL(new URLRequest(“http://www.youtube.com”));
}
sould be:
face4.addEventListener(InteractiveScene3DEvent.OBJECT.CLICK, face4Click);
unction face4Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.youtube.com”));
}
so everywhere that you had MouseEvent you should have had InteractiveScene3DEvent. This is the source of your “Not able to convert” error.
Right, cant wait to get home and try that, I was at my wits end!!!
Will leave the “[COLOR=#808080]//import.org.papervision3d.events.InteractiveScene3D Event.*;”[/COLOR][COLOR=black] commented out and test aswell asthis seemed to give me problems. [/COLOR]
Fingers crossed.
Thanks again for your patience.
[quote=gibry21;2347547]Right, cant wait to get home and try that, I was at my wits end!!!
Will leave the “[COLOR=#808080]//import.org.papervision3d.events.InteractiveScene3D Event.*;”[/COLOR][COLOR=black] commented out and test aswell asthis seemed to give me problems. [/COLOR]
Fingers crossed.
Thanks again for your patience.[/quote]
[COLOR=Black]The following line is wrong too:
[/COLOR][COLOR=#808080]import.org.papervision3d.events.InteractiveScene3D Event.*;
[COLOR=Black]it should be
[/COLOR][/COLOR][COLOR=#808080]import org.papervision3d.events.InteractiveScene3DEvent;[/COLOR]
[COLOR=#808080][COLOR=Black][/COLOR][/COLOR]
Right, having made the changes you suggested, I no longer get any errors, however, by changing my MouseEvent to Interactive…, none of my face click links work. Also the trace function is showing nothing, so with the following cude, the cube spins as before but nothing is clickable or interactable…which is a step back from where i was before!!
<code>
import org.papervision3d.scenes.;
import org.papervision3d.cameras.;
import org.papervision3d.objects.;
import org.papervision3d.objects.special.;
import org.papervision3d.objects.primitives.;
import org.papervision3d.materials.;
import org.papervision3d.materials.special.;
import org.papervision3d.materials.shaders.;
import org.papervision3d.materials.utils.;
import org.papervision3d.lights.;
import org.papervision3d.render.;
import org.papervision3d.view.;
import org.papervision3d.events.;
import org.papervision3d.core.utils.;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;
import org.papervision3d.events.InteractiveScene3DEvent;
var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
addChild(viewport);
viewport.buttonMode = true;
var renderer:BasicRenderEngine = new BasicRenderEngine();
var scene:Scene3D = new Scene3D();
var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100;
var mam:MovieMaterial = new MovieMaterial(face);
mam.interactive = true;
mam.smooth = true;
mam.animated = true;
var mam2:MovieMaterial = new MovieMaterial(face2);
mam2.interactive = true;
mam2.smooth = true;
mam2.animated = true;
var mam3:MovieMaterial = new MovieMaterial(face3);
mam3.interactive = true;
mam3.smooth = true;
mam3.animated = true;
var mam4:MovieMaterial = new MovieMaterial(face4);
mam4.interactive = true;
mam4.smooth = true;
mam4.animated = true;
var mam5:MovieMaterial = new MovieMaterial(face5);
mam5.interactive = true;
mam5.smooth = true;
mam5.animated = true;
var mam6:MovieMaterial = new MovieMaterial(face6);
mam6.interactive = true;
mam6.smooth = true;
mam6.animated = true;
var cube:Cube = new Cube(new MaterialsList({front:mam, back:mam2, left:mam3, right:mam4,top:mam5, bottom:mam6}), 200, 200, 200, 10, 10, 10);
scene.addChild(cube);
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}
addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,objectClick);
function objectClick(e:InteractiveScene3DEvent):void
{
trace(“Hello”);
}
face.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, faceClick);
function faceClick(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.yahoo.com”));
}
face2.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, face2Click);
function face2Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.google.com”));
}
face3.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, face3Click);
function face3Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.gibsonmedia.co.uk/Photo_Gallery/index.html"),"_self”);
}
face4.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, face4Click);
function face4Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.youtube.com”));
}
face5.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, face5Click);
function face5Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.facebook.com”));
}
face6.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, face6Click);
function face6Click(e:InteractiveScene3DEvent):void
{
navigateToURL(new URLRequest(“http://www.adobe.com”));
}
</code>
Is the OBJECT_CLICK correct?
And do I not need my mouse events to make my navigation work?
What you think? I wouldn’t have thought I would have to had changed any of the code for the faces as they worked fine, I thought maybe it would be this code:
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}
Maybe change the ENTER_FRAME, to a differnt function or are you trying to make it so that when a user interacts with any of the faces using a mouseover it starts the loop function, I dont want the user to have to click, apart from to navigate to the url’s (obviously!!)
ARGGGGGGGHHHHHHHHHHHHHHHHH!!!
Sorry!!