# Calling methods of a loaded Flex swf

**URL:** <https://forum.kirupa.com/t/calling-methods-of-a-loaded-flex-swf/265454>\
**Category:** flash\
**Created:** [July 9, 2008, 5:05am UTC](https://forum.kirupa.com/t/calling-methods-of-a-loaded-flex-swf/265454 "2008-07-09T05:05:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiashy](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiashy](https://forum.kirupa.com/u/Kiashy)\
**Post date:** [July 9, 2008, 5:05am UTC](https://forum.kirupa.com/t/calling-methods-of-a-loaded-flex-swf/265454/1 "2008-07-09T05:05:56Z")

</div>

Hi all!

I’m loading a swf made in pure Flex from a pure ActionScript project. The Flex swf implements an interface. I load that swf and then I try to call a method of the loaded Flex swf but it doesn’t work.

This is the Flex swf that I’m loading:

```auto

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" implements="IApp" layout="absolute">
    <mx:Script>
        <![CDATA[
            public function init():void
            {
                trace( "INIT OK!!" );
            }
        ]]>
    </mx:Script>
</mx:Application>

```

This is the interface IApp:

```auto

package
{
    public interface IApp
    {
        function init():void;
    }
}

```

And this is how I load the Flex swf in the ActionScript pure project and try to call the init method:

```auto

package {

    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLRequest;
    import flash.text.*;

    public class PruebaGS extends Sprite
    {
        public var URL:String = new String( "FlexSWF.swf" );
        public var loader:Loader;
        
        public function PruebaGS()
        {
               loader = new Loader();
               loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
               loader.load( new URLRequest(URL));
        }
        
        public function completeHandler( evt:Event ):void
        {
            var movie:IApp = evt.target.content as IApp;
            movie.init();
        }
    }
}

```

The problem is that evt.target.content is of type \_FlexSWF\_mx\_managers\_SystemManager so it cannot be converted to IApp.

Does anyone know what is the problem?

Thanks!
