0
votes

I have a two files: Main.swf and DataEnter.swf. Each has a Document Class. I try to load DataEnter.swf in Main.swf.

Main.as

package
{
    import flash.events.*;
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.display.Loader;

    public class Main extends MovieClip
    {    
        public function Main()
        {
            var loader: Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, DataEnter_loadComplete);
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
            loader.load(new URLRequest('DataEnter.swf'));
        }       

        function DataEnter_loadComplete(evt: Event):void
        {   
            trace(evt.target.content); // DataEnter__Preloader__                    
        var SWF = evt.target.content;   
        SWF.FooBar(); //Error #1069: Property FooBar not found on DataEnter__Preloader__ and there is no default value                      
        }
    }
}

DataEnter.as

package
{
    import flash.display.Sprite;

    public class DataEnter extends Sprite
    {
       private var _socketWorker:Foo;

       public function setSocketWorker(sw:Foo)
       {
           _socketWorker = sw;
       }

       public function FooBar()
       {
           //do something
       }
    }
}

When occurs an event Event.COMPLETE of Loader in Main class, the evt.target.content contains object DataEnter_Preloader_. But it must be "DataEnter".

What is wrong? How to call method FooBar of Loaded Class ?

3

3 Answers

1
votes

Did you by any chance use the preloader options in the Runtime Shared Library section of the extended ActionScript settings panel?

1
votes

I was running into this problem as well. After backtracking, it turned out that adding an embedded font to the data swf caused it.

I recommend removing any embedded fonts from the DataEnter.FLA, and republishing the SWF, to get this to work

1
votes

I opened DataEnter.swf in FlashDevelopIDE. This shows that my file has two frames, but FlashIDE it has only one frame.

In DocumentClass of DataEnter I have included a class "Foo", which works with sockets. But, object of this class, passed in constructor.

When I removed the class "Foo" and publish file again, then on loading swf file *DataEnter_Preloader_* is gone, and expected DataEnter was there.

Sorry for Bad English