Copy link to clipboard
Copied
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.
var loader:Loader=new Loader();
var lc:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);
loader.load(new URLRequest('yourgameswf.swf'),lc);
addChild(loader);
Copy link to clipboard
Copied
open dessin-henri.fla and save it as dessin-henri_bu.fla
then create a new fla, add a movieclip to frame 1 with instance name dh_btn and add the same script showing in message 49. test.
Copy link to clipboard
Copied
same error :
| Scene 1, Layer 'Layer 1', Frame 1, Line 1, Column 1 | 1120: Access of undefined property dh_btn. |
Copy link to clipboard
Copied
click the movieclip in frame 1 that you think is dh_btn and check the properties panel. do you see its instance name there?
Copy link to clipboard
Copied
Man I can't believe that was hidden there. I thought just giving it a name was sufficient.
Now back to Dessin-Henri.fla, I changed the instance name of the button to dh_btn. Now that error is gone.
Now I have :
TypeError: Error #1006: addEventListner is not a function.
at Main/frame1()
Copy link to clipboard
Copied
are you publishing for as3?
Copy link to clipboard
Copied
yes here are my settings.
I'm publishing for IOS in my .FLA where most of my app is.

Copy link to clipboard
Copied
tick 'permit debugging' in your main swf and retest to more detailed info about the error.
Copy link to clipboard
Copied
Here is what I got :
By choosing Debug only
[SWF] Dessin-Henri.swf - 157100 bytes after decompression
TypeError: Error #1006: addEventListner is not a function.
at Main/frame1()
Cannot display source code at this location.
Tried it by clicking debug movie in Air Launcher Desktop and got this :
[SWF] Henri%20Godon.swf - 60704565 bytes after decompression
[SWF] Dessin-Henri.swf - 157100 bytes after decompression
TypeError: Error #1006: addEventListner is not a function.
at Main/frame1()
Cannot display source code at this location.
Is there another way to see what is happening?
Copy link to clipboard
Copied
there's a typo:
that should be addEventListener, not addEventListner
Copy link to clipboard
Copied
Okay, that one is okay now.
When I test it, it loads the Dessin-Henri.swf without a hitch but when I click on the back button I get :
ReferenceError: Error #1065: Variable Loader is not defined.
at Main/backF()
Does that mean we must define the var Loader in the Main.as that came with the Drawing App?
Or is it in the dh_btn script itself?
Copy link to clipboard
Copied
tick 'permit debugging' in all the fla's and then publish.
then test.
Copy link to clipboard
Copied
cool.
here is the message :
[SWF] Dessin-Henri.swf - 158362 bytes after decompression
ReferenceError: Error #1065: Variable Loader is not defined.
at Main/backF()[Main::frame1:3]
[UnloadSWF] Henri%20Godon.swf
Test Movie terminated.
Copy link to clipboard
Copied
are you testing by running the main fla, NOT dessing-henri.fla?
Copy link to clipboard
Copied
Yeah I'm testin in the main.fla, cause I guess it won't be able to know where to go back to.
Here is the full error :
[SWF] Henri%20Godon.swf - 60704565 bytes after decompression
[SWF] Dessin-Henri.swf - 158362 bytes after decompression
ReferenceError: Error #1065: Variable Loader is not defined.
at Main/backF()[Main::frame1:3]
[UnloadSWF] Henri%20Godon.swf
Test Movie terminated.
Henri%20Godon.swf is my main file.
Copy link to clipboard
Copied
i don't understand why you're seeing this, [SWF] Dessin-Henri.swf - 158362 bytes after decompression
with henry godon.fla open in flash pro, you click control>test movie>in flash professional.
is that exactly what you're doing?
if yes, then you see the error message? so you do something and see the error message?
Copy link to clipboard
Copied
I test the Henri Godom.fla in Flash Pro control>test
I then navigate through my menu up to the 3 drawings scene.
I then click on the first drawing > Dessin-Henri.swf
I can draw fine as supposed to.
If I click on the back button, that's where I get my error.
Copy link to clipboard
Copied
i can't duplicate that (unless you have some other code in the main fla, or elsewhere) that's unlloading d-h.swf before the code i suggested executes.
Copy link to clipboard
Copied
Here is what I got at frame 10 in the Main.fla
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);
The reason why it's at frame 10 is mainly because I have a script at frame 1, when you click on the first drawing, it leads you to frame 10, where is loads the proper SWF.
Is that script Okay?
Copy link to clipboard
Copied
in d-h.fla, comment out the Loader(this.parent).unloadAndStop() line of code and above it place
trace(this.parent);
publish a new d-h.swf
in your main fla, test the d-h coloring and report the trace output.
Copy link to clipboard
Copied
Hi kglad,
Here is my script in d-h.fla :
dh_btn.addEventListener(MouseEvent.CLICK, backF);
function backF(e: MouseEvent): void {
trace(this.parent);
/** Loader(this.parent).unloadAndStop(); **/
}
Here is the report in the Main.fla once tested :
[SWF] Henri%20Godon.swf - 60704565 bytes after decompression
[SWF] Dessin-Henri.swf - 158339 bytes after decompression
[object Loader]
[UnloadSWF] Henri%20Godon.swf
Test Movie terminated.
It reported [object Loader] only when I clicked on the Back button.
Copy link to clipboard
Copied
now replace that code with the following and paste the output:
dh_btn.addEventListener(MouseEvent.CLICK, backF);
function backF(e: MouseEvent): void {
trace(this.parent);
Loader(this.parent).unloadAndStop();
trace('after');
}
Copy link to clipboard
Copied
Here is what I got after I raplaced it in Dessin-Henri.fla
[SWF] Henri%20Godon.swf - 60704565 bytes after decompression
[SWF] Dessin-Henri.swf - 158401 bytes after decompression
[object Loader]
ReferenceError: Error #1065: Variable Loader is not defined.
at Main/backF()[Main::frame1:7]
[UnloadSWF] Henri%20Godon.swf
Test Movie terminated
Again only after I clicked.
Copy link to clipboard
Copied
try:
dh_btn.addEventListener(MouseEvent.CLICK, backF);
function backF(e: MouseEvent): void {
var ldr:Loader = this.parent;
ldr.unloadAndStop();
}
Copy link to clipboard
Copied
hmm, I got this when trying to publish the Dessin-Henri.swf :
| Scene 1, Layer 'Actions', Frame 1, Line 3, Column 10 | 1046: Type was not found or was not a compile-time constant: Loader. |
I still tried to test the Main.fla but couldn't draw anymore.
I'm kinda stumped and don't have a clue of what is what.
Copy link to clipboard
Copied
try:
import flash.display.Loader
dh_btn.addEventListener(MouseEvent.CLICK, backF);
function backF(e: MouseEvent): void {
var ldr:Loader = this.parent;
ldr.unloadAndStop();
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now