How to load External swf file in AIR

I try this code its working in computer but when I publish this file in .apk or .ipa , my external swf file is not opening
(I include my external file as well)
places_btn.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
function newvid(event:MouseEvent) {
     trace("you clicked me");
     var loadit = new Loader();
     addChild(loadit);
     loadit.load(new URLRequest("scene02.swf"));

thx boss its working great
I have 3 scenes; load scene code is working great
1. How can I unload the scene?
2. Can I unload all scenes or one by one?
can I unload some think like this
Load scene 2 , unload scene 1 and scene 3
Load scene 3, unload other all scene
i try this
load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
function newvid(event:MouseEvent) {
          trace("you clicked me");
          var loadit = new Loader();
          addChild(loadit);
    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    loadit.load(new URLRequest("scene02.swf"), _lc);
          loadit.unload();
load3.addEventListener(MouseEvent.MOUSE_DOWN, newvid1);
function newvid1(event:MouseEvent) {
          trace("you clicked me");
          var loadit = new Loader();
          addChild(loadit);
    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    loadit.load(new URLRequest("scene03.swf"), _lc);
          loadit.unload("scene01.swf scene02.swf");

Similar Messages

  • Loading external .swf files issue...

    Hi,
    I'm working on a simple example of loading external swf files with some ActionScript.
    I've placed an instance of List Component and gave it an instance name of loadList. Using Component Inspector, I assigned data for 4 external files as below:
    Next, I've added a UILoader component (instance name - loadWindow). The code that is supposed to load the content into UILoader is this:
    loadList.addEventListener(Event.CHANGE, selectItem);
    function selectItem(e:Event):void
        loadWindow.source = e.target.selectedItem.data;
    When I run it in a FlashPlayer, it only loads the first 2 swf files....  (I checked the files and all files are fine).
    I hope to get some light on the issue so any help will be appreciated.

    Try tracing e.target.selectedItem.data to make sure it's what you expect.
    Also, have you tried using the load() method instead of the source property?

  • Loading external swf file in a new window

    Hi,
    I've got a few .swf files with video tutorials I've created using Captivate 4.
    I wanted to link them so I've created a main screen with menu with buttons in Flash.
    I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
    Here's my code:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        myLoader.load(myURL);
        addChild(myLoader);
    I'm also attaching screenshot with menu in flash

    I've deleted the line and now the code lookes like that:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        addChild(myLoader);
    Unfortunately, it doesn't load the .swf file when you click on the button...

  • Loading external swf files in a swf - Error#1009

    I have been having trouble using a swf file within a swf file.   The external swf files all work as expected.  However when used within another swf file I get the standard TypeError #1009 for some of my swfs.   The external swf files are mainly actionscript 3 files.  A typical swf file will have an object (or objects) in the library which has an export for ActionScipt property enabled and an addEventListener(Event.ENTERFRAME, somefunction).   About four years ago when I had to do some work with AS2 I seemed to get around a similar issue with the _lockroot method but this is no longer part of AS3. I have searched various forums and note that I am not the only one with this issue but did not find any relevant solutions.   If anyone could give me any ideas on how to get around this it would be appreciated.
    Regards
    Norman

    Hi,
    I have added a download to rapidshare and its link is:
    Download link: http://rapidshare.com/files/380202712/ExtSwfs.zip
    The main file Training01.fla has been set up with links to download several swf's.   The links that do not work properly are those labelled :  Module6 and Module 8.   The first Module 6 connects to a function that is a variation of how I was trying to load external swfs using Application Domain, while Module 8 is a link to a swf that uses and external class.  Module 8 is supposed to load with rotating stars, while Module 6 loads the same file as the link called Module 1.   As soon as I use the two links Module 6 or Module 8 the whole lot ceases to work properly.  I did also follow through the examples on the Adobe site.  The examples for Module 6 and Module 8 are tutorials I have used from the Internet as part of my training from the site FlashMyMind.com but they replicate the type of work we have been doing with respect to using ActionScript3.
    Re my background, at this stage I am self-taught using tutorials on the web and whatever books I can lay my hands on here.  There is no structured training available where I live as there is insufficient demand and no books available on Flash or ActionScript at the local book stores or libraries so the books are ones I have ordered via the Internet.  The one I am currently using apart from Adobe Classroom in a Book Flash CS4 is O'Reilly's Learning ActionScript 3.0 a Beginners Guide.
    The other problem I have been trying to solve and still researching is why one loses sound in the flash player when playing flv files, if the user has selected or restarted a video (or videos) many times eg 25 to 30 times as we create video training files and serve them to the user within the flash environment using Flash Player 9 and IE6.
    Regards
    Norman

  • Load external SWF file into another SWF

    Hello all.
    I've tried loading a .swf file externally into another .swf file on my  local drive, and it works. Now, when I try to Simulate Download, the  preloader in the 2nd file doesn't get played and the images in there  take a while to get displayed.
    I need to load a .swf file from a server into the parent .swf file(I'm  working on using a "thin flash file" for added security for the company I  work for - blank file which loads the content from another file on  their server).
    So far, I have:
    try
        var myLoader:Loader = new Loader();
        addChild(myLoader);
        var url:URLRequest = new URLRequest("newBook.swf");
        myLoader.load(url);
    catch (e:Error)
        trace("ruhroh");
    When I replace the "newBook.swf" with the URL of another .swf, there's just a blank page.
    I'm not too sure how to proceed, and I hope you will be able to help me out. I'd greatly appreciate the help.
    Many thanks,
    -Nazgul

    What happens is...when I set the speed to DSL(32.6kbps), the screen is blank and the preloader doesn't show up. It just goes directly to the Main screen. And then, the pages inside don't get loaded properly.
    This only happens when I try to Simulate Download.
    But that's not really the problem. I need to load a .swf file from a server into another .swf file, and just adding the link to the child .swf isn't working.
    Anyway, thanks for your help
    -Nazgul

  • Loading external swf file

    Hi all,
    I am trying to load an external SWF file into my website.. but it is not working. Here is my code
    public var CD:Loader=new Loader();
    protected function application1_creationCompleteHandler(event:FlexEvent):void
    CD.load(new URLRequest("http://localhost/assets/slide.swf"));
    addChild(this.CD);
    CD.x=2;
    CD.y=170; 
    // TODO Auto-generated method stub
    Can anyone tell me what is going wrong..
    The url is correct and its working in my browser when i type 'http://localhost/assets/slide.swf' in the browser... So problem is with flex..

    I am pretty sure that Flash's security measures prevents the coder from loading swfs that are not local to the swf that is trying to load them.  So the swf that is trying to load another swf would have to be on the same system or same networked server.  From what I have experienced its best to reference the location of the files from the swf that is doing the loading.  I am not sure if you are still referencing your swf as "http://localhost/assets/slide.swf" but that might be a problem as well.
    so
    mainfolder
    movie.swf
    assets
    slide.swf
    so in movie.swf
    //Start: Put in desired function
    var swfLoader:Loader = new Loader();
    swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    swfLoader.load(new URLRequest("assets/slide.swf"));
    //End
    Also add this function
    public function loadComplete(e:Event):void
         stage.addChild(e.target.content);
    This might help explain it
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html
    the first set of bullet points highlight the security options
    ps. I got this working on my end, copy and pasted the code, of course i had to recreate the file system structure and slide.swf

  • How to load external SWF used sharing library.

    Hi~~~
    Before ask the question, plz understand my bad English..
    Recently I try to load the Swf file that is maded by Flash CS 6.0.
    Especially it used shared library..
    When I try to load this SWF, I used FileStream instead URLRequest.
    This is because the target SWF File located same device with the Swf Application.. So when I use the URLRequest
    it give me the warning - Sandbox security violation.
    But by using FileStream, the warning did not occur.
    This is the sample code below..
      var myFile = new File(path);
      var myStream = new FileStream();
      myStream.open(myFile, FileMode.READ;
      var myBytes:ByteArray = new ByteArray();
      myStream.readBytes( myBytes );
       mSwfLoader.loadBytes( fileStream, context );
       mSwfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadedComplete);
    As you can see, I made a event listener to get the content of the Loader, after receving Complete Event(I guess.. after decording?).
    But I can't receive any event call, so I removed symbol used sharing library in the SWF.
    And this gave me the result as I respected... So I guess the problem caused by using sharing Library..!
    (In parenthease, I can see the valid result in running debug time on the Flash CS6..)
    What should I do? I respect that using sharing libary give saving memory.  So I want to using it as possible.
    Thanks for your reading...!

    Here is one way:
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f9c.html
    HTH,

  • Loading external SWF fila and accessing variables/functions

    Hello everybody!
    My first post here. Actually I do search google for answers all the time, but now - it's tough one.
    public function loadScreen(swf:File):void {
         _content = swf;
         var swfBytes:ByteArray = new ByteArray();
         var file:File = _content;  
         var loadStream:FileStream = new FileStream();
              loadStream.open( file, FileMode.READ );
              loadStream.readBytes( swfBytes );
              loadStream.close();
         var loader:Loader = new Loader();
         var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
              loaderContext.allowLoadBytesCodeExecution = true;
              loader.loadBytes( swfBytes, loaderContext);
              loader.contentLoaderInfo.addEventListener(Event.INIT, accessSWF);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
    public function errorHandler(e:Event):void {
         trace("PROBLEM LOADING BYTES");
    public function accessSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.content.addEventListener(Event.INIT, readyHandler);
    public function readyHandler(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
    The problem is that application loads the external swf with loadBytes, but it's not executing the script. Actually, I'm not able to use the loaded swf. I'm not able even to add it to Stage. But message in output still shows, that the swf file is loaded "[SWF] file.swf/[[DYNAMIC]]/1 - 2746 bytes after decompression"
    There are many solutions for this problem on the internet, but they're old (written in 2008 most of all) and not working either, because those solutions work only in older AIR versions
    Any help?

    Well I got a bit further:
    public function loadScreen(swf:File):void {
         var loadStream:FileStream = new FileStream();
         with(loadStream) {
              openAsync( swf, FileMode.READ );
              addEventListener(ProgressEvent.PROGRESS, loadProgress);
              addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
              addEventListener(Event.COMPLETE, loadComplete);
    public function loadProgress(e:ProgressEvent):void {
         trace("Loading " + e.target.bytesAvailable);
    public function errorHandler(e:IOErrorEvent):void {
         trace("Error ");
    public function loadComplete(e:Event):void {
         var swfBytes:ByteArray = new ByteArray();
         FileStream(e.target).readBytes( swfBytes );
         var loaderContext:LoaderContext = new LoaderContext();
         with(loaderContext) {
              allowLoadBytesCodeExecution = true;
         var loader:Loader = new Loader();
         with(loader) {
              loadBytes( swfBytes, loaderContext);
              contentLoaderInfo.addEventListener(Event.INIT, completedSWF);
    public function completedSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.addEventListener(Event.COMPLETE, initiatedFinally);
    public function initiatedFinally(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
         var loader:Loader = e.target.loader;
         loader.addEventListener(Event.ADDED_TO_STAGE, irAdded);
         _window.stage.addChild(loader);
    public function irAdded(e:Event):void {
         trace(e.target.content.vars); // Object Dictionary
    At this point ( function irAdded ) I'm able to retrieve external SWF's variables. But stil, it's not visible on the stage. And yet - there's another problem - rendering the same script , every second time application unloads the external swf movie.

  • Is it possible to Load External SWF files into Flex Mobile projects?

    Hi Guys,
    I'm trying to load an external asset in this cse (a SWF file) into my flex project (Apple IOS IPAD), don't get any luck. Can any one suggest a solution ?

    In Apple's words, "No interpreted code may be downloaded or used in an Application except for code that is interpreted and run by Apple's Documented APIs and built-in interpreter(s)".
    Hence external swfs cannot be loaded in iOS.

  • How to load external text file into a Form?

    Hi,
    I made a menu with 1-5 in a Form and 5 external text files. I want the user who is able to view the text content of the text file when he chooses one of them from the menu. And the text file screen has a "Back" command button to let him go back.
    How can I do it and can it support other languages such as Chinese and Japanese?
    Thanks for help.
    gogo

    Sorry, I made the mistake about the subject, it should be loading local file, not external file through http.
    I wrote a method but it throwed an exception when the midlet was run.
    private void loadText()
    try {
    InputStream is = this.getClass().getResourceAsStream("/text.txt");
    StringBuffer sb = new StringBuffer();
    int chr;
    while ((chr = is.read()) != -1)
    sb.append((char) chr);
    is.close();
    catch (Exception e)
    System.out.println("Error occurs while reading file");
    I put the text.txt file in the same folder with the main file (extends midlet). How can I load the text content and display it on StringItem?
    Thanks for any help.
    gogo

  • How to load external swf and handle events of external swf by passing data .

    Hi all
    I have to laoad external swf (made in flash).On loading i have to pass data and hndle events which occurs on this swf.
    Can any one suggest me how can I achieve this.
    Regards
    Munira

    Here is one way:
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f9c.html
    HTH,

  • AS3 loading external swf files with buttons from inside a movieclip

    In my main .swf I have labels on the timeline, navs for those btns are on the first frame of the AS layer and each button sends the playhead to a different frame.
    On one frame called fr1 there is an mc called mc_1 that appears on stage when the playhead stops there. Inside mc_1 are a set of navigation buttons that need to call external .swfs.
    Do I add event listeners on the last frame of mc_1 for each button?
    how do I call the loaders for the swfs on the buttons since the swfs will load on the main timeline NOT the mc_1 timeline?
    So label on main timeline called fr1 will load external1 swf , on fr10 external 2.swf will load and so on.
    any help?

    The code for that button's event listener needs to be placed wherever it has direct access to the button.  Not necessarily on the same timeline, but in a place where both the button and the code are present at the same time.
    The code could be placed at the frame in the main timeline where the movieclip with the button(s) is, targeting the buttons via the movieclip (mc.button.addEvemtListener...) , unless the buttons are somewhere down the timeline of that movieclip.
    If they are down the timeline of that movieclip, then you would need to have the event listener also inside the movieclip, down its timeline where the buttons are finally settled in... being sure to assign instance names to the buttons at every keyframe.

  • Loading external swf files

    I have a Flash presentation where the chapters are made of
    seperate swf files. How can I link them, so they play in the
    correct order automatically? I will also need to make a clickable
    version. Any help greatley appreciated.
    Thanks
    D.

    dazzlah wrote:
    > I have a Flash presentation where the chapters are made
    of seperate swf files.
    > How can I link them, so they play in the correct order
    automatically? I will
    > also need to make a clickable version. Any help greatley
    appreciated.
    You could have one base movie which load your first movie in
    level 1.
    Then on the last frame of the first movie place an action to
    load next movie
    in level 1 as well, what automatically will replacing the
    previous loaded
    content with a new one. That's probably as simple as you
    could go.
    Tho, take note, that's good idea when comes to any flash till
    version AS3.0
    player 9. Loading in AS3.0 is ridicules, so it unloading of
    loaded content
    The functionality is no longer the same as in early versions
    so if you can
    export as2.0, you can achieve it using very basic methods
    like loadmovie action
    attached to last frame of the timeline.
    Best Regards
    Urami
    "Never play Leap-Frog with a Unicorn."
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • How to load large SWF files?

    I have created a flash game which is about 11 MB in size and i have created the progBar in the first frame of the swf...
    But it only shows the loading process after few MBs of data beign loaded...which might take some time and cause the user to close the tab..
    I dont want this to happen...How i could tell the user at least that the swf is loading without any percentage and all the animations..
    Like putting a <div> tag at the back of swf file..so until the swf load the div tag with "loading" message can be shown...I tried this method but it wasnt working for me and i dont know why.
    I hope flash masters at this forum could help me.
    Tq

    gameLoader.source="MapleCity0.1.13.12_800.swf";
    gameLoader.load();
    gameLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    gameLoader.addEventListener(Event.COMPLETE, completeHandler);
    gameLoader.addEventListener(IOErrorEvent.IO_ERROR, catchScoreIOError);
    function progressHandler(event:ProgressEvent):void {
        var uiLdr:UILoader=event.currentTarget as UILoader;
        var kbLoaded:String=Number(uiLdr.bytesLoaded/1048576).toFixed(1);
        var kbTotal:String=Number(uiLdr.bytesTotal/1048576).toFixed(1);
        ui.myLabel.text=kbLoaded+" of "+kbTotal+" MB"+" ("+Math.round(uiLdr.percentLoaded)+"%)";
        ui.myProgressBar.setProgress(event.bytesLoaded, event.bytesTotal);
    function completeHandler(event:Event):void {
        ui.visible=false;
        gameLoader.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
        gameLoader.removeEventListener(Event.COMPLETE, completeHandler);
    function catchScoreIOError(event:IOErrorEvent) {
        if (event.type=="ioError") {
            ui.myLabel.text="Cannot establish a connection to the server. Please try again later.";
        } else {
            ui.myLabel.text="ERROR : "+event.type;

  • [ISSUE] Load external .swf into an AIR for iOS app

    I want to load an external .swf which is included theme objects of the application. The loader class finishes loading but after this when I try to get objects in the swf I get this error.
    Device is iPad v.2 iOS v5.1.
    ReferenceError: Error #1065: Variable MenuHome is not defined.
        at adaptive.controls.thememanager::ApplyTheme/applyStyle()[D:\ConsumerProductInterface\Consu merProductBusiness\src\adaptive\controls\thememanager\ApplyTheme.as:41]
        at adaptive.controls.thememanager::ApplyTheme/apply()[D:\ConsumerProductInterface\ConsumerPr oductBusiness\src\adaptive\controls\thememanager\ApplyTheme.as:54]
        at adaptive.controls.thememanager::ThemeManagerSystem/checkIfAllLoaded()[D:\ConsumerProductI nterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeManagerSystem.as: 139]
        at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()[D:\Consum erProductInterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeManager System.as:119]
        at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()
        at flash.events::EventDispatcher/dispatchEvent()
        at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()[D:\Con sumerProductInterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeMana gerImageLoader.as:60]
        at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()
        at flash.events::EventDispatcher/dispatchEvent()
        at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()[D:\ConsumerProductInter face\ConsumerProductControls\src\adaptive\controls\imageloader\ImageLoader.as:32]
        at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()
    Steps are:
    1- Create a .fla file and one object in it (like below):
    2- In Flash Builder 4.6
    Load the external swf:
                    var swfLoader:Loader = new Loader();
                    var url:URLRequest = new URLRequest("themes/DefaultTheme/DefaultTheme.swf");
                    var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                    swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
                    swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                    swfLoader.load(url, loaderContext);
            private function completeHandler(event:Event):void
                var evt:LoadThemeSWFEvent = new LoadThemeSWFEvent(LoadThemeSWFEvent.COMPLETE);
                if (AdaptiveHelper.getInstance().platform == PlatformType.DESKTOP)
                    evt.swfLoader = SWFLoader(event.currentTarget);
                else
                    evt.loader = Loader(event.currentTarget.loader)
                dispatchEvent(evt);
              // load is OK
            private function ioErrorHandler(event:IOErrorEvent):void
    After load is complete I tried to get the object from the swf file and use it as a skin class of a button.
    cssSelector.setStyle(property, Class(content.loaderInfo.applicationDomain.getDefinition("MainMenu")));
    I am stuck here. Any ideas what the problem is?
    My Best,
    Suat

    Hi Suat,
    Can you send me a sample application  @[email protected] with which I can reproduce your problem and can look into the issue?
    Thanks,
    Nimisha

Maybe you are looking for

  • Help needed to interpret kernel panic

    Hello everybody Recently I've had a couple of kernel panics on my MacBookPro 13'' (OSX Lion 10.7.2 version, 2,26 GHz Intel Core 2 Duo, 8GB 1333 MHz DDR3) The last one occured today : I was opening Google Earth (the last version) to see the GPS positi

  • Datagram Sockets

    Hi Folks. I am curently devising an presence service andinstant messaging system on UNIX. The problem is I am looking to open a datagram socket connection with a client on another computer on port 1115. Hhow am I able to send them a message without t

  • Web service not listed in web service navigator

    Hi all, I'm on NW70. I developed a staless session ejb and exposed it via WS. Deploy was ok and the .ear archive seems to contain both the ejb and the .videf and .wsdef files. However I cannot find the WS in wsnavigator. Also accessing the WS from ht

  • Why doesn't my program open? Error message states "not enough RAM" but I have 5 GB avail

    I have Elements 2.0. Have been using it on 3 computers. Suddenly this laptop won't even open the program. Error message states "not enough RAM" but I have 5 GB available. How can I fix this. No problem on other computers with same Windows 7, Elements

  • Solaris 10x86 06/06 HP DL585 G1 with Grub issues.

    Hello, I'm trying to understand why Solaris 10x86 06/06 hang just after grub on HP DL585 G1! If I add the option "-v" (kernel /platform/i86pc/multiboot -v) then the system will boot up and work fine, without error on screen (Is there a way to redirec