views:

951

answers:

1

I am in the process of designing a 3D panorama viewer using papervision3d for the 3D library. I am coding entirely in ActionScript3 using FlashDevelop. I am at the point now where I need to add simple components (button, dropdown menu, toolbar, etc.) I know that using mxml it is easy to create UIs. Does anyone have any experience with creating UIs in mxml and then using them within a papervision3d object? Basically, I want to put a button specified by an mxml file in the middle of my panorama and I have no idea how to do this. Thanks for any help.

+1  A: 

I'm doing something very similar: I have been developing a 3D panorama viewer with Papervision3D, with Flex controls added as an interface. (You can check out the current status of the viewer at http://www.panocast.com)

What I did here was exactly the opposite of what you request: I wrapped the Papervision3D view inside a UIComponent, and placed that into an MXML file. By putting it in a Canvas, I was able to position the controls on top of it. Here's how:

<mx:Canvas width="100%" height="100%">
 <!-- the main panoarama player object -->
 <pp:PanoViewer id="pv" width="100%" height="100%" />

 <!-- horizontal control bar -->
 <mx:HBox id="controls" bottom="10" left="10" right="10">
  <!-- rewind & play/pause buttons -->
  <mx:ButtonBar id="playbackButtons" buttonWidth="26">
   <mx:dataProvider>
    <mx:Array>
     <mx:Object icon="@Embed(source='../../../../assets/rewind.png')" toolTip="Rewind video" name="rewind" />
     <mx:Object icon="{playIcon}" toolTip="Play video (space)" name="play" />
    </mx:Array>
   </mx:dataProvider>
  </mx:ButtonBar>
 ...

etc.

David Hanak
Very nice viewer! So did you extend the UIComponent for the PanoViewer object? If that is the case did you add your mouseListeners(for panning and tilting the panoramic video) to the stage or to something else?
Adam Richardson
@Adam: yes, I extended UIComponent. I added most of my listeners (incl. mouse listeners) to the component itself. To handle keyboard events, I made the class implement the IFocusManagerComponent interface, and filled in the keyDownHandler() and keyUpHandler() functions.
David Hanak