<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="{init()}" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" xmlns:ns1="*" viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import away3d.materials.TransformBitmapMaterial;
            import mx.logging.Log;
            import away3d.materials.WireColorMaterial;
            import away3d.materials.ColorMaterial;
            import away3d.primitives.Sphere;
            
            private var ball:Sphere;
            
            [Embed(source="./fx_appicon.jpg")]
            private var flexLogo:Class;
            
            // Adds a ball to the 3D view and sets up rendering
            public function init():void
            {
                var flexImage:Bitmap = new flexLogo() as Bitmap;
                var flexMaterial:TransformBitmapMaterial = new TransformBitmapMaterial( flexImage.bitmapData, {scaleX:0.1, scaleY:0.1, repeat:true, smooth:true} );
                
                ball = new Sphere({material:"orange#black"});
                ball.material = flexMaterial;
                ball.radius = 300;
                ball.segmentsH = 25;
                ball.segmentsW = 25;
                away.view.scene.addChild( ball );
                this.addEventListener(Event.ENTER_FRAME, render);
            }
            
            // makes the 3D component render on each frame
            public function render(e:Event):void
            {
                ball.rotationX += 0.5;
                ball.rotationY += 0.8;
                away.view.render();
            }
            
            // patches the Flex omission of smoothing for Image containers
            public function fix(event:Event):void
            {
                var imgControl:Image = event.currentTarget as Image;
                var image:Bitmap=imgControl.content as Bitmap;
                image.smoothing = true; 
            }
        ]]>
    </mx:Script>
    <mx:HDividedBox id="box" top="5" right="5" bottom="5" left="5" borderStyle="solid" borderColor="#999999" minWidth="100" minHeight="100">
        <ns1:AwayView id="away" width="200"/>
        <mx:Image source="@Embed('./away3d_logo_white.jpg')" maxHeight="{box.height-5}" scaleContent="true" creationComplete="{fix(event)}"/>
    </mx:HDividedBox>
</mx:Application>