Import an away3d Class in a Flex Project?

Software: Away3D 4.x

frogman_pep, Newbie
Posted: 27 February 2012 10:34 AM   Total Posts: 19

Not sure how to word this, probably easier to show.  So if you go to: http://www.frogmandesignz.com/test5/index.html and on the main page click on the away3d Examples button in the list aligned to the right of the stage and in the drop down list select the first option ‘Capsule’, you’ll see the stats palette show, but no background color and no away3d action.

View source is enabled so you can check out the code of the important files:

main_cont_away3d_cone.mxml - in the components folder
ExBasicClass.as - in galleries/away3d
away3d.mxml - in components as well

The ExBasicClass works fine on it’s own, but when I try to import it into this Flex Project no luck.  Sorry it’s so messy, still trying to make sense of this all.  Any help will be much appreciated, thanks.

   

Stephen Hopkins, Sr. Member
Posted: 28 February 2012 09:19 PM   Total Posts: 110   [ # 1 ]

Make sure you have background alpha of your flex containers (UIComponents or SpriteVisualElements) set to 0

 Signature 

http://www-scf.usc.edu/~shopkins

   

frogman_pep, Newbie
Posted: 29 February 2012 12:54 AM   Total Posts: 19   [ # 2 ]

Thanks Stephen, I figured out the problem, but not a solution yet.  It’s the skinClass for the background image, so for instance if you take out the skinClass in the index file the away classes will show. 

I came across this post that talks about changing the z-index of the parent, but couldn’t make it work.  Would that be a possibility?

Here’s the code I’m working with, edited a bit for simplicity.

Index.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      
xmlns:s="library://ns.adobe.com/flex/spark"
      
xmlns:mx="library://ns.adobe.com/flex/mx"
      
xmlns:skins="skins.*"
      
xmlns:components="components.*"
      
backgroundAlpha="0"
      
width="100%" height="100%" autoLayout="true" currentState="home"
      
viewSourceURL="srcview/index.html"      
      
creationComplete="init()"
      
skinClass="skins.MyAppSkin">
 
 <
s:states>
  <
s:State name="home" />
 </
s:states>
 
 <
fx:Style source="assets\\\\\\\\\\\\\\\\css\\\\\\\\\\\\\\\\style.css"/>
 
 <
fx:Script>
  <!
[CDATA[
   import mx
.core.ScrollPolicy;   
   
import skins.MyAppSkin;
   
   
import spark.skins.spark.ApplicationSkin;  

   private function 
init():void{
    
    cone_cont
.visible true;
    
cone_cont.start();    
   
}
  ]]
>
 </
fx:Script
 
 <
components:home id="home_comp"
      
includeIn="home"
      
backgroundAlpha="0"/>
 
 <
components:main_cont_away3d_cone backgroundAlpha="0"
          
id="cone_cont"
          
visible="false"/> 
</
s:Application

MyAppSkin

<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
        
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
  
xmlns:mx="library://ns.adobe.com/flex/mx">

    <
fx:Metadata>
    <!
[CDATA[ 
        
/** 
         * A strongly typed property that references the component to which this skin is applied.
         */
        
[HostComponent("spark.components.Application")]
    ]]
>
    </
fx:Metadata
 <
fx:Script fb:purpose="styling">
  <!
[CDATA[
   import mx
.core.ScrollPolicy;
   
import mx.graphics.BitmapFill;
   
import mx.graphics.BitmapFillMode;
   
   
[Embed("assets/view/Background_Scene_Image.png")]
   
protected const BG_FILL:Class;
   
   
override protected function updateDisplayList(unscaledWidth:NumberunscaledHeight:Number):void {
    
var bmpFill:BitmapFill = new BitmapFill();
    
bmpFill.source BG_FILL;
    
bmpFill.fillMode BitmapFillMode.SCALE;    
    
backgroundRect.fill bmpFill;    
    
super.updateDisplayList(unscaledWidthunscaledHeight);
   
}  
  ]]
>
 </
fx:Script
    
    <
s:states>
        <
s:State name="normal"/>
        <
s:State name="disabled"/>
    </
s:states>
   
    <
s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0">
        <
s:fill>
            <!--- @private -->
            <
s:SolidColor id="bgRectFill" color="#FFFFFF"/>
        </
s:fill>
    </
s:Rect>
        
    <
s:Group left="0" right="0" top="0" bottom="0">
        <
s:layout>
            <
s:VerticalLayout gap="0" horizontalAlign="justify" />
        </
s:layout>

      
  <
s:Scroller id="scroller"
     
width="100%"
     
height="100%"
   
  <
s:Group id="contentGroup"
     
left="0"
     
right="0"
     
top="0"
     
bottom="0"
     
width="100%"
     
height="100%"
     
clipAndEnableScrolling="true"
     
contentBackgroundAlpha="0"/>
   
  
  </
s:Scroller>  
    </
s:Group>
</
s:Skin

main_cont_away3d_cone.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009" 
       
xmlns:s="library://ns.adobe.com/flex/spark" 
       
xmlns:mx="library://ns.adobe.com/flex/mx"
       
backgroundAlpha="0"       
       
width="100%"
       
height="100%">
 <
fx:Declarations>
  <!-- 
Place non-visual elements (e.g., servicesvalue objectshere -->
 </
fx:Declarations>
 
 <
fx:Script>
  <!
[CDATA[
   import plz
.Away3D4AFP11_ConePrimitive;  
   
   public function 
start():void{
    
    
var cap:Away3D4AFP11_ConePrimitive = new Away3D4AFP11_ConePrimitive(); 
    
cap.0;
    
cap.0;
    
window.addChild(cap);
   
}
  ]]
>
 </
fx:Script>
 
 <
s:SpriteVisualElement id="window"
       
width="100%"
       
height="100%"/>  
 
</
s:BorderContainer

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X