# Trouble assigning the value of a property in an externally loaded SWF to a local var

**URL:** <https://forum.kirupa.com/t/trouble-assigning-the-value-of-a-property-in-an-externally-loaded-swf-to-a-local-var/284010>\
**Category:** flash\
**Created:** [March 13, 2009, 6:01pm UTC](https://forum.kirupa.com/t/trouble-assigning-the-value-of-a-property-in-an-externally-loaded-swf-to-a-local-var/284010 "2009-03-13T18:01:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![derrickcurry](https://avatars.discourse-cdn.com/v4/letter/d/cc9497/32.png) [@derrickcurry](https://forum.kirupa.com/u/derrickcurry)\
**Post date:** [March 13, 2009, 6:01pm UTC](https://forum.kirupa.com/t/trouble-assigning-the-value-of-a-property-in-an-externally-loaded-swf-to-a-local-var/284010/1 "2009-03-13T18:01:42Z")

</div>

A have a external SWF file that contains an instance of an object that will be used across multiple projects. It’s accessible as a public property of the external SWF.

When I load the external SWF file using the Loader class everything comes in fine but when I try to assign the value of that property, which traces out as an instance of the correct object, to a local variable the local variable is always null.

Below is a dumbed down sample of what I’m trying to accomplish:

# Object Class

```auto
package com.derrickcurry
{
    import flash.display.Sprite;
    
    public class MyObject extends Sprite
    {
        public function MyObject():void
        {
            trace("- MyObject -");
        }
        
        public function doWork():void
        {
            // Does something
        }
    }
}

```

# External SWF Document Class

```auto
package
{
    import com.derrickcurry.MyObject;
    import flash.display.Sprite;
    
    public class MyExternalMovie extends Sprite
    {
        public var instance:MyObject;
        
        public function MyExternalMovie():void
        {
            this.instance = new MyDocument();
        }
    }
}

```

# SWF Document Class that the loads the External SWF from above

```auto
package
{
    import flash.display.Sprite;
    import com.derrickcurry.MyObject;
    
    public class MyMovie extends Sprite
    {
        private var myObject:Object;
        
        public function MyMovie():void
        {
            if (!this.myObject)
            {
                var url:URLRequest = new URLRequest("http://somedomain.com/MyExternalMovie.swf");
                
                var loader:Loader = new Loader();
                
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMyExternalMovieLoaded);
                loader.load(url);
                
                addChild(loader);
            }
        }
        
        private function onMyExternalMovieLoaded(e:Event):void
        {
            this.myObject = e.target.content;
            
            trace(this.myObject); // traces [object MyExternalMovie]
            trace(this.myObject.instance); // traces [object MyObject]
            
            var localObject:MyObject = this.myObject.instance as MyObject;
            
            trace(localObject); // traces "null"
        }
    }
}

```

Is there a reason why I can’t take the value from a property of the externally loaded SWF and assign it to a local variable?
