• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

External swf import into Animate/AIR for iOS app

Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Hi

I am creating apps for AIR for iOS.

I am using external swfs that I am loading into the main app.

In  testing on the Mac it worked fine once I started using Loader COntexts and Application Domains for the external swfs.

I also found that where the external swfs shared the same classes they were more likley to clash and I also needed to switch off Automatically declare stage instances in some of the files creating the external swfs.

I had it all working good but now I have published to the iPad it isnt working.

I realised that I could only use ApplicationDomain.currentDomain in AIR for iOS - whereas before I was creating a seperate ApplicationDomain for each Loader context.

Now - just using ApplicationDomain.currentDomain - some of the external swfs load and others dont.

The ones that load ok either:

aren't using external classes (I did the coding on the timeline back in the day) these load fine

or arent sharing any classes from a shared class library.

A typical error I get when trying to load the external swf when using ApplicationDomain.currentDomain

is

ReferenceError: Error #1056: Cannot create property mc1_mc on Main.

  at flash.display::Sprite/constructChildren()

  at flash.display::Sprite()

  at flash.display::MovieClip()

  at Main()[/Volumes/PASSPORT815/EY 0-6 Content Devt/Multi Media/EY Superfile/iPad Files/Move/Main.as:127]

Does anyone have any tips as to what is causing this and how to avoid this?

Best

Tommy Banana

TOPICS
ActionScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 28, 2017 Mar 28, 2017

The more self contained the SWC is the better. All the main app should be doing is loading and unloading SWC, but any public variables in the SWC should be accessible. So for example if you want to ask the user's name in the shell app, it ought to be able to appear inside something in the SWC.

Votes

Translate

Translate
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

You can't use external SWFs with any code in them at all on iOS. What is the reason they are external? You could publish them as SWC, and include them in the ActionScript 3.0 settings for the app. Then they would work, without having to be developed all in one FLA.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Thanks -Colin.

Yes - the reason they are external is so I can use already developed work.

And not needing to have everything in one big FLA file.

I haven't used SWC before - can you recommend a place to find out how to use that?

Will the SWC be incorporated into the .ipa file?

Best Wishes

Tom B.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Great, it sounds like it could work out.

Make sure that each FLA has the entire experience is in a movieclip in the library of the independent FLA, and is using a unique linkage name. For example, if you had a game "MarioBros" you would have a movieclip in the library that had a linkage name of MarioBros. In the document class for that FLA you would do something like:

var mc:MovieClip = new MarioBros() as MovieClip;

addChild(mc);

Then in publishing settings you already have Flash(swf) checked, also check the next entry, SWC. When you test movie a SWC will be made, and that's what you add to the ActionScript 3.0 settings in the iOS FLA.

Make sure you have code that shuts down listeners when the movieclip is removed from the stage, so that as you go on to the next game the previous one is cleared from memory.

To use the game in the iOS app would be the exact same code:

var mc:MovieClip = new MarioBros() as MovieClip;

addChild(mc);

And yes, these SWCs get added to the IPA, even though they have code in them. One nice thing, it doesn't take much publishing time, the SWCs are already compiled, so only the shell FLA needs to be compiled again.

In each of the Heckerty apps I made every section is a different SWC. I'm even able to use several of the SWCs in all of the apps, there is no difference. Only the parts that are unique to that app are their own SWC, things like the current story, or the coloring book.

Meet Heckerty ā€” a free funny interactive family storybook series for learning to read English (#1 in...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Thanks Colin.

Do you control the SWC assets in the main asset eg start stop functionality - or can they be in the SWC assets as well?

I'll check that out. we are making apps for kids too - Music ones. I will check out your Heckerty!

This looks a good way to go - although quite a bit of work from here!!

Doesn't explain why some work and others do... and will mean starting again with the jib. But it is the right answer ....and so the journey of learning to code enters another chapter...

Best

Tom B.

www.abcmusic.org.uk

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

The more self contained the SWC is the better. All the main app should be doing is loading and unloading SWC, but any public variables in the SWC should be accessible. So for example if you want to ask the user's name in the shell app, it ought to be able to appear inside something in the SWC.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Thanks.

One more question.

If in the independent FLA I am using 3 main components -

say

1) an animation in a MovieClip with  a time line

2) a start stop button also as a movieclip

3) another class which a kind of interactive button allowing a user to interact with what is happening in the timeline animation.

I am guessing you wouldnt import those 3 elements into the holder FLA and recreate the game.

So do you nest all three of those elements in one Movieclip in the independent FLA so you can add it as one class from the SWC?

At the moment that is my game swf. How can  I access the whole swf as one thing from it's SWC without nesting it all inside a Movieclip?

Not sure if that makes sense....

Best Tom B

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

It's ok. I worked it out - it is dead easy as you know!

Wow that is so much better.

Thankyou.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

By the way, you might think that having your game experience directly on the stage of the game FLA should work, that adding the SWC to the shell's stage should immediately show its stage contents. Alas it doesn't work out, I've tried it. The using the library movieclip symbol is an easy solution to the problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

You are a wonderful man!

BTW are you interested in any occasional paid employment as a Flash/AIR/iPad App guru?

best Tom

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

If you have lots of money you don't need, sure.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Well - it saves me money ( stress and time) sometimes being able to ask for help from someone and we are about to start trying to get apps onto the App Store and I can see that you seem to know what you are doing....

I'll PM you an email!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

Colin,

One question.

Do you find that you have to untick 'Automatically declare stage instances' for the SWC to work.

I am finding that if I dont do that some of the SWC dont seem to load.

IF that is what I need to do I will - but I can be a lot of work for some of the more complex applications - to declare everything.

Best Tom B.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

The way I've worked is to have nothing on the stage, and to get the main movieclip from its library linkage name. I did it that way because things that are already on the stage don't appear. It could be that having something on the stage and automatically declaring it could then clash with the one you're trying to get from its library.

I test the FLA that will become SWC by putting a copy of the movieclip on the stage, do a test movie, then when I'm going to publish the SWC I make the movieclip's layer be Guide, so that it doesn't end up in the SWC. Or I just delete it, publish, then Undo to get it back for further testing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

Hi Colin

I am doing that and just adding the SWC movie clip in code on the Main.as for testing the FLA. T

hat is all fine.

However in the host FLA which contains ask the SWC I am finding that it can be working fine when tested as a swf using Animate, but then doesnā€™t work

once I put the .ipa into an iPad.

It seems to be something to do with Class names in the SWC and making sure none the class names are the same, and switching off "Automatically Declare ā€¦ā€ seems to make a difference.

Best Wishes

Tom Bancroft

tom@abccreativemusic.com <mailto:tom@abccreativemusic.com>

0131 510 0678

Primary Site: www.abcmusic.org.uk <http://www.abcmusic.org.uk/>

Early Years Site: www.abcearlyyears.org.uk <http://www.abcearlyyears.org.uk/>

"Teach Primary Creative Music on Your Interactive Whiteboard"

demo video here <http://www.abccreativemusic.com/?page_id=734>

Like us at facebook.com/ABCCreativeMusic <http://facebook.com/ABCCreativeMusic>

Follow us on @abccreativmusic <https://twitter.com/intent/user?screen_name=abccreativmusic>

Send me photos & videos https://www.hightail.com/u/abccreativemusictomb <https://www.hightail.com/u/abccreativemusictomb>

Whole Primary School 2 Month Free Trial: http://www.abccreativemusic.com/2monthsfree <http://www.abccreativemusic.com/2monthsfree>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

This is a public forum, you should think about whether you want to give telemarketers so much of your personal information!

You are adding the SWC's to the host FLA, in the ActionScript 3.0 settings, Library Path list? You don't include the SWC file itself as an external file.

If the library element gets added to the stage ok when you're testing then it should also work in the host FLA. But make sure you're not still adding the symbol to the stage with the Main.as for the SWC version, that could lead to problems. Only use host FLA code to add the SWC's symbol to the host stage.

I've done a lot of apps that use SWCs, so hopefully there is something you're doing wrong. If you're able to make a zip file of just enough for me to reproduce the issues, I could look to see if there's something to explain why it fails.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

LATEST

OK. I ill try taking out the Main.as code adding the MC and see if it makes a difference.

Many thanks

Tom B.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Suppose you have a normal FLA, with a document class and there is a main timeline full of stuff. You would put the timeline contents into the library movieclip, lined up so that when you do an addChild() the movieclip will look just like the original timeline did.

Take the document class of the FLA and make it be the Class file for the library movieclip. Don't have a document class for the FLA.

To test that it's ok you could drag the movieclip onto the stage, and do a test movie. Everything should work fine. For peace of mind you would either delete that stage copy, or make it be a guide layer, for publishing the SWC.

The SWC that gets made includes everything that was in the library of its FLA, you don't have to embed library symbols into the movieclip I've been talking about. If your movieclip is adding objects at runtime, that will continue to work.

One thing to make sure of, and this is the case even for loading external swfs, don't write any code that assumes the object is on the stage. Allow for the fact that it may be inside some other object. For example, in your app you might choose to have a container movieclip on the stage, that you add the SWC to. With that approach you can then scale and position the container movieclip for various device screens, without having to change any of the math that is in the SWC.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines