Loading swf files created using away3D into swf files made using flash GUI

Software: Other

O_MEGA, Newbie
Posted: 31 December 2017 12:47 PM   Total Posts: 25

Hello, recently I made an AS3 project using FLASHDEVELOP and AWAY3D everything works fine. However when I tried to load created .swf file (which is located in bin folder) into another .swf file produced using flash GUI(ADOBE FLASH CS6) I get this Error!

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/initEngine()[F:AWAY3D_test3DmodeltestsrcMain.as:115]
at Main/init()[F:AWAY3D_test3DmodeltestsrcMain.as:95]
at Main()[F:AWAY3D_test3DmodeltestsrcMain.as:87]

Is there anyone who knows how I can solve this problem? I thought if I copy swc version of away3D in lib folders of installed flash CS6 will help me overcome this problem, I was wrong!(or maybe I have copied them in a wrong folder, does anyone know where shall I copy them?)

Is there anyone who knows how to load an swf made using away3D into another swf ?

Best Regards

   

Avatar
Fabrice Closier, Administrator
Posted: 31 December 2017 06:20 PM   Total Posts: 1265   [ # 1 ]

what is line 115?

   

O_MEGA, Newbie
Posted: 31 December 2017 09:46 PM   Total Posts: 25   [ # 2 ]

Hello Dear Fabrice, the line 115 of source Main.as file of FLASHDEVELOP AS3 project is:

stage.scaleMode StageScaleMode.NO_SCALE

and the line 95 is :

initEngine(); 

is a call for private function initEngine() inside the private function init(), and it basically initiates away3D engine.

and the line 87 is:

init(); 

is a call for private function init() inside the public function Main(), and it basically loads AWD models.

I am also suspicious that I might copied the swc version of away3D into the wrong lib of flash GUI. or could it be incompatibility between versions of FLASHDEVELOP and flash GUI? (ADOBE FLASH CS6 in this case)

I cannot figure it out!

   

tcorbet, Jr. Member
Posted: 01 January 2018 07:28 PM   Total Posts: 31   [ # 3 ]

Let’s start with a caveat:  I have not looked at the Away3D examples for over five years.

Yet, with the amplified information you provided concerning the lines of source code which correspond to the brief stack dump you posted, I am going to guess that you have architected your application around the Away3d examples which used functions named init() and initEngine() to get to the statement which raised the 1009 Error.

If you look at that statement, the reference which is null pretty assuredly has to be the reference your code holds to the singleton instance of the Flash runtime Stage.  In all likelihood your Main class extends Sprite in order to gain access to the stage property shared by all DisplayObjects.

Let me pause right there.  I am not writing this offer of help at this very basic level in any way to criticise, rather to suggest that you step back from the problem you are describing to think about the ways you might trouble-shoot the problem yourself.  It appears to me that you have fallen into a trap I often fall into:  If the methods and processes that you have been using to create a running piece of code fail, and one of the distinguishing attributes of your new attempt is working with a hitherto unfamiliar library or framework, it is somewhat natural to suspect that the new “stuff” is the cause of your problem.

Without the benefit of more information revealing your sources and even your build environments, it might not be possible for me to diagnose your problem, but by stepping back to your basic Flash skills, I suspect it will turn out that what you are seeing is the long-standing and correct behavior of the runtime—a behavior which you could reproduce with absolutely no Molehill [see, that’s how long it has been since I looked at this “stuff”], absolutely no Away3D code present in the test case at all.

Indeed, if I am correct about the problem you are experiencing, stepping back to basic Flashmanship would likely cause you to modify the code snippet you have probably copied from some earlier Away3d example.  Look at the statement that fails.  What is it trying to do?  Does it really make much sense for a child, sub-application, loaded swf set of code to be modifying the overall state of the application as being rendered by the runtime?  Wouldn’t the initialization of the parameters of the Stage normally be accomplished as a part of the initialization of the primary swf code execution?

I suspect if you just want to no-op the lines of code which attempt to set the parameters of the stage when the loaded swf is being executed, you’ll be able to continue on with your debugging/testing/enhancing work just fine.  Otherwise, if you find good reason to attempt to set stage properties in the loaded sub-application, you can google the old Adobe documentation for Actionscript 3.0 and see good explanations/examples of when the value of the stage property can be relied upon and when it cannot.  The short answer is that you need not only to wait on a complete event from the LoaderInfo object embedded in the Loader instance which I suppose you are using to load the sub-application, but you subsequently need to wait on an addedToStage event on the Loader instance itself, because, as a subclass of DisplayObject, Loader will only gain a valid reference to the stage when it is added directly, or more more likely indirectly, through some other DisplayObjectContainer which is part of your application architecture.

In summary, there is very little possibility that the source of your problem has anything directly to do with Away3d code and it would not matter in what directory structure you placed a swc containing that code no matter whether your IDE involves FlashDevelop or Adobe’s own toolchain.

I hope I have guessed right about your problem.  If not, please provide any additional information that might be helpful, and good luck with getting your test to the next level.

   

O_MEGA, Newbie
Posted: 08 January 2018 09:17 PM   Total Posts: 25   [ # 4 ]

Thanx for all your guides and helps, after doing more research and talking to some other people I changed the source code in flashdevelop project this way:

public function Main(){
 addEventListener
(Event.ADDED_TO_STAGE,init);
        
}
        
private function init(e:Event):void{
 removeEventListener
(Event.ADDED_TO_STAGE,init);
        
/*the rest of the code goes here*/
        

And it worked! Yet it is too soon to be happy, because I am observing strange behavior! while I run the code inside flash CS6 GUI everything works fine except the fact that the loaded swf is not in the position it should be.However,when I close Flash CS6 GUI and try to run the produced swf I see strange things! I see the loaded swf but it doesn’t work! there is a 3D model which is supposed to interact with mouse movements but it does nothing! there is a slider which is supposed to change the position of the camera so the user can see the model from different distances, it doesn’t work too! or it is better to say that it is out of control!
All of the effects I mentioned disappear when I press Ctrl+enter inside Flash CS6 GUI. Do you have any Idea?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X