1 person found this helpful
IOS doesn’t support running ActionScript in a loaded SWF. Your main SWF is cross-compiled. Any code in loaded content isn’t so it won’t run.
Couple of things:
1. The code doesn't work in a regular Flex (non IOS packaged) app either. That shouldn't have that dynamic code loading limitation.
2. The way I read the IOS limitation was different. I took it to mean you couldn't load dynamic content at runtime from remote places - things not included in your packaged IPA. Does that go, as well, for code local to your installed app and included with it in the packaged IPA? What is the precise guidline here and from what documentation does it come?
Not all SWFs are designed to be loaded as sub-apps so there might be a problem with the AS2 swf.
You can interpret the limitation any way you want, but the fact is, the runtime will not execute ActionScript in a loaded SWF on IOS.
I don't want to interpret it. I want to see the documentation on it. Then interpretation won't be necessary.
The problem is that iOS will not be able to read any SWF format* at runtime. Any SWF content your app uses must be cross-compiled into native ARM code to run on iOS. This means that all classes and symbols must be referenced somewhere as code so the compiler can pick them up.
Since these SWFs are still in AS2, I am assuming you no longer have the source, which may present a problem if they were not set up to be linked in this way. If you can give more info on the nature of these SWF files you're trying to use, I may be able to suggest a few strategies on getting this content to run in iOS (and other devices of course).
* I am told basic "image" like SWFs with no code or timeline should work, but IMHO it's probably better to use an actual image at that point...
I hear what you are saying. I was looking for documentation on it. Where are you reading this from?
On the nature of the swf's, they are PowerPoint slides converted to Flash by third party products. As such, they can't be linked in as code. For one, the content in them is updated frequently, sometimes daily. I can't submit updated app builds to the Apple store every day. Not practical. The slides need to be independent of the app so they can be updated regularly and called dynamically.
It seems PowerPoint to Flash conversion products, by in large, produce AS2 output for some reason. Not sure why. Probably just a difficult thing for the converter vendors to update.
Problem seems simple. How do you show animated slides in a packaged IOS app? Again, can't link them in as code because they are updated frequently.
1 person found this helpful
Sounds like you work in "eLearning". I feel your pain...
I don't think I read this anywhere specific. It's coming from my understanding of the iOS developer guidelines, a basic understanding of how the compiler works, and a year long headache from having to deal with these problems myself.
In short, you will need to abandon runtime SWF model if you want your content to run in iOS. SWFs that don't require user interaction can be converted into flv and streamed to the app. You will probably want to automate this somehow. I used Moyea* since it has a batch process. Everything else will need to be converted into some kind of data-driven format so you can load and interpret it at runtime in your application. I ended up creating what is essentially a dumbed down run-time MXML interpreter, along with a server-side compile process that resolves any bindings or code expressions into static data (for templating). This was quite an undertaking however...
Cheers and good luck!
*Note: There may be better programs for this. Using Moyea, I had to first convert to H.264 mpgeg, and from there to flv using Adobe Media Encoder. For some reason, nothing else worked except for that exact combination of encodings...
Yes, pain is the proper designation
The curious thing is that Adobe Connect is using the runtime SWF model somehow, so I know a solution exists in this realm. If I upload a PowerPoint into Connect, AS2 swf's are created on the server. There are no FLV's created. If I go fire up Connect on the iPad, these swf's are immediately available and animations run (images are not flattened).
Further, if I take these AS2 swf's and load into my iPad app dynamically, they do load and animations run. They loop though (because stop() commands in each one are ignored on IOS). Any thoughts on how they are doing that? There are definitely no FLV's created so I know they are not going that route.
Well I know for sure that any code will be ignored and may prevent the SWF from working entirely. I have heard that basic timeline (no tweens or anything) sometimes works, but I have yet to hear of a success story where SWF content turned out to be a viable option (someone please correct me if I'm wrong!). Perhaps you will have better luck with this. I think it really just depends on what's in all these SWF files, and if these 3rd party tools you are using include any code in the output.
Almost all of our SWF content had at least some code in it, so this was a moot point for us.
After re-reading your original question, you are saying these SWFs already work fine? The problem is that you can not load a SWF that loads them? Well then you may be in luck my friend! The problem is that you are executing code to load the extra SWFs. Can this code be moved into the main app? That would be your data driven architecture right there. Just feed the app some data that tells it what SWFs it should load. Assuming all the other animations are playable, this would probably be your best bet.
Just to reiterate, Adobe Connect has definitely solved this with swf's so we're working from an assumption that it can be done. If you feed a PowerPoint to Connect, it converts it to individual swf's and these are indeed loaded and displayed properly on the iPad.
That said, to your question about "can this code that loads the extra SWF's be moved into the main app" - I'd like to do that. How can I do it if my app is AS3/Flex Mobile and that code that loads extra swf's must be AS2? Do you have a suggestion there?
The reason the code has to be AS2 is because the swf's it loads are AS2. I'll explain.
The extra swf's are AS2. They do indeed load into my iPad app dynamically and look great. The only problem I have is that I can't stop the animations from looping. So when I load up slide #1, the animation in it loops. When slide #2 loads up, its animation loops too - and so on.
If you think about it, it makes sense. Stopping the animations would require AS code - a "stop()" call in the last frame of each slide. On IOS, however, that would be ignored. And that's what I'm seeing.
My thought was, as you indicate, that I could include code in my app to fix the problem. This code would be told to load the next slide, and *most importantly* to ask each slide when its animation was done and stop it - in essence to "reach in" to each slide from my app code, and tell it to stop() its animation when currentFrame == totalFrames, or something to that effect.
Sounds like a plan. Problem is my app is AS3 and the slides are AS2. That's why I was trying to include AS2 code in the app somehow but I couldn't figure out how to link it in properly. Can that be done? I realize I would need to communicate with it via LocalConnection, but how do I actually link the AS2 code into my AS3 Flex app?
Ah, yes. Using an AVM1 SWF could prove difficult...
I'm going on about 3 hours of sleep at the moment, but let me toss out a few thoughts I have and hopefully something will stick...
Ok, so my first thought what to try and cast the loaded content as a MovieClip and call methods on that, but the fact they are AVM1 throws that out the window.
That leaves LocalConnection, as you mentioned. But this would require you to have code on the receiving end to handle the connection... no good either.
But what if you created a "bridge" in AS2 that holds all the code for the receiving end of LocalConnection (or has the control logic itself, perhaps even eliminating the need for LocalConnection all together!). I think maybe this is what you were trying to do already by loading a SWF into a SWF? Well instead of loading your bridge at runtime, what if you statically linked it into your project as a class?
*a few moments later*
Well it looks like you can in fact link in a a symbol created for AVM1, but it will only come in as a SpriteAsset, and will not include any custom code (which makes sense, since they use entirely different class constructs).
To do the test, I created a symbol exported for actionscript (AS2/Flash8), then linked it in with a CSS style embed. I then instantiated the class and called describeType on it.
So in summery, it looks like calling custom code on the bridge is out (I did not test this extensively, that was just my first impression with this simple test). However, if you may be able to perform the actions you need by attempting to cast the loaded content into something AVM2 can recognize. Apparently it does this automatically when linked in statically, so maybe there is something there worth looking into... mainly, can you do what you need using only the base class and no custom code?
Keep me posted!
Wow, 3 hours? Best get yourself some sleep before you crash and burn.
Yes, the bridge is where I was going with loading a swf into a swf I thought if I could somehow place functions in there that I could call through a LocalConnection (like loadNextSlide() and stopAnimation(), etc.) that I could control the loading and play back from there.
I'm not the best Flash guy so I don't know how to do as you suggest - "link in statically". I only know my way around the Flash IDE enough to break things I know how to go into the actions panel and create a few functions but I'm not sure how I'm supposed to save that in such a way so as to make use of it in Flex. Any direction here would be appreciated. When you wake up of course
@rexdtripod, were you able to make any progress on this? I'm in a similar situation, except that I have as3 swfs I'd like to load at runtime into the iPad. The swfs need not contain any actionscript - i'm just looking to play the animation, just like you postured when you said:
to "reach in" to each slide from my app code, and tell it to stop() its animation when currentFrame == totalFrame
Thanks for any insight you might have!!