Skip to main content
Participant
February 26, 2013
Question

SWF loading not working on AIR for iOS

  • February 26, 2013
  • 12 replies
  • 2383 views

Hey. Code running on Android, the iPhone does not work on. I want to do is this: there is a SWF file in a folder located in documentsDirectory. This is the file I want to load it into a MovieClip. The code I wrote below. Do you think what is the problem? Thank you for your help in advance.

import flash.events.MouseEvent;

import flash.display.Sprite;

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.events.ErrorEvent;

import flash.events.Event;

import flash.events.LocationChangeEvent;

import flash.events.StageOrientationEvent;

import flash.filesystem.File;

import flash.geom.Rectangle;

import flash.media.StageWebView;

import flash.net.URLRequest;

import flash.events.*

import flash.events.TouchEvent;

import flash.ui.Multitouch;

import flash.ui.MultitouchInputMode;

import flash.ui.Mouse;

import flash.display.Bitmap;

import flash.display.Loader;

import flash.display.LoaderInfo;

import flash.net.URLRequest;

import flash.events.Event;

import flash.filesystem.*;

import flash.filesystem.FileStream;

import flash.events.TransformGestureEvent;

var pf:Object;

var loaderSWF:Loader = new Loader();

var fileSWF:File = File.documentsDirectory.resolvePath("dergievi/1/dergi.swf");

loaderSWF.load(new URLRequest(fileSWF.url));

loaderSWF.contentLoaderInfo.addEventListener(Event.COMPLETE, setPosition);

function setPosition(e:Event):void{

          var contPF = new MovieClip();

          contPF.addChild(loaderSWF.content);

          ana_dergi.addChild(contPF);

 

          pf=loaderSWF.content;

          pf.width=640;

          pf.height=880;

}

This topic has been closed for replies.

12 replies

Nimisha1
Participating Frequently
February 27, 2013

Hi,

To use this feature on iOS you've to provide LoaderContext while loading a child SWF and LoaderContext need to have current ApplicationDomain. Like this:

var _urlRequest:URLRequest = new URLRequest(“mySecondarySwf.swf”);

var _loader:Loader = new Loader();

var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

_loader.load(_urlRequest, _lc);

To learn more about this feature please go through the following blog:

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

-Thanks

Participant
February 27, 2013

hello. Many examples of this type is not available. Because I want to install documentsDirectory directory. I wonder if there is an obstacle to reading the swf? Because I can read the text and pictures in the same directory. I added the following command line, but it still does not work.

new LoaderContext (false, ApplicationDomain.currentDomain, null);

However, the error does not try-catch block. Is also true, as a result of the control of the file.

URLRequest command to read the file on how to organize a local directory.

Nimisha1
Participating Frequently
February 27, 2013

It is possible to load a SWF from documents directory but you have to copy it from the apps'directory as secondary SWF needs to be packaged with the Main app for AIR-iOS. I am sharing a working sample project with you at dropbox which loads a child SWF from documentsdirectory on iOS @https://dl.dropbox.com/u/89259794/DocumentdirectorySWF.zip

Please look at the code and give it a try.

Thanks,

Nimisha

Nabren
Inspiring
February 26, 2013

That code should work - unless it is resolving the wrong path. Just note that you cannot have any symbols with a linkage name in the SWF - only contents on the stage with an instance name will work unless you package it with the build.