Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help integration a AS3 drawing game into a .fla

Explorer ,
Jun 18, 2015 Jun 18, 2015

Hi,

I created a drawing game by following a tutorial on this website : http://code.tutsplus.com/tutorials/create-a-basic-drawing-application-in-flash--active-1627

It was pretty straight forward. (you can download the source file to have the same code as me and save time).

Now to the fun part!

I previously created an iPad app in Flash. Works great by the way and is published on the App Store. (Search for : Henri Godon -> free app)

My client wants this drawing game to be incorporated in his app with a possibility of 3 different images to color opon. Which is pretty easy to do.

I thought that just doing a simple copy/paste and including the scripts would do the trick.... WRONG! I keep getting errors once I try to export it or test it out.

My App works great without the game. And the game works great alone. It's only one I try to embed it that I'm stuck.

Here are my errors, hope someone has an easy DIY way that I'm not aware of since I have never done this before.

ERROR 1:

1037 : Packages cannot be nested.

here is what it is referring to in the Main.as script :

package

{

  import PNGEncoder;

  import flash.display.MovieClip;

  import flash.display.Shape;

  import flash.display.DisplayObject;

  import flash.text.TextField;

  import flash.text.TextFormat;

  import flash.text.TextFieldType;

  import flash.text.TextFieldAutoSize;

  import flash.display.BitmapData;

  import flash.geom.ColorTransform;

  import flash.events.MouseEvent;

  import flash.events.Event;

  import flash.utils.ByteArray;

  import flash.net.FileReference;

  public class Main extends MovieClip

  {

ERROR 2:

Even if I try to remove that part, then I get an other error saying

1114: The public attribute can only be used inside a package. (which is kinda obvious)

1084: Syntax error: expecting leftbrace before var.

So nothing works after that...

I added the Main.as in the ActionScript setting in the Document class. So I know it is loaded in a way, but after that I'm stuck!

Please help out! I'll do anything.

TOPICS
ActionScript
4.4K
Translate
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

Community Expert , Jun 18, 2015 Jun 18, 2015

var loader:Loader=new Loader();

var lc:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);

loader.load(new URLRequest('yourgameswf.swf'),lc);

addChild(loader);

Translate
Explorer ,
Jun 28, 2015 Jun 28, 2015

Same error which leads to this :

var ldr:Loader = this.parent;

Scene 1, Layer 'Actions', Frame 1, Line 5, Column 91046: Type was not found or was not a compile-time constant: Loader.
Translate
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 Expert ,
Jun 28, 2015 Jun 28, 2015

republish that swf use the code in message 74.

it's been changed since you last read it.

Translate
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
Explorer ,
Jun 28, 2015 Jun 28, 2015

Horrray!

Yeah man you got it!!!!!!!!

Insanely great help and patience Woah!

Is there another way to rank your help?

Translate
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 Expert ,
Jun 28, 2015 Jun 28, 2015

that was the problem?  we needed to import the Loader class?

that stinks.  the compiler should have complained when you published the swf without that import statement if it was going to be a problem.

and i just tried to duplicate that error and cannot.

oh well,  you can make messages correct (only one per thread and you already did that) and helpful - up to 4, i think.

you might be able to post other things if you click my name, but i'm not sure about that.

Translate
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
Explorer ,
Jun 29, 2015 Jun 29, 2015

Hi kglad,

yeah actually that was the problem. Tonight I had to change the instance names of the other buttons found in the other .SWF's to dh_btn. I had a problem with something about "Could not load child dh_btn".

Naming them all dh_btn solved it.

I just encountered another problem though. If I click on one of the drawings, it loads fine, click back, everything is ok

I click on another drawing, loads fine, click back everything ok. After a couple of times I get this error :

Error #2044: Unhandled IOErrorEvent:. text=Error #3764: Reloading a SWF is not supported on this operating system.

I only get this while playing on the iPad itself or testing it on the iPad through debugging on the device.

I've never seen this type of error before.

I found this possible fix :

http://code.tutsplus.com/tutorials/quick-tip-how-to-debug-an-as3-error-2044--active-9675

Could it help?

Translate
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
Explorer ,
Jun 29, 2015 Jun 29, 2015

Ok I went further in my debugging process. I tried the above site's method and did nothing except not show any errors.

What I noticed though is once you click on a drawing, and then press on the back button it unloads.

I actually can't access it anymore because it unloads.

So once you click on every drawing and unload them, they are all unaccessible anymore.

Is there a way to unload but, once back in the Main.fla force it to reset the stage?

Translate
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 Expert ,
Jun 30, 2015 Jun 30, 2015

what code are you using to load a drawing?

Translate
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
Explorer ,
Jul 02, 2015 Jul 02, 2015

Hi kglad,

sorry for the delay, we had a national holiday here up in Canada.

Here is the code to load the SWF when clicking on one of the drawings :

stop();

var loader1:Loader=new Loader();

var lc1:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);

loader1.load(new URLRequest('Dessin-Henri.swf'),lc1);

addChild(loader1);

Here is the error message I get in debug mode on the iPad :

[SWF] Henri Godon.swf - 60680143 bytes after decompression

[SWF] Dessin-Henri.swf - 153487 bytes after decompression

[SWF] Dessin-Cowboy.swf - 130237 bytes after decompression

[SWF] Dessin-Poster.swf - 343537 bytes after decompression

[UnloadSWF] Dessin-Cowboy.swf

Error #2044: Unhandled IOErrorEvent:. text=Error #3764: Reloading a SWF is not supported on this operating system.

I don't know why relaoding a SWF is not supported.. If I tried it in AIR Desktop it works fine.

Something is blocking it on iPad.

Translate
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
Explorer ,
Jul 02, 2015 Jul 02, 2015

After searching the forums I found this :

Loading multiple swfs using air 3.6 for ios

It seems to be attributed to the fact that IOS needs to cache it in order to load it again. And my script may be containe ABC script (which I don't know what that is...)

I tried to find a quick fix to this issue to no avail for me anyways.

I tried adding this but I get errors :

request.cacheResponse = false;

request.useCache = false;

Translate
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 Expert ,
Jul 02, 2015 Jul 02, 2015

to prevent cache issues, use:

loader1.load(new URLRequest('Dessin-Henri.swf?nocache='+Math.random()),lc1);

Translate
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
Explorer ,
Jul 06, 2015 Jul 06, 2015

Wow cool that Solved it!

Works like a charm!

Many thanks! Now I can do the rest of my project by loading SWF's like that without a hitch!

Thanks for your patience dedicated and really fast help!

Translate
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 Expert ,
Jul 06, 2015 Jul 06, 2015
LATEST

you're welcome.

Translate
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