I am working on an app for my work, where I need to bring in several (around 8 to 9) SWFs into an flash file that is being published to an iPhone. I have the flash projects each of these SWFs were created in, but they did not use the timeline at all, instead each are completely made through code.
I was able to load in the SWFs and get them running on the phone, but only through interpretor mode in Flash. The issue with this is it is not reliable and causes massive slow down after extended use.
I know that the other modes support a single secondary SWF with actionscript.
Here is the code I am using to load in each one.
myLoader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("JavierNew/app.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, demoLoaded);
Does anyone have any solutions or suggestions for how I can better import these in a better fashion? To my knowledge there is no way to import the swf or the whole project file into the main .Fla, or a way to combine all the .swfs together.
Any help would be appreciated! Thank you so much!
Related
We are developing an iOS app using the air 3.9 sdk. Our application is such that we have 2 SWFs packaged inside the ipa file i.e.the main.swf and an experience.swf.
The main.swf is loaded initially using application.xml. A button-click within the main.swf loads the experience.swf (which is located within the bin folder in the ipa, NOT remotely downloaded). This experience.swf contains assets and code.
When we create an ad-hoc build, experience.swf loads perfectly the first time, but if the user returns to the main.swf and then tries loading the experience.swf again, it doesn't load. Just the default stage color is visible. (This problem only occurs on the ad-hoc build. The debug build has no such issues)
To load this experience.swf we are using the flash.display.loader with loaderContext set as the ApplicationDomain.currentDomain.
mcExperience = new MovieClip();
var url:URLRequest = new URLRequest("ChristmasExperience.swf");
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loader.load(url, loaderContext);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);
addChild(mcExperience);
private function CompleteHandler(e:Event):void
{
trace("I HAVE LOADED .... SWF loaded... , waiting for the constructor call back..." + e.target.loader.content);
//mcExperience.addChild(loader);
mcExperience.addChild(MovieClip(e.target.loader.content));
//TODO : Set the Session ID Here
m_experienceBase.SetSessionID(int(m_ExperienceSessionID));
m_experienceBase.SetLocalPlayer(m_localPlayer);
//(loader.content as MovieClip).soundTransform = new SoundTransform(0);
//addChild(loader);
//setChildIndex(m_tfConsoleMsgDisplay, numChildren - 1);
}
When the experience is unloaded, we remove the holder MovieClip of the experience.swf and unload the flash.display.loader. This still does not re-load the previously loaded experience.swf.
if (mcExperience)
{
mcExperience.removeChildren();
removeChild(mcExperience);
mcExperience = null;
}
We are using swf-version=22 for both main and experience swf.
This is quite a big problem for us and we've gone through a bunch of posts, to help understand this issue better (a few examples below):
Adobe AIR, IOS, and Multiple SWFs - Returning to a previously loaded SWF
Load and reload external SWF in AIR for iOS
http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/
Is there any way to reload a secondary swf within an ios application?
Don't know if you checked here:
http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/
Basically you cannot reload an swf on IOS and this is from Adobe's mouth.
To overcome this, Adobe came with a NOTE:
"Note: Reloading of pure asset SWFs will work with AIR 3.7 builds which can be downloaded from here"
Pretty lame if you ask me
So what you must do?
Well put the hole code as before in older air versions, in the first swf and use the second swf purely as graphic/animation resource.
While this is a big drawback, blame Adobe :D
Eventhough it says reloading of pure asset SWFs (SWF's w/o ABC) will work with AIR 3.7, I found problems with 4.0. I had SWF's with no code that did not work, and I needed a solution. I answered how I did it here: Load and reload external SWF in AIR for iOS and more fully here: http://www.eqsim.com/blog/?p=400
For my business I need to be able to show a potential client a website I generate with a program called Pano2VR, which is a virtual tour program. This program takes some panoramic photos linked with each other and can generate a virtual tour out of them (as example: www.casas-fotoart.de/virtualtours ). The output this App gives can be either HTML5, Flash or both (flash if available and html5 for mobile devices, for example).
I need to be able to show that on my iPad while offline. i haven't found any solution for that so I tried to build a easy App for that, which I thought it wouldn't be complicated.
I generated a html5-only virtual tour and I droped the output into the "Suporting Files" group on the Xcode project. I added a UIWebView and on viewDidLoad I set it so it loads the html file.
The files I'm droping are like these (these inside the ipad folder):
The html file loads into the webView, but it just displays "This content requires HTML5/CSS3, WebGL, or Adobe Flash Player Version 9 or higher.", even though when loading these files from the net, it loads perfectly. I know this message comes from the html file.
Any idea on how to make it work will be much appreciated. Thanks in advance.
Your problem is this probably - XCode is mangling the JS files, I assume because it's trying to compile them
I'm writing an application using as3 and adobe air that loads external SWF files and plays them internally in the application. The container works just fine with android and the animation of the external swf file is very cool.
However, on the iOS (iPad 2), it runs very slow as if its playing only 1 frame per second.
Is there anyway at all to make it play faster.
My application configuration is as follow:
<initialWindow>
<autoOrients>false</autoOrients>
<aspectRatio>landscape</aspectRatio>
<renderMode>gpu</renderMode>
<fullScreen>false</fullScreen>
<visible>true</visible>
<softKeyboardBehavior>none</softKeyboardBehavior>
</initialWindow>
This is the part of code where I load the external swf:
public function set url(value:String):void
{
_url = value;
object.source = File.applicationDirectory.resolvePath(value).url;
object.addEventListener(Event.COMPLETE , onLoaded);
}
protected function onLoaded(event:Event):void
{
object.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onEnterFrame(event:Event):void
{
if((object.content as Object).currentFrameLabel == "stop")
(object.content as Object).stop();
}
I also tried to comment the Enter frame event listener but nothing changed.
Thanks in advance.
Edit:
I figured out something that is very strange actually. When I run the application from the application with the Fast configuration, it runs fast. But when I publish it or use the Standard option while running it runs really slow.
Tested with AIR 3.2
try setting your render mode to direct:
<renderMode>direct</renderMode>
Remember, when you are rendering exclusively to the GPU, it will slow things down if you are rendering animations. Although rendering to the GPU is fast, allocating Video Memory to the GPU is slow. If you render exclusivity to the GPU, on every frame, the video memory will need to be updated.
Another thing is that all vectors will be rasterized so some things will render pixelated.
A couple of things:
You aren't allowed to load SWFs that have any code in them, in AIR for iOS. This is forbidden by Apple.
You should only use swf at most as a library of graphics / resources when compiling for iOS. If a movieclip inside has stop(); on one of the frames, then this counts as an 'addFrameScript()' under the hood, which means that SWF contains ActionScript.
I suggest if you need functionality as such, create a list of predefined behaviours to be compiled into your main app, then run these behaviours based on the type or name of asset you are instantiating from your SWF library, attaching them at runtime.
Besides, if you are doing this to allow updates -- or the ability to modify the app, post-release, then you may as well compile it into the release build, and just republish next time you want an update to the app. This will help your ranking in the app store to some extent, and remove a lot of versioning issues down the line.
For a project we need to download and save pdf files on an IPAD device for offline use through an AIR for iOs application.
After a lot of searching I haven't found much information on this subject. My question is, can it be done, and if so, can you provide us with some pointers to lead us in the right direction.
Thanks for your time!
Sure, first you check if you can access the web - can use a class like air.net.URLMonitor, if you can you can set up a URLStream instance.
You get data while its downloading the file using the progress event, write that out to a File instance using the FileStream class.
To display the PDF file you can use a StageWebView or HTMLLoader.
So I'm pretty experienced with OOP (I like to believe) and I just started with Flash CS5 and ActionScript.
I created a new empty file and added a button to it. Nothing else, no code at all.
I set in the publishing options the "Default linkage" option to "Merged into code" to see how big the download will be for those who are loading it for the first time without cache and the size turned out to be ~500KB which is a far cry from the ~20KB it is with the shared libraries option.
So, why is my file so big? I thought all the features I'm using are built in the flash player and no external libraries are required to load?
Also, is there a way to see what external files my swf depends on to run?
If your button is the default Flex button (as opposed to creating your own using pure as3), then you're probably bringing in the the entire Flex lib. It's why I stopped using it :)