Interactive Materials Video Demo

I did a similar demo at the RMI classes in Toronto this last weekend and some of the students asked if I would post notes or a tutorial online about how to do this. So, here’s a quick 5 minute demo on how to make a movie, add some components, and with minimal code, make it interactive on a 3D object.

This demo was done with the new Papervision3D 1.9 and the InteractiveSceneManager, but it would work with 1.5 and the current ISM nearly the same way.

Here’s the code:
[as]
import org.papervision3d.objects.Plane;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.FreeCamera3D;

// create Sprite container to draw into, add to stage and center
var container:Sprite = new Sprite();
addChild(container);
container.x = stage.stageWidth * .5;
container.y = stage.stageHeight * .5;

// create Scene3D and Camera – pass ‘true’ as the 2nd argument to make the scene interactive
var scene:Scene3D = new Scene3D(container, true)
var camera:FreeCamera3D = new FreeCamera3D();
camera.zoom = 11;

// create MovieMaterial to use on the Plane object
var material:MovieMaterial = new MovieMaterial(movieSkinContainer, true, true);
// make the material interactive
material.interactive = true ;
material.oneSide = false;
material.smooth = true;

// create the plane to the same dimensions as the movieclip
var plane:Plane = new Plane(material, 250, 250, 10, 10);

// add to the Scene3D
scene.addChild(plane);

// add listener for ENTER_FRAME to render the scene
addEventListener(Event.ENTER_FRAME, handleEnterFrame);

function handleEnterFrame(e:Event):void
{
// rotate the scene on the y axis
plane.yaw(.2);

// render scene
scene.renderCamera(camera);
}
[/as]

Get the FLA and make sure you're sync'd up with the Phunky branch in the google code repository

  1. Hi Guys! Shooting a video!😉 Great work john!

  2. Thanks Ralph😉

    For anyone that was not able to view the video, I had to move it to another server. It’s up and running now.

    I hit Jing’s bandwidth limit for a month in less than an hour🙂

  3. Sweet stuff! This really opens a whole new realm of possibilities!

    • kan
    • September 20th, 2007

    Thanks John..
    very useful video!!🙂

    • Mike
    • September 20th, 2007

    Splendid, thanks so much – rockOnFlash is a beacon for me in these trepidous expeditions into the future… Also great to hear you being a family-type man, very human touch, love it. !

    • Steve
    • September 20th, 2007

    thanks

    i get an error compiling that ISMPlaneDemo.fla:

    1061: Call to a possibly undefined method drawFace3D through a reference with static type org.papervision3d.core.proto:MaterialObject3D.

    i didnt change anything… i sync’d with that phunky branch..
    flash hates me😦

  4. Hey Steve, go into publish setting and change the class path to where ever you have phunky located. If that doesn’t work, let me know

  5. Nice video. Good for begginers!

  6. Nice video, thanks a lot ! But I’ve got a problem at compilation too… I have the latest revision (247) from the repository, and I’ve got two errors : 1137, incorrect number of arguments, 1 expected and 1119, interactive property undefined

  7. (it’s about line 11 : var scene:Scene3D = new Scene3D(container, true)) and line 17 : material.interactive = true😉

    • Steve
    • September 20th, 2007

    thanks! everything works finde now : )

  8. Sorry😉 My fault : I don’t use the right revision

  9. 😉 \m/

    • beedee
    • September 20th, 2007

    Works pretty well for me, but is there a way to get the interactive material to use the hand cursor over clickable items?

  10. just set buttonMode on the sprite container that you use with Scene3D to true

    var container:Sprite = new Sprite();
    container.buttonMode = true;

  11. Hi John,

    When I run your tute everything works A OK. When I run it using my own mc it gives me this error:

    Papervision3D Beta 1.9 – PHUNKY (20.09.07)

    DisplayObject3D: null
    renderer? true
    DisplayObject3D: null
    ArgumentError: Error #2015: Invalid BitmapData.
    at flash.display::BitmapData$iinit()
    at org.papervision3d.materials::MovieMaterial/org.papervision3d.materials:MovieMaterial::initBitmap()
    at org.papervision3d.materials::MovieMaterial/org.papervision3d.materials:MovieMaterial::createBitmapFromSprite()
    at org.papervision3d.materials::MovieMaterial/set texture()
    at org.papervision3d.materials::MovieMaterial$iinit()
    at landscapeTimeline_fla::MainTimeline/landscapeTimeline_fla::frame1()

    Do you have any insight into what may be going on?

    TIA,

    Noah

    • noah aronsson-Brown
    • September 21st, 2007

    Hi again John, so I finally figured it out! Seems like a strange bug where if the Movieclip you are using contains a lot of text elements (like a resume or something) pv3d cannot handle it and craps out. If I delete all that text (but leave a 50pt headline!) then it renders just fine. Hmmm. If you would like to see the files email me and I’ll pass them on.

    Thanks for all your fantastic work on this and pv3d in general.

    • Vic Cekvenich
    • September 24th, 2007

    Flex question, how would I do this in Flex?
    MovieMaterial and pass it a canvas w/ a text area on it?
    This does not work (but it can show color, not a “movie”):
    var c:Canvas = new Canvas();
    var ta:TextArea = new TextArea();
    ta.text=”hello world”;
    c.addChild(ta);
    var mate:MovieMaterial = new MovieMaterial(c);
    plane = new Plane(mate,3000,3000);

    It shows nothing… (but if I make it a Color material it works).

    Hint?
    (thx for the help so far!!)
    tia,
    .V

    • Garlon
    • September 25th, 2007

    Hi John,

    I’ve been noticing your work here with papervision and it’s phenomonal! Especially the drums! I’ve also been keeping up with the updates on Papervision via the SVN client and noticed there’s a shadingmaterial finally! I tried using it but couldn’t get it to work. Have you played around with that yet and produced any examples! I’m not that great in texturing in 3DS because I rarely used it before I noticed 3D engines for flash just a couple of months ago. I tried using Sandy before and they have shading/light already built into it, although the updates are very very slow and Papervision has far more people working on it as well.

    Thanks for all your awesome demos!

    • Rex Raptor
    • September 26th, 2007

    Thank you so much for this tutorial! I’ve been trying for weeks to create an interactive cube with no luck and this made it super easy!

    Just incase anybody else out there is trying to make an interactive cube I’m posting my code modifications below.
    Thanks again!

    //import org.papervision3d.objects.Plane;
    import org.papervision3d.objects.Cube;
    import org.papervision3d.materials.MaterialsList;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.cameras.FreeCamera3D;

    var container:Sprite = new Sprite();
    addChild(container);
    container.x = stage.stageWidth * .5;
    container.y = stage.stageHeight * .5;

    var scene:Scene3D = new Scene3D(container, true);
    var camera:FreeCamera3D = new FreeCamera3D();
    camera.zoom = 11;

    var material:MovieMaterial = new MovieMaterial(movieSkinContainer, true, true);
    material.interactive = true ;
    material.oneSide = true;
    material.smooth = true;

    var materials:MaterialsList = new MaterialsList(
    {
    //all:
    back: material,
    front: material,
    right: material,
    left: material,
    top: material,
    bottom: material
    } );

    //var plane:Plane = new Plane(material, 250, 250, 10, 10);

    //scene.addChild(plane);

    var cube:Cube = new Cube(materials, 250, 250,250, 10, 10, 10);

    scene.addChild(cube);

    //this.addChild(movieSkinContainer);
    //this.movieSkinContainer.x = 200;

    addEventListener(Event.ENTER_FRAME, handleEnterFrame);

    function handleEnterFrame(e:Event):void {
    cube.yaw(.2);
    scene.renderCamera(camera);
    }

    • Rex Raptor
    • September 26th, 2007

    You can use the code I posted for adding different movie clips to different sides of the cube but there’s one VERY VERY IMPORTANT STEP-the movie clips have to all be aligned to the upper left of the stage!

    Crazy!

    • Magnus
    • September 27th, 2007

    Hi John, thanx for a great tutorial!

    I have one problem, when I use your .fla I get interaction but if I copy your code and make my own movieSkinContainer, I get no interaction. You have any idea what I am doin wrong?
    Thanx in advance

  12. @Magnus: Check to make sure –

    1. movieclip is on stage
    2. it’s in the upper left corner at 0,0
    3. you’re using MovieMaterial rather than MovieAssetMaterial

    • Rose
    • October 1st, 2007

    This is quite possibly the coolest thing I have ever played with. You have made available the exact information I was looking for…but I can’t quite make it work. It doesn’t like the event listeners or the get child by name. My errors all say “access of undefined property scene3D”. I am trying to get mouse events, I paste the code from the awesome new button. Is it the class path…what is the correct class path?

    • Nao
    • October 1st, 2007

    The demo looks great. Somehow, it doesn’t work. It gives me a error when I compile it.

    TypeError: Error #1034: Type Coercion failed: cannot convert org.papervision3d.core.geom::Vertex3D@397f911 to org.papervision3d.core.geom.renderables.Vertex3D.

    On the output, it says “Papervision3D Beta 1.9 – PHUNKY (20.09.07)”
    So I guess papervision is working but hmmm.
    Does anybody know why?

    Thank you

    • Josh
    • October 4th, 2007

    What is the direct link to down PV3D 1.9? At google the newest they have is 1.5.

    Thanks

    • a_[w]
    • October 4th, 2007

    Hi!
    I am trying to add flash.display.SimpleButton object in your example. Button is not properly working, not working HitTest state and Over, Out, Down not appear.
    Even if after event MouseEvent.* call function MovieMaterial.updateBitmap ();

    Thanks for great work!

  13. @ a_[w]: yeah, you can’t use SimpleButton – VirtualMouse doesn’t work with that object. use a regular Button object instead or a MovieClip/Sprite

  14. @ Josh – yeah we’re not putting a 1.9 zip up until we release 2.0

    If you want to use 1.9 (Phunky), you need to sync with the svn repository on googlecode.

    • a_[w]
    • October 4th, 2007

    The code in the first frame of “movieSkin” symbol:
    import flash.geom.*;
    import flash.events.*;
    import flash.display.*;
    var d:DisplayObject = btn.upState;
    function onMDown(e:MouseEvent):void{
    trace(‘down’);
    btn.upState = btn.downState;
    this.refresh();
    }
    btn.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);
    function onMUp(e:MouseEvent):void{
    trace(‘up’);
    var x:Number = btn.mouseX;
    var y:Number = btn.mouseY;
    var b:Rectangle = btn.getBounds(btn);
    if(xb.width+b.x || y>b.height+b.y){
    btn.upState = btn.overState;
    }else btn.upState = d;
    this.refresh();
    }
    btn.addEventListener(MouseEvent.MOUSE_UP, onMUp);
    function onMOver(e:MouseEvent):void{
    trace(‘over’);
    btn.upState = btn.overState;
    this.refresh();
    }
    btn.addEventListener(MouseEvent.ROLL_OVER, onMOver);
    function onMOut(e:MouseEvent):void{
    trace(‘out’);
    btn.upState = d;
    this.refresh();
    }
    btn.addEventListener(MouseEvent.ROLL_OUT, onMOut);
    function refresh():void{
    var r:MovieClip = this.root as MovieClip;
    r.material.updateBitmap();
    }

    btn – instance of flash.display.SimpleButton inside of movieSkin.
    Do you think that will work if create Manager button, which would record all the buttons inside texture and change of buttons on the event?

    • Bijan
    • October 6th, 2007

    Hi! Great work!

    I wonder how to sync with the svn repository on googlecode?

    I have version 1.5 and it doesnt work.

    Thanks

  15. good
    very useful!
    May I ask when can download PV3D 1.9?
    Thanks

    • a_[w]
    • October 6th, 2007
    • Jing
    • October 9th, 2007

    hi
    I am using version 1.5 but got errors:
    please tell me whats wrong?

    Thanks~~

    1137: Incorrect number of arguments. Expected no more than 1.
    1119: Access of possibly undefined property interactive through a reference with static type org.papervision3d.materials:MovieMaterial.

  16. You need to sync with the repository and use the Phunky branch (1.9)

    • Jing
    • October 9th, 2007

    thanks! it works like a charm now.

    • Jing
    • October 9th, 2007

    one more question…why could’t i find InteractiveScene3D in v1.9? did i miss something?
    Thanks

  17. There is no more InteractiveScene3D = its just regular Scene3D, but in the new Constructor, pass a second argument to make it interactive:

    scene3d:Scene3D = new Scene3D(container, true);

    then, whatever materials you create, set the “interactive” flag to true, and it’ll work

    • Jing
    • October 9th, 2007

    Thanks!!
    so…InteractiveSprite is replaced by …?
    thanks again for answering my newbie questions🙂

    • Mika
    • October 15th, 2007

    Fantastic!
    About the buttonMode property … if we add the line as you suggested:
    container.buttonMode = true;
    The entire container/plane receives the cursor, and not just the interactive elements.
    Would one have to use a Mouse.hide() and use a custom hand cursor instead?

    • David
    • October 23rd, 2007

    Hi John. This is fantastic. I have one little issue though…

    When I try to recreate this, I get the following error:
    Vertices3D.as, Line 123
    1000: Ambiguous reference to Vertex3D.
    I took a look at the Vertices3D class, but I’m still pretty new to AS3, so I’ve had no luck debugging this. Any insites would be greatly appreciated.

    Cheers,
    David

    • Johnny
    • October 29th, 2007

    David & People,
    For the 1000: “Ambiguous reference to Vertex3D” problem:

    Make sure you don’t have a double reference to both 1.5 and 1.9 Papervision versions. I had papervision 1.5 in my global references (Prefereces, Actionscript, ActionScript 3.0 settings ) .

    Removed it and the 1.9 worked fine.

    • andrew
    • October 31st, 2007

    Hello ..here’s andrew from Italy..i tried to use the interactive movie asset material with a cube but for some reasons it wont work ..i’ve created 4 movie assets material and add listeners to them : backI.movie.addEventListener(MouseEvent.CLICK, handleMainClick); then created a materialList and added the movie assets: var materials:MaterialsList = new MaterialsList(
    {
    front: frontI,
    back: backI,
    right: sideI,
    left: sideI,
    top: upI,
    bottom: upI
    });
    then added the materiallist to the cube…
    what i’ve done wrong?
    thank u

    • Wim Taring
    • November 3rd, 2007

    Hey i am having some trouble and whatever i do i cant seem to make it work. I have a scene with 5 planes in it to make a sort of menu. i need to make the planes clickable. planes are named plane1 plane2 plane 3 etc how can i do it? I can make the whole scene clickable with container.addEventListener(MouseEvent.MOUSE_UP,buttonPressed); but how can i get just the planes to work?

    • andrew
    • November 4th, 2007

    no one can answer me?😦

    • andrea
    • November 5th, 2007

    wha about creating something like that using a movieclip from the library rather than one on stage?

    • greg
    • November 6th, 2007

    i am getting the ambiguous reference to vertex problem too, have cleared out all of my references to previous versions, tried different class paths, everything, but cannot seem to get it to compile.

    • Akiles
    • November 20th, 2007

    Great!!
    i get an error compiling that ISMPlaneDemo.fla:
    1137: Incorrect number of arguments. Expected no more than 1.
    thanks
    1119: Access of possibly undefined property interactive through a reference with static type org.papervision3d.materials:MovieMaterial.

    i didnt change anything…

    • Jon
    • November 30th, 2007

    I also get the ambiguous reference to Vertex3D problem. I went as far as completely deleting my 1.5 version but I still can’t get rid of the issue.

    • Jon
    • November 30th, 2007

    I fixed the amboguous vertex problem by starting a new flash file and copying everything over from the old one.

    However, a seperate issue: I’ve been trying to do this stuff on an external collada model and been having problems. I’ve gradually stripped back , removing interactivity, just using a flat ColourMaterial etc.and then made the collada move onEnterFrame. All this works fine in the main branch of papervision, but in the Phunky branch the motion is very slow and old frames leave behind a ghost image. I also note that the frame rate gets grdually slower as if there is a memory leak. There is no problem using the internal Plane. Is this really a problem with the Phunky branch or am I doing something obviously silly.

    • Daniel
    • December 3rd, 2007

    @jon
    you can clear the container manually:

    private function render(e : Event) : void {
    container.graphics.clear();
    scene.renderCamera(camera);
    }

    • Brian
    • December 6th, 2007

    i tried to do this demo using the great white revision (papervision 2.0) and its coming up with this error:

    Location: Triangle3D.as, Line 180

    1067: Implicit coercion of a value of type org.papervision3d.core.math:Number3D to an unrelated type org.papervision3d.core:Number3D.

    var vn0:Number3D = v0.toNumber3D(),

    does anyone know whats going on?

  18. @Brian: Yeah, you probably have a class path set to the new repository. The Component you have is not using 2.0 code base, so it will fail. Remove the class path from your FLA and compile

    • Brian
    • December 6th, 2007

    Thanks John for the fast response… but now im getting another error:
    1172: Definition org.papervision3d.objects:Plane could not be found.

    import org.papervision3d.objects.Plane;

    and

    1046: Type was not found or was not a compile-time constant: Plane.
    var plane:Plane = new Plane(material, 250, 250, 10, 10);

    1180: Call to a possibly undefined method Plane.

    It seems like such an easy fix but i tried a bunch of different things and I dont know where i went wrong. Thanks!

  19. DOH yeah, that’s because the component you have doesn’t have all of the classes compiled with it. You’ll have to use PV3D 1.5 and point to that src in your FLA if you’re going to add a plane / primitive to the Components scene – sorry about that. This should be fixed in 2.0 component

    • Brian
    • December 6th, 2007

    Im playing around with papervision3d 2.0 and trying to convert this demo to 2.0, so far this is the code, everything is working except the buttons dont seem to be active. Does anyone know what might be missing?

    import org.papervision3d.view.Viewport3D;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.cameras.FreeCamera3D;
    var viewport:Viewport3D = new Viewport3D(0, 0, true, false);
    addChild(viewport);
    var renderer:BasicRenderEngine = new BasicRenderEngine();

    var scene:Scene3D = new Scene3D();
    var camera:FreeCamera3D = new FreeCamera3D();
    camera.zoom = 11;

    var material:MovieMaterial = new MovieMaterial(movieSkinContainer, true, true);
    material.interactive = true;
    material.oneSide = false;
    material.smooth = true;

    var plane:Plane = new Plane(material, 250, 250, 10, 10);

    scene.addChild(plane);

    addEventListener(Event.ENTER_FRAME, handleEnterFrame);
    function handleEnterFrame(e:Event):void {
    plane.yaw(.5);
    renderer.renderScene(scene, camera, viewport);
    }

    THANKS!

    • Brian
    • December 7th, 2007

    aahhh, i found the problem, the 4th parameter of viewport is interactivity so it must be set to true. like this:
    var viewport:Viewport3D = new Viewport3D(0, 0, true, true);

    If you are using pv 2.0 you can use this code above (with this minor change) and just replace it with the script that is used in the downloadable demo for this.

  20. i read all mesagges you post but i could’t solve my problem:( please help me to run my project without these errors.

    1046: Type was not found or was not a compile-time constant: Scene3D.
    1046: Type was not found or was not a compile-time constant: Camera3D.
    1046: Type was not found or was not a compile-time constant: BitmapAssetMaterial.
    1046: Type was not found or was not a compile-time constant: Plane.
    1180: Call to a possibly undefined method Scene3D.
    1180: Call to a possibly undefined method Camera3D.
    1180: Call to a possibly undefined method BitmapAssetMaterial.
    1180: Call to a possibly undefined method Plane.

    • dwayneneckles
    • January 3rd, 2008

    i am so lost. since 1.9 is not available anymore.. i have 1.7.. and i get …..

    1137: Incorrect number of arguments. Expected no more than 1.

    • Warren Mackenzie
    • January 7th, 2008

    this doesnt work.
    papervision is fucking shite man, very fiddly and undocumented.

    this added to the AS3 migration headache for average AS2 coders like myself make this a tasty carrot i will never get to fucking eat.

    i downloaded the source above, i have pointed the files to the ‘greatWhite’ folder, and when i export the the movie, no errors pop up, and the compiler says nothing and the screen is blank.

    this is really starting to piss me off. ive not slept for days trying to resolve this. please can you explain what im doin wrong. do i need to install a new flash extension into cs3 extension managaer, or just point to the great white folder as i am doing.

    please advise

    • warren
    • January 7th, 2008

    ok, i pointed the lot to the greatwhite folder, and replaced the code with Brians code, and changed the 4th aparameter as mention.

    i now get the error:
    1020: Method marked override must override another method.

    here is my code:
    import org.papervision3d.view.Viewport3D;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.cameras.FreeCamera3D;
    var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
    addChild(viewport);
    var renderer:BasicRenderEngine = new BasicRenderEngine();

    var scene:Scene3D = new Scene3D();
    var camera:FreeCamera3D = new FreeCamera3D();
    camera.zoom = 11;

    var material:MovieMaterial = new MovieMaterial(movieSkinContainer, true, true);
    material.interactive = true;
    material.oneSide = false;
    material.smooth = true;

    var plane:Plane = new Plane(material, 250, 250, 10, 10);

    scene.addChild(plane);

    addEventListener(Event.ENTER_FRAME, handleEnterFrame);
    function handleEnterFrame(e:Event):void {
    plane.yaw(.5);
    renderer.renderScene(scene, camera, viewport);
    }

    please can someone advise me as im fooked without this

  21. @ Warren: your code looks fine as far as I can tell, can you tell me what’s not working? You don’t seem to have any event listeners for mouse events for the movieSkinContainer – are they in some other class? are you just trying to get mouse events on that material?

    if so, you could test by adding this code, which I just tested with YOUR code (and it works):

    movieSkinContainer.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
    movieSkinContainer.addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
    movieSkinContainer.addEventListener(MouseEvent.CLICK, handleClick);

    function handleRollOver(e:MouseEvent):void
    {
    trace(“rollover”);
    }
    function handleRollOut(e:MouseEvent):void
    {
    trace(“rollout”);
    }
    function handleClick(e:MouseEvent):void
    {
    trace(“rollClick”);
    }

    also, you’re using a movieclip that’s on stage, but if don’t need that onstage, I would suggest using MovieAssetMaterial() instead and provide the linkage string as the first argument. You might have put your material (movieclip) onstage with x/y not being at zero and that would cause your demo to fail as well. Materials have to be 0,0 on the x/y axis’

    hth

    • Warren Mackenzie
    • January 8th, 2008

    thanks john, ill test this tonight,
    having to work around it with ‘fake 3d’, but if i can get this nailed tonight at home, then i will get brownie points at work on thursday when i turn up with it in true 3d!

    is there any chance you would be kind enough to create the simplest of FLA for me that will work with what i have.

    i simply dont understand all the conflicts with different versions of Papervision etc…. Phunky / Great White / 1.5 / 1.7 / 1.9 / 2.0

    it seems when u download source for a tutorial, you have about a 1 in 10 chance of it working. I would have thought, say, if u are using a tutorial for version 1.5, then if u have set flash up to point to the GreatWhite folder in ‘branches’ so ur using latest version, all the FLA’s for version 1.5 would work with 2.0.

    but no!

    when people refer to version 1.5 /1.7 /2.0 are they refering to the folder flash is pointing to on machine so for example 1.7 would be “C:\svn\as3\trunk\src” and 2.0 would be: “C:\svn\branches\GreatWhite\src” and any tutorials aimed at 2.0 should only contain the latter class path?

    or am i grossly misjudging the situation……

    basically what im trying to do is as follows:
    1) Design Orb-like object in 3dS max with a few faces extruded (Think 3d Snowflake)
    2) Export as collada file with texture on it
    3) Import into flash via AS3 (not the shitty component built in colllada wysiswyg)
    4) Point the texture to a movieclip instead, either on stage, out of view with MC name or using linkage id to one in the library.
    5) Inside the Texure Movie clip, on the faces which would be the extruded outer faces, have some kind of interaction. Maybe a movie clip containing a little animation and an invisible button on top, so when you mouse over the invisible button, the movie clip underneath plays, and on mouse out it reverts to initial state.

    Im sure to a flash pro like yourself this is a walk in the park, and if I had an endless amount of time id eventually suss it as I have most other probs like this, but unless I can suss this in next day or so, a massive project will be a lot shitter than it has to be…

    Please can you explain what I need to do to get your example working, how I map to the right directories etc… How different versions of Papervision work, what this all means.. and clear up anything else ive mentioned above… Im lost. Once I have this little fucker on the lock-down, the world is my oyster.

    Help me brother.

    feel free to msn me at warrenmackenzie@hotmail.com

    • Warren Mackenzie
    • January 8th, 2008

    @John
    btw what wasnt working was, when i exported and tested the FLA with code above, i got the error i said and the screen was completely blank! i changed the blend properties of the mc on stage to be normal as are initially set to ‘erase’????????? and then the clip just flickers, no plane, no 3d, just jibberish.
    ….i then cried and crawled back to swish 3d with my cock in my hand😦

  22. @Warren: I created that “shitty” component. It’s hardly shitty. There’s absolutely no documentation on how to create components for Flash 9 IDE – NONE. I had to guess my way through and beg people internally for answers on how to do stuff. If anything, it’s at least a note worthy achievement – but a far cry from shitty.

    It’s also the first time you’ve ever seen interactive 3D at DESIGN TIME within the flash IDE, and that’s at LEAST earned it a right not to be called “shitty”.
    🙂

    As for you helping you out, I already did that – if you take the code I posted in my original reply and put it in YOUR code that you posted, it works.

    As for the samples – yes that’s right. That’s why 1.5 demos are with 1.5 code base. They don’t work with future versions of the engine in most cases. ALL of the 1.9 samples are broken when used with 2.0 GreatWhite. GreatWhite was a considerable re-write and reorganization of the code base to incorporate shaders and materials.

    Hope that helps.

    • Warren Mackenzie
    • January 8th, 2008

    i did not know you invented this, im very sorry. its very nice im just a bit crap at implementing this stuff.

    if say i download the latest SVN, and i have tutorials for 1.5 where would i point them
    1.7 the same, 1.9 the same etc…….

    anyway, sorry dude, just a little lost. ill try that stuff tonight.
    how come there are no GreatWhite samples yet?…

  23. @Warren: No worries

    1.9 was removed because it essentially became 2.0, so 1.7 should have samples that work, but of course, only with that version of the code base.

    2.0 doesn’t have samples yet, because we were waiting to make sure that the GW code base didn’t change much more and we wanted to do some house cleaning. But I beleive there are 2.0 examples out there now in the SVN repository. I just sync’d last night and saw several folders come in with examples. So check it out

    • warren
    • January 8th, 2008

    hi john, doesnt work and SVN is sync’d properly, sorray about this, i know u guys are busy…

    same error….
    anyway, ive FTP’d a zip containing the code, click here to download it and see what happens when u run it.
    http://www.disease.co.uk/ISMPlaneDemo3.fla

    im running this on my desktop, all paths hooked up so shouldnt be a problem.

    please christ help me!

    • jassa
    • January 10th, 2008

    Hi John,

    Great tutorial – thanks! Excuse my ignorance but where should I be placing MouseEvents for the buttons inside the movieSkin? I have named the Button “btn” but the following code does not seem to work.
    movieSkinContainer.movieSkin.btn.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
    movieSkinContainer.movieSkin.btn.addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
    movieSkinContainer.movieSkin.btn.addEventListener(MouseEvent.CLICK, handleClick);

    If you could point me in the right direction that would be great😉
    Thanks!

  24. @jassa: I would just put that code inside the movieclip where btn lives:

    btn.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
    btn.addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
    btn.addEventListener(MouseEvent.CLICK, handleClick);

  25. Hello John,

    First of all I use your api and it’s amazing!
    Now im in a little trouble because im on svn but cant upgrade to 1.9, its still 1.7 and when i try to run your tutorial it says a 1137 and 1119 error. I saw others had this problem and could fix it, but i cant… i feel lame littlebit

    • jassa
    • January 13th, 2008

    Hi John,

    Thanks for the tip. Still doesn’t seem to work though. Everything else seems to be perfect, it’s just that the buttons aren’t doing anything even though they have MouseEvents associated with them. I’ll keep trying – Cheers!

    Jassa

    • Tim
    • January 25th, 2008

    Hey

    Wow it feels like Papervision is just way over my head. I tried this with Brians code and it comes up with many errors. I feel so lost. Does anyone else know of any other tutorials that cover interactive materials with the “great white” version of papervision.

    Any help would be appreciated!

    By the way thanks to John for all the hard work you have put into papervision and these tutorials, without which I would be completely lost.

    Cheers Tim

    • akire
    • February 1st, 2008

    Hello!

    I have removed all references to old code bases and am pointing to greatwhite and i get this error:
    TriangleMaterial.as, Line 24
    1024: Overriding a function that is not marked for override.

  26. @Akire: that was fixed a while ago I believe, maybe you need to resync with the repo and make sure you don’t have any source paths pointed to old versions of PV3D

  27. Hey guys, I don’t think it was ever posted here directly, but Rex Raptor posted a solution on another blog that some people may find very useful.

    In order to have a real *hand cursor* on specific elements, you can simply turn the whole viewport container’s .buttonMode on and of INSIDE the rollover and rollout events of your 3D objects + textures.

    ie.

    function onRollOver(event:InteractiveSceneEvent):void {
    viewport.containerSprite.buttonMode = true;
    }

    function onRollOut(event:InteractiveSceneEvent):void {
    viewport.containerSprite.buttonMode = false;
    }

  28. John,
    I’ve come across a bug with the interactive scene event, i have 3 planes, each one i’ve added a click event listener to… The problem is after i click one, the id property i get through e.target.id is always the first one that i clicked although, i definitely am clicking other planes.

    Thanks
    Patrick

  29. @patrick: I don’t think it’s a bug if you’re listening for pure mouse events. Just depends: are you using a unique movieclip for each material for each plane? If you’re not, then the same movieclip instance is used for all planes, and there for, the ID would be the same.

    • Patrick
    • February 12th, 2008

    Actually i am using bitmap data, which is unique for my material.

    The bug, or intended implementation it might be, seems to be that when i stop the enter frame event, then the getting the proper id property of the selected item fails.

    Thanks,
    Patrick

    • Rex Raptor
    • February 27th, 2008

    Hi John,

    Thanks again for your tutorial it really helped a lot. I thought you might like to see how my final interactive cube came out:
    http://rollover.troweprice.com

    In the middle of the page you’ll see a link in green called “Use our Rollover Planner”. You’ll need to hit that because the cube shows up in a pop up window.

    Hit the top link on the face of the cube to get it started (the one with the video icon).

    Let me know if you notice any bugs. I barely knew any AS1 before jumping strait into AS3.

    Thanks again!

    Rex

    • mixey
    • March 12th, 2008

    Hi, I have downloaded you fla file an now trying to compile in Flash CS3 Classpath is pointing to the GreatWhite src folder, but I’m getting following errors, any help is greatly appreciated.

    1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.
    1137: Incorrect number of arguments. Expected no more than 1.

  30. @Mixey: you can’t use the GW branch with this sample code unfortunately. You have to convert and use the new BasicRenderEngine with a Viewport3D.

    var viewport:Viewport3D = new Viewport3D(0,0,true, true);
    var renderer:BasicRenderEngine = new BasicRenderEngine();

    //… in your render loop

    renderer.renderScene(scene, camera, viewport);

    • mixey
    • March 12th, 2008

    @John Grden: What branch should I use to get this working?

    Yes, I’m using BasicRenderEngine.

    But, when I’m trying to pass parameters to the Scene3D(container); I get this:
    Warning: 3590: flash.display:Sprite used where a Boolean value was expected. The expression will be type coerced to Boolean.

    of course I have container Sprite made before.

    And also when I’m passing second parameter true, to the Scene3D(container, true); I got:
    1137: Incorrect number of arguments. Expected no more than 1.

    Thank you for your answer

  31. @Mixey: yeah, you can’t do that anymore with Scene3D. Just simply don’t pass any parms in the Scene3D constructor. Instead, use viewport3d like I stated above. The 4th argument (Interactive:Boolean) sets interactivity up. I think if you pull those args out of Scene3D, you should be fine

    • mixey
    • March 12th, 2008

    @John Grden: Wow! Thank you! Now I’m able to put some buttons inside of my mc which I’m using as a MovieAssetMaterial, just one thing left to get me running and start to create interesting stuff. How could I make finger cursor to appear when I’m roll overing my buttons?

    container.buttonMode = true; isn’t working anymore?

  32. @Mikey: The trick is to set buttonMode inside of your event listener method:

    event.currentTarget.buttonMode = true;

    I’ve also done it by setting buttonMode on the stage object and then turn it off when I rolled out.

    • mixey
    • March 12th, 2008

    I’m really sorry for bothering you, but also forgot to mention that I’m new to AS 3.0 and right trying to learn it.

    inside of my movie clip that I’m using as a MovieAssetMaterial I’ve got button and code in the frame:

    my_btn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, onPressM);

    function onPressM(e:Event):void {
    trace(“1”);
    }

    so where event.currentTarget.buttonMode = true; should go?

    Once again Thank you, your help is really helping me

  33. @Mixey: inside your onPress event, put:

    e.currentTarget.buttonMode = true;

    hth

    • mixey
    • March 12th, 2008

    @John Grden: If I do that in output panel I see:

    ReferenceError: Error #1056: Cannot create property buttonMode on flash.display.SimpleButton.
    at my_rect/onPressM()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.papervision3d.core.utils.virtualmouse::VirtualMouse/::handleUpdate()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.papervision3d.core.utils.virtualmouse::VirtualMouse/update()
    at org.papervision3d.core.utils.virtualmouse::VirtualMouse/press()
    at org.papervision3d.core.utils::InteractiveSceneManager/org.papervision3d.core.utils:InteractiveSceneManager::handleMousePress()

    • mixey
    • March 12th, 2008

    I converted button to the movieclip and now I don’t get this RefferenceError, but still no luck with handcursor😦

    • akshatha
    • April 7th, 2008

    Hi John,

    I get 2 errors when I try to compile this code:
    ->Error: Incorrect number of arguments. Expected no more than 0.
    scene = new Scene3D( container, true );

    ->Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.
    scene.renderCamera( camera );

    I dont understand why I’m getting this error. Please help.

    Thanks,
    Akshatha

  34. @akshatha: read prior comments on this post – I’ve answered it several times🙂 You’re using 2.0 of papervision I’m assuming, yes?

    • akshatha
    • April 7th, 2008

    Yes, I’m using papervision 2.0…does it have somethin to do with the version?

    I will try out your suggestions above..

    • akshatha
    • April 7th, 2008

    Hi again,
    I tried out your suggestion and was able to remove the build errors:) However, I came across a type error after that:

    [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
    Fault, onStageResize()

    How do I fix this?Please help.

    Thanks,
    Akshatha

  35. Hey John,

    I see that the implementation of interactive materials is now different to Patrick’s at http://labs.blitzagency.com/?p=315 and thus it’s not possible to select text or use the mouse wheel (this isn’t enabled on Patrick’s demo, but I reckon in theory it would have been simple).

    I guess the reason behind this is that the VirtualMouse class doesn’t support this. Just wondering if any attempts have been made to add this functionality?

    Cheers :p

    • Mabs
    • May 12th, 2008

    Hi! where can i download papervision 1.9 phunky i searched it on google code and did not find a thing…please help anyone ?

    • Mabs
    • May 12th, 2008

    i found it here http://ascollada.googlecode.com/svn/
    is this the right one?
    it still doesn’t work,and i’ve set to edit> preferences >as3 the directory with phunky,i still have errors

  36. @Mabs: 1.9 was removed from the repo when 2.0 was added unfortunately. If you found a version at ascollada, that’s the only one I know about. AsCollada is developed by Tim Knip, who’s a core member of the papervision3D team, so I’m not surprised he has a version of 1.9 out there

    • Mabs
    • May 12th, 2008

    Thanks for the reply,i’ve tried to use papervision 2.0 great white engine with brian’s code,but i’m getting reference errors like this one:
    ReferenceError: Error #1065: Variable PV3DScene3D is not defined.
    is it because i’ve also installed the 1.51 mxp component??
    is it not compatible with great white 2.0 ??

  37. ah yeah, duh, you don’t need a reference to any classes at all when you use the component. So, if you’ve establed class paths to any PV3D libraries in your FLA OR the FLash IDE, remove them. That’s the error your getting. The component code is refactored in 2.0, hence that error message

    • Jakob Halskov
    • May 24th, 2008

    Is it posible with great white?

    • christina
    • July 8th, 2008

    hey ive been playing with paervision 3d and i was having some problems with it. i made this http://christinarule.com/test/downstairs2.swf and i cant figure out how to when i click on something insde my scene to make the camera stop so it can load anoterh swf…. here is my code http://christinarule.com/test/main.as please someone help haha

  38. I had the same issue as Mabs:
    “ReferenceError: Error #1065: Variable PV3DScene3D is not defined.
    is it because i’ve also installed the 1.51 mxp component??
    is it not compatible with great white 2.0 ??”

    I removed the mxp from the extensions manager but still get the same error.

    Any guideance would be appreciated.
    Thanks!

  39. John:

    I downloaded the 2.0 repo and placed the files in my fla’s directory then just ran the empty swf that has nothing on it just a blank scene and this is what I get:

    1067: Implicit coercion of a value of type org.papervision3d.core.geom:Vertex3D to an unrelated type org.papervision3d.core.geom.renderables:Vertex3D.

    I’m using Flash CS3 on Win XP
    There are no class paths defined and even if I do define them, I get the same error.

    I’m guessing there is something hanky in the Vertex3D.as but I’m not apt enough to go pluckying around with the src.

  40. @cam: be sure you do NOT have a global path setting for PV3D in the general preferences for flash. That sounds like what’s happening

  41. I have the same error as Cam. I have removed all papervision files from my computer, then downloaded the latest from svn.

    • papablacksheep
    • September 12th, 2008

    Hi there, thanks for the tuts !

    I am actually workin’ with latest great white revision (726) and I have a problem with the “animated” property of my material, here’s my code:

    import org.papervision3d.view.Viewport3D;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.cameras.Camera3D;
    var viewport:Viewport3D = new Viewport3D(0, 0, true, true, true);
    addChild(viewport);
    var renderer:BasicRenderEngine = new BasicRenderEngine();

    var scene:Scene3D = new Scene3D();
    var camera:Camera3D = new Camera3D();
    camera.zoom = 11;
    camera.focus = 100;

    var material:MovieMaterial = new MovieMaterial(myclip, true, true);
    material.interactive = true;
    material.animated = true;
    material.oneSide = false;
    material.smooth = true;

    var plane:Plane = new Plane(material, 250, 250, 10, 10);

    scene.addChild(plane);

    addEventListener(Event.ENTER_FRAME, handleEnterFrame);
    function handleEnterFrame(e:Event):void {
    plane.yaw(.5);
    renderer.renderScene(scene, camera, viewport);
    }

    So, in my exemple, let’s say that I put a button inside Myclip, as you did in your own video tut, and that I put , still inside the movie clip “Myclip” an event listener on it, with a function attached to that listener, let’s say for instance a trace (“clicked”), indeed it works and when I click on the button within the plane, I get the trace function BUT the button itself is not animated like yours in your tut, the mouse over state of the button itself is not displayed…

    Any idea?
    (excuse my poor english I’m a french student)

    • felix
    • September 17th, 2008

    hi i’m using 2.0 greatwhite still cant get buttonMode to work for rollovers. i can get it to show if i set the viewport to buttonMode true but individual clips are still not getting hand cursor. I tried putting the buttonMode true in the event handler with no luck. anything im missing?

    • Jolanta Gałecka
    • August 21st, 2009

    so where is that demo? I found some cool tools for making some lessons (www.yauthor.com) but need to provide animation myself, so an interactive cube would be good
    Jola

    • if you sync with the repository on google code, the interactive cube is included in the examples/samples directory

        • Jolanta
        • August 30th, 2009

        what does it even mean to “sync with the repository on google code”? I am sorry but I am far from the technological gurus, you guys are…
        thank you
        Jola

      • Hey Jola, you’ll have to us an SVN client like tortoise or versions ( if you’re on a mac ) to “sync” with the source files we have on google code:

        Papervision source

        I can’t get into the specifics of using SVN unfortunately (that’s up to you), but that’s basically it. When you “sync” or “checkout” using the information on that google page, the source files will be copied to your harddrive. This will include the examples, and you should be able to play/learn from there.

        good luck

      • you might also try downloading the zip of the classes, BUT i’m not sure it includes the examples:

        http://papervision3d.googlecode.com/files/Papervision3D_2.0.883.zip

  1. October 5th, 2007
  2. November 29th, 2007

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s