Accessing methods within loaded swf

Recently I was working on an application which loads flash or flex swf in it. We had to access internal methods in the loaded swf, flash and flex generated swf required different ways to access.

Probably any one of you reading this may have a better way.

<!--?xml version="1.0" encoding="utf-8"?-->
xmlns:mx="library://" minWidth="955" minHeight="600"&gt;
import mx.core.IUIComponent;
import mx.managers.SystemManager;

private var _systemManager:SystemManager;
private var _loadedApplication:IUIComponent;

private var _isFlexApp:Boolean = false;

protected function loader_completeHandler(event:Event):void{
_systemManager = SystemManager(loader.content);

_systemManager.addEventListener(FlexEvent.APPLICATION_COMPLETE, appApplicationCompleteHandler);
_systemManager.addEventListener(FlexEvent.UPDATE_COMPLETE, appUpdateCompleteHandler);

_isFlexApp = true;
_isFlexApp = false;


private function appUpdateCompleteHandler(event:FlexEvent):void{
_loadedApplication = _systemManager.application;

private function appApplicationCompleteHandler(event:FlexEvent):void{
_loadedApplication = _systemManager.application;

private function callMethodHandler(event:MouseEvent):void{
if((_loadedApplication as Object).hasOwnProperty("clearAll")){
(_loadedApplication as Object).clearAll();
if((loader.content as Object).hasOwnProperty("clearAll")){
(loader.content as Object).clearAll();


facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Comment

Your email address will not be published. Required fields are marked *

Disclaimer: All published content views of author.