Load Away3d compiled swf file into Flash builder

Software: Away3D 4.x

Aki Sharipov, Newbie
Posted: 24 August 2015 07:06 PM   Total Posts: 4

Hello

Is there any sample code of loading away3dv4 compiled swf into Flex.
I can’t get away3d start playing. I only see the regular stage objects.

Thanks

Aki

   

cyberix3d, Jr. Member
Posted: 25 August 2015 03:49 PM   Total Posts: 34   [ # 1 ]

Hello,
Here is a working example:

package
{
 import flash
.display.DisplayObject;
 
import flash.display.Loader;
 
import flash.display.MovieClip;
 
import flash.display.Sprite;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
import flash.events.ProgressEvent;
 
import flash.system.LoaderContext;
 
import flash.utils.setTimeout;
 
 public class 
externalTest1 extends Sprite
 {
  [Embed
(source "external_away3d.swf"mimeType="application/octet-stream")]
  
private var Scene1:Class;
  private var 
loader:Loader;
  private var 
embedSWF:MovieClip;
  private var 
ctx:LoaderContext;
   
  public function 
externalTest1()
  
{
   ctx 
= new LoaderContext(false,this.loaderInfo.applicationDomain);
   
ctx.allowCodeImport true;
   
   
addEventListener(Event.ENTER_FRAMEtempLoop );
  
}
  
private function tempLoop(event:Event):void {
   
if ( stage != null && stage.stageWidth && stage.stageHeight {
    this
.removeEventListenerEvent.ENTER_FRAMEtempLoop );
    
Setup(); 
   
}
  }
  
  
private function Setup():void 
  {
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.frameRate 60;  
   
   
loader = new Loader();
   
loader.contentLoaderInfo.addEventListener(Event.COMPLETEswfLoaded);
   
loader.loadBytes(new Scene1(), ctx);
  
}
  
  
private function swfLoaded(event:Event):void {
   
   loader
.contentLoaderInfo.removeEventListener(Event.COMPLETEswfLoaded);
   
embedSWF MovieClip(event.target.content);
   
addChild(embedSWF);
  
}

  
public function ReloadSWF():void{
   removeChild
(embedSWF);
   
loader.unloadAndStop();
   
Setup();
  
}    
 }

Also make sure that your HTML template has wmode = “direct”

 

   

Aki Sharipov, Newbie
Posted: 25 August 2015 05:19 PM   Total Posts: 4   [ # 2 ]

Thanks,

The addChild function is not supported in Flex. I am using greenback component to import the Away3d compiled swf. Regular import shows null error. I think SWF runs before it is fully loaded.

But the real problem was that Stage3D is below the Stage components. I set background alpha to 0, then away3d objects appeared.

Thanks for your reply. I really appreciate.

Aki

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X