Skip to main content
Participant
October 10, 2012
Question

ActionScript in external swf (iOS)

  • October 10, 2012
  • 1 reply
  • 853 views

I'm developing an app that will need to download external SWF's at some point. 

I'm aware that external SWF's cannot contain ActionScript, but have a few questions about that.

I've been doing a few tests in Flash CS6.  I'm intending on using Flash Builder later when I've proved that everything I'll need to be able to do is possible.

If I create an SWF that contains some AS code and put it on my webserver, my iOS app (running on an iPhone 4) CAN download this file.  I don't get any errors pop up to say that it is not allowed (I read in another thread that it would if it contains AS).  The code does not run but the movie still plays right the way through.  EDIT: I do get an error if I attach the remote debugger.

Now, this is fine as far as I'm concerned, provided it won't suddenly stop working on a non-debug build.  Obviously I'd like to avoid having any script that is not going to be used in these external SWFs but what if it creeps in there by accident?  Can it be stripped out by some tool?  Will I run into problems?  Will Apple come down on me like a ton of bricks / not allow the app to be released?

Another question about this. 

I will need to have some basic control of these external SWF's.  Some of the internal MovieClips will need to have images attached that change based upon the current frame.  Additionally I'll need to loop certain parts of the animation and change between these loops.  I also need to attach some behaviours to objects.

Presumably it is legal to use code that is already in the IPA and attach it to objects in the external SWF after I have downloaded it?

I can attach a frame listener that gives me control over the loops.  So thats good provided the app wont be rejected.

If I provide (nested) instance names for things then I appear to be able to access these in my test app.  Do instance names result in uncompiled ActionScript being added to the SWF?  Does that contravene Apple's app laws?  It does appear to work in my test app in that I can attach objects to a nested movie clip that is accessed by instance names.

One thing that doesn't work is accessing e.g. circle1.inner_circle.transform.  This causes the app to crash and abort.  I've verified that circle1.inner_cirle is a movieclip (but actually in the source FLA it is a derived class of MovieClip).   I don't think I need to access this particular thing at the moment - I only need to swap images out and control animations/play audio.  However, the crash is a concern.  XCode says the crash was an EXC_BAD_ACCESS.  iOS 5.0.1, AIR 3.2.  The callstack does not look useful.

Ok, so I guess thats a long set of questions, so to summarize:

1) Will external SWF's with AS code in them fail to run at all on a retail build or on some particular devices? Or will it simply not run the code?

2) Will loading of external SWFs without AS code cause Apple to reject the app, even though they will not have been authored at the time the app is released?

3) Do instance names cause an SWF to contain actionscript?  If it does, is there a way around this?

4) Does exporting movieclips for scripting cause disallowed AS code to end up in the SWF?

5) Is the crash accessing the transform property of a nested movie clip in an external SWF simply a bug?

6) Is there any way of adding additional string based properties to movie clips that can be accessed externally without scripting?

This topic has been closed for replies.

1 reply

Pete340Author
Participant
October 10, 2012

Well, running under the debugger appears to make it quite clear that you can't have objects exported for actionscript in an external SWF.

And additionally it looks like you can't access such objects if they only have instance names.

It would really be nice to be able to introspect a SWF file that was loaded externally using AS3 and make changes to it.

The external file doesn't really need to contain any code to do this - all of the code is in the file loading it.

I was initially thinking all my problems were solved but now it looks like that isn't the case.