-
1. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Kevin Newman Feb 15, 2013 1:27 PM (in response to amandeepsiin)It's been a while, but I believe you can only load "dumb" assets from
remote servers - that is SWFs with no bytecode. Just having bytecode is
enough to invalidate them. To be honest, I'm not even sure a clean SWF
(with no ABC or actionscript bytecode in it) will pass Apple's
guidelines - it's ultimately up to them.
For certain I can tell you, the iOS AIR bundle doesn't have the
necessary plumbing (a jit) to run any bytecode from any SWF, even if you
were allowed to load it (or figured out how to get the SWF under Apple's
radar, which I wouldn't recommend even trying). You'll need to compile
all AS3 into the main application.
Kevin N.
-
2. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Nimisha1 Feb 18, 2013 10:21 PM (in response to amandeepsiin)Hi Amandeep,
You can't load a swf from a remote server which contains ActionScript.
Thanks,
Nimisha
-
3. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Nimisha1 Mar 15, 2013 12:36 AM (in response to Nimisha1)Hi,
A new feature "External hosting of secondary swf files (iOS)" has been introduced with AIR 3.7 , please get more info @http://labsdownload.adobe.com/pub/labs/flashruntimes/shared/air3-7_flashplayer11-7_release notes.pdf
To use this feature please download AIR 3.7 build from http://labs.adobe.com/downloads/air.html.
Please share the feedback with us.
-Nimisha
-
4. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 15, 2013 4:36 PM (in response to Nimisha1)I’m very excited about this feature since it addresses specifically the needs of my app.
However, I couldn’t make it work. The stripped assets file downloads fine, but when I try to access its content (ie. instantiate a symbol by its library name) the debugger states that the symbol doesn’t exist in the library, as well as that the custom class it’s linked to (via Base Class) doesn’t exist:
[SWF] SWFDownloadTest.swf - 944 bytes after decompression
ReferenceError: Error #1065: Variable CustomClass1 is not defined.
[SWF] /test/SWFDownloadTest/assets/assets.swf - 5,481 bytes after decompression
Symbol meepit doesn’t exist in the library or error loading the libraryThe last line it's a custom trace statement that pops up when:
ApplicationDomain.currentDomain.hasDefinition("meepit")
returnsfalse.I followed the example in the AIR 3.7 Release Notes regarding the LoaderContext, so that shouldn’t be the problem.
Anybody has had any luck in making this work? -
5. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
CraigMurray_ Mar 18, 2013 10:06 PM (in response to vikkiana)If I'm reading correclty, this new feature only lets you downloaded swf files with no bytecode from an external source instead of including them in the original package. So "export for actionscript" might not work to get your art into the final swf that you publish (and later load). As a result you'll either have to create the swf in FlashBuilder (the best way) or you need to put your asset on the stage.
Look into your published swf and see if the art is even in there. Check the link report. Most likely it never got into the stripped swf file to begin with, so when you load that swf, the asset is not there.
-
6. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Colin Holgate Mar 19, 2013 6:16 AM (in response to CraigMurray_)I think/hope, that you're misunderstanding the new feature. The "export for action script" code will already be embedded in the app file. The new feature is all about hooking up the code-less swf with its original class files.
If there ends up being an issue where the host FLA's classes can't directly get at the library symbols of the loading code-less swf, perhaps the loading swf could have a public utility function that the host could call, that would hand back one of the library symbols from the swf being loaded.
-
7. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 19, 2013 12:36 PM (in response to Colin Holgate)Hei Nimisha,
any word on this? Is there a specific API to access the library symbols of the loaded library like Colin suggested?
How is the stripped code 'reconnected' to the library item?
-
8. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
CraigMurray_ Mar 19, 2013 12:47 PM (in response to vikkiana)To get at a symbol in a dynamically loaded swf you use getDefinitionByName("mysymbol").
As far as me misunderstanding it, I'm pretty sure I'm not. There is no way to run swfs in iOS that contain code. The code in a swf is ABC (actionscript byte code) which cannot be interpreted on iOS. Instead the iOS publisher translates as3 to objective-c and natively compiles for iOS. So a published swf will not run, regardless of this feature. Additionally if the suggestion is that you can publish a swf file natively for iOS with native code in it, and load that dynamically... well, first of all it doesn't work that way, and second of all, Apple would never allow that.
This feature is designed to allow you to put art inside a swf, load it dynamically, and display that art on iOS. All code must be compiled into your main game as native iOS code.
PS: if you are using getDefinitionByName and the file still appeasr to be missing, make sure you set a linkage identifer so it is included in the published swf. The special compiler flag used to strip the bytecode out will still do so, but presumably it will leave the symbol in the linkage list so it appears in the final output swf. If not, I would suggest there is a bug in this feature because the only other way to get it to exist in the output swf is to put it on the stage.
-
9. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Colin Holgate Mar 19, 2013 1:02 PM (in response to CraigMurray_)What code do you talk of? If it's the code that was in the swf, that the compiler strips out and stores in the main app file, why did it do that if the code can not be used when the swf is reloaded?
-
10. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 19, 2013 1:07 PM (in response to CraigMurray_)This new feature of AIR 3.7 ADT compiler is supposedly able to 'strip' the code from the to-be-loaded swf at compile time and add it to the main app file. This operation is done with the command-line ADT compiler. Once the to-be-loaded swf has been stripped of its code, it is uploaded on the server. Supposely this swf dosen't contain code anymore, so it can be downloaded by the app.
What is not clear is how the code gets 'reconnected' to the swf (metadata?) and if the usual
getDefinitionByName("mysymbol").
will work with this 'special' stripped swfs as well.
Please refer to the AIR 3.7 documentation for more info: http://labsdownload.adobe.com/pub/labs/flashruntimes/shared/air3-7_flashplayer11-7_release notes.pdf
-
11. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Nimisha1 Mar 20, 2013 1:00 AM (in response to vikkiana)Hi Everyone,
Our team is working on a blog which will give you more info about this feature and I hope it will resolve all your queries
Please have patience.We'll keep you posted.
Thanks,
Nimisha
-
12. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
MasterDaijunjie Mar 20, 2013 1:36 AM (in response to vikkiana)vikkiana wrote:
I’m very excited about this feature since it addresses specifically the needs of my app.
However, I couldn’t make it work. The stripped assets file downloads fine, but when I try to access its content (ie. instantiate a symbol by its library name) the debugger states that the symbol doesn’t exist in the library, as well as that the custom class it’s linked to (via Base Class) doesn’t exist:
[SWF] SWFDownloadTest.swf - 944 bytes after decompression
ReferenceError: Error #1065: Variable CustomClass1 is not defined.
[SWF] /test/SWFDownloadTest/assets/assets.swf - 5,481 bytes after decompression
Symbol meepit doesn’t exist in the library or error loading the libraryThe last line it's a custom trace statement that pops up when:
ApplicationDomain.currentDomain.hasDefinition("meepit")
returnsfalse.I followed the example in the AIR 3.7 Release Notes regarding the LoaderContext, so that shouldn’t be the problem.
Anybody has had any luck in making this work?HI brothers, we encountered the same problem, experiment numerous times! Finally, no way! ! !
Is this a BUG, or what? Your last been solved?
-
13. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
MasterDaijunjie Mar 20, 2013 1:44 AM (in response to Nimisha1)HI Nimisha1
Load SWF from remote server with ActionScript in AIR based iOS ipa
ReferenceError: Error #1065: Variable CustomClass1 is not defined.
This error is what causes it?We understand that it was wrong what?If not, how they deal with?
-
14. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Colin Holgate Mar 20, 2013 5:44 AM (in response to MasterDaijunjie)I have seen a similar situation when trying to load swcs by their class name, and setting that class name in XML. The problem was solved by mentioning the class name in my code, which ends up making the feature less useful, but it's not too bad a solution, and certainly would be no big deal if the new feature worked that way.
So, for example, if this gives you errors:
var myclass:MyClass = new MyClass();
try doing this:
var myclass:MyClass = new MyClass();
Just the mention of MyClass in the code is enough to let the compiler know what you're talking about.
-
15. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 20, 2013 9:40 AM (in response to Colin Holgate)Did that
I always do mention the library classes when I load them in from an external swf, otherwise hasDefinition() returns false.
However, in this case it didn't work.
I want to mention that CustomClass1 is the base class of my meepit symbol in the library, and it is 'mentioned' in the document class.
FYI you don't need to actually instantite it, it's enough to create a variable typed to it.
-
16. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 20, 2013 9:41 AM (in response to vikkiana)thanx Nimisha!
-
17. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Mar 21, 2013 4:26 AM (in response to amandeepsiin)Hi everyone
The blog for the "External hosting of secondary SWFs on iOS" has been made live here :
We have tried to explain the entire workflow of using this feature as well as how the behavior of loading & hosting of assets/ swfs has evolved over the previous AIR releases using graphical representations.
I hope it will help clear the understanding of the entire feature.
Regards
Abhinav
-
18. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Mar 21, 2013 4:15 AM (in response to MasterDaijunjie)Hi MasterDaijunjie
Could you please share the sources of your sample application so that I could look into the issue.
Regards
Abhinav
-
19. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 21, 2013 11:14 AM (in response to Abhinav Dhandh)awsome!
I'll got through the blog, and try to make it work with the new info.
The process i was using was some what intricated , requiring me to
1. compile the assets swf with Flash Pro and Flash Player 11.7 (swf-version=20) tot eh assets folder in the src folder of my FB project
3. compile the main swf in Flash Builder 4.7
4. move the swf fromt he bin-debug to the src folder and run the ADT command from there using the assets compiled in Flash
5. manually install the resulting ipa on the device, upload the resulting swfs in externalStrippedSWFs to the server
6. run the debug command in FB again, but when the debugger starts, launch the manually installed app from the USB cvonnected device instead of launching the one installed by FB
7. Debug is working, but then I would get that Library problem
I'm sure this process is not foolproof, and actually last time I try I could get the debugging part to work, while the time it gave me the Library error I ddin;t compile the assets swf with 11.7 but with 11.6 so that might have been the problem.
I'll share my project so you cna have a look at it
thanx!
-
20. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
MasterDaijunjie Mar 21, 2013 7:53 PM (in response to Abhinav Dhandh)HI Abhinav Dhandh
I pass up the test examples, please help me see, thank you!
The inside has rem.txt file, there are some instructions!
-
21. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Mar 21, 2013 11:09 PM (in response to MasterDaijunjie)Hi MasterDaijunjie
I had a look at your sample project and below are some of my observations :
1. The text file for specifing the external SWF has not been added in the project.
2. The text file has not been mentioned within the <externalSwfs> tag within iPhone tag in the app-xml.
3. The loader is trying to load a SWF from the IP 127.0.0.1 which is the general IP of every machine. You will not be able to load a SWF using that generalized IP. Please host the SWF generated in the externalStrippedSWF to a server & pass that URL to the loader.
4. You will not be able to access the Stage object or any of the stage properties within the external SWF as the stage object retruns as null for the SWF loaded using Loader.
I would suggest you to make the above changes as well as have a look at this blog : http://blogs.adobe.com/airodynamics/2013/03/08/external-hosting-of-sec ondary-swfs-for-air-apps-on-ios and try to run the application again.
Please revert back if you are still facing any issues.
Regards
Abhinav
-
22. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 22, 2013 12:09 PM (in response to Abhinav Dhandh)Hi Abhinav
can you please look at this simple test project and let me know if you have any clue on what is going on?
please look at the README.txt file for additional info
https://www.yousendit.com/download/UVJoSlIwdVUzMWsxWjhUQw
Thanx!!!
Viviana
-
23. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Mar 26, 2013 3:53 PM (in response to vikkiana)any progress on this? I believe the file i attached will expire in 2 days, so I'm wondering if i need to resend it
thanx!
Viviana
-
24. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 4, 2013 5:32 AM (in response to vikkiana)Hi Viviana
I tried to look into this issue but the file is unavailable at the location. Could you please re-upload the file and mention the new link ?
Regards
Abhinav
-
25. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 4, 2013 10:05 AM (in response to Abhinav Dhandh)yes the file expires after a week on YouSendit
here's the file again, thanx fro looking at it
-
26. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 5, 2013 6:19 AM (in response to vikkiana)Hi vikkiana
I had a look at your project. One of the observation is that the SWF version for the main swf has not been set to 20.
Secondly, could you please confirm if you have created the symbol name in the secondary swf using the AS Linkage in Flash Pro ?
Also, could you please try to access the symbol using getDefinitionByName method ?
-Abhinav
-
27. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 5, 2013 12:08 PM (in response to Abhinav Dhandh)I rebuilt the app using the correct swv version settings. Now it doesn't give me strange "not an ABC file" errors and the loading seems to work fine.
However, when I try to access the symbol in the library (it's linkage name in the library, set with the AS Linkage in Flash Pro, is "meeepit" and the base class is now a simple MovieClip) I get
error #1065 - Variable meeepit is not definedHere's the new main app code:
package {import flash.display.Loader;import flash.display.Sprite;import flash.display.StageAlign;import flash.display.StageScaleMode;import flash.events.Event;import flash.net.URLRequest;import flash.system.ApplicationDomain;import flash.system.LoaderContext;import flash.text.TextField;import flash.utils.describeType;import flash.utils.getDefinitionByName;public class SWFDownloadTest extends Sprite {public var loader:Loader; `public function SWFDownloadTest() {super(); // support autoOrientsstage.align = StageAlign.TOP_LEFT;stage.scaleMode = StageScaleMode.NO_SCALE;loader = new Loader ();loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getClass);var req:URLRequest= new URLRequest("http://images50.neopets.com/test/SWFDownloadTest/assets/assets.swf");var lc:LoaderContext = new LoaderContext (false, ApplicationDomain.currentDomain, null); loader.load(req, lc); }protected function getClass(event:Event):void {try{var cl:Class = getDefinitionByName("meeepit") as Class;var meep:* = new cl();addChild(meep);} catch (e:Error){var tf:TextField = new TextField ();tf.width = 500; tf.height = 300;tf.wordWrap = true; tf.multiline = true;addChild(tf); tf.text = e.message;}}}}and here's the linkage:
thanx!
Vv
-
28. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 8, 2013 5:39 AM (in response to vikkiana)Hi vikkiana
I looked into your issue again and the issue seems to be due to AS linkage which you have created in your secondary SWF. I created another secondary SWF with an image and then converted this image to symbol with the symbol name as "meepit" and this SWF works perfectly fine with your application.
Could you please try the issue again with the secondary SWF as well as your project I have shared at the below links and confirm if your issue is resolved ?
Secondary SWF : https://www.dropbox.com/s/3ybw9zk1yzwkope/meepit.swf
Modified Project : https://www.dropbox.com/s/tf5l0kt7y716ann/SWFDownloadTest.zip
-Abhinav
-
29. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 8, 2013 4:31 PM (in response to Abhinav Dhandh)hi Abhinav,
unfortunately your version didn't work either;
it was not clear if the secondary swf you attached has been stripped already or not. I try to use it as it was stripped (uploading it on my server) but upon download I got a notice that the app was trying to process uncompiled code, so I assumed it was not stripped yet.
I proceeded in processing the main swf (form the modified project you attached) and the new secondary swf you attacched calling the ADT and generating the ipa. Unfortunately, upon launchin the app on my device, I got the same response:' error #1007: Instantiation attempted to a non constructor'. It also traced that the symbol was not in the library.
so no luck yet
PS I noticed you had selected to compile the secondary meep.fla with AIR 3.6 for iOs in Flash Pro. I'm compiling this secondary swf for Flash Player 11.7, in Hellcat. Not sure it's relevant
thanx
Vv
-
30. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 8, 2013 4:31 PM (in response to vikkiana)what exactly did you change in my project/secondary swf?
-
31. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 9, 2013 12:25 AM (in response to vikkiana)Hi vikkiana
I tried the issue once again and the only changes which I did in your project was :
1. Changed the URL of URLRequest of the secondary SWF to my server. In my case the url looks something like : "http://example.com/asset/meepit.swf".
2. Changed the contents of assetsinfo.txt to assets/meepit.swf
3. Added the "-swf-version=20" in the project's Actionscript Conpiler settings.
After these changes the project works fine and the SWF loads correctly without any errors.
I would suggest you to make the changes mentioned above in your Flash Builder project using the "meepit.swf" I shared in the previous mail and try the issue again.
Also please try to load the SWF in a simple HelloWorld project without using any helper classes like LibraryLoader.as used in your project in the Loader's Complete handler.
If you still face the issue than please revert back to me.
-Abhinav
-
32. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 9, 2013 11:56 AM (in response to Abhinav Dhandh)Attached is my project with the modifications you suggested:
https://www.yousendit.com/download/UVJpNWNsT01samVybHNUQw
1. added -swf-version=20 to the compiler arguments
2. Generated a swf of my main app by 'cleaning' the project in FB and copying the resulting SWFDownloadTest.swf from the bin-folder to the src folder
3. I copied your attached 'meepit.swf' to the src/assets folder to generate the stripped swf with the following ADT command:
C:\Adobe Flash Builder 4.7\SWFDownloadTestOld\src>adt -package -target ipa-app-store -provisioning-profile D:\documents\admin\AppleDevelopment\2013-new\Team2.mobileprovision -storetype pkcs12 -keystore D:\documents\admin\AppleDevelopment\2013-new\iphone_dev.p12 -storepass 2222 SWFDownloadTest.ipa SWFDownloadTest-app.xml SWFDownloadTest.swf assets/assetsinfo.txt assets/meepit.swf
4. I uploaded the generated meepit.swf to my server.
5. I installed the resulting .ipa on my device
6. Launched the app, after a few seconds it showed the error #1065- Variable meepit is not defined
PLEASE NOTE: my app is calling a dev server that will give you errors becouse you are outside of my network.Change that to your own server to test my project.
thanx
Vv
-
33. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 10, 2013 2:45 AM (in response to vikkiana)Hi vikkiana
The project which you shared works perfectly fine with just the change of server URL to my server without any errors.
Can we schedule a Skype call sometime so that the issue which you are facing is resolved ?
-Abhinav
-
34. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 10, 2013 11:36 AM (in response to Abhinav Dhandh)Tried again uploading the assets to a different server (http://www.artside.us/viviana/test/assets/meepit.swf), same result:
[SWF] SWFDownloadTest.swf - 818 bytes after decompression
[SWF] /viviana/test/assets/meepit.swf - 14,988 bytes after decompression
Error #1065: Variable meepit is not defined.
Yes for the Skype call, I'm available anytime from 9 am to 11 pm PST, vikiana_on_air; let me know wht time you're going to call
thanx!
-
35. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 10, 2013 10:39 PM (in response to vikkiana)Sure.
-Abhinav
-
36. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 23, 2013 5:25 PM (in response to Abhinav Dhandh)hei Abhinav
just wanted to let you know that it finally worked and I finally got that sweet Meepit image on my iphone
I really didn't do anything different that what we tried until now. Only, I downloaded a fresh copy of the AIR 3.7 SDK that was released today on Adobe. That might have made the difference.
Thanx for all your help
Viviana
-
37. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 23, 2013 9:47 PM (in response to vikkiana)Great !
It might be possible that some file(s) in your previous SDK were not copied/extracted properly.
However, if you still face some issues with this feature, you can always revert back to me.
-Abhinav
-
38. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
vikkiana Apr 24, 2013 2:30 PM (in response to Abhinav Dhandh)so I'm loading a compiled swf with a document class (SecretMeepitStache_v7.swf) in my SWFDownloadTest.
The swf downloads fine and its doc class starts running and it runs fine until it tries to access the stage to add a listener.
At this point AIR throws the following error:
SecurityError: Error #2070: Security sandbox violation: caller http://artside.us/viviana/test/assets/SecretMeepitStache_v7.swf cannot access Stage owned by app:/SWFDownloadTest.swf.
So is this a limitation of the download feature or is ther a workaround to access the stage from the loaded swf?
thanx!
Vv
-
39. Re: Load SWF from remote server with ActionScript in AIR based iOS ipa
Abhinav Dhandh Apr 28, 2013 11:42 PM (in response to vikkiana)This is a standard behavior across all platforms to prevent access to the stage for secondary swfs. It helps prevent any modifications which the secondary swf might make to the stage and cause issues with the working of the application itself.
As of now, there is no workaround using which you could access the stage.
-Abhinav





