3

All,

I'm pretty new to AS3, so this is probably a very trivial question. But, I'm stuck.

I'm working on a new Flash application (AS3). The app uses a Document class.

Here's how I've set up the folder structure:

  • "application" folder
  • "com" folder

    • "[mycompany]" folder

      • "[myproject]" folder

So, in Flash CS5, in the main FLA, the Class: field points to "com.mycompany.myproject.AppName"

If I click the little "pencil" icon next to that field, Flash CS5 loads AppName.as in the IDE.

In AppName.as, the first few lines are:

package com.mycompany.myproject {
    import flash.display.Sprite;
    public class AppName extends Sprite {

When I test the movie, everything works just like I'd expect. So far, so good.

However, when I try this on my HOME pc, it doesn't work - the constructor in AppName.as is never called.

There are no output messages or errors - just that nothing happens. Flash runs the SWF as though there was no ActionScript associated with it (there's no timeline code).

So, clearly, something is different on my home PC than on my office PC. But I can't figure out what.

Here's what I've ruled out:

  • The folder structure is the same on both PCs (I use dropbox, so I know they're identical)
  • In Flash CS5, I haven't set any global Source paths (i.e., Edit > Preferences > ActionScript > ActionScript 3.0 Settings - all path fields are blank). This is the same on both PCs
  • I have set the document specific paths on both PCs (i.e., in the Properties Window, if I click "Edit" next to ActionScript Settings, I get the "Advanced ActionScript 3.0 Settings" dialog window. In the "Source Path" tab, the only entry is ".". I assume that this means that Flash will find all source files in or below the folder that contains the FLA/SWF.

The strange thing... on my home PC, when I'm in Flash CS5 - if I click the little Pencil icon next to the Class: field, AppName.as loads in the IDE. So, it's as though Flash knows where to find the document.

The only problem is that, when I test the movie, the constructor is not called.

I know there are no errors in that Class, since it works perfectly on my office PC.

But, just to be sure, I reduced the Class to this:

package com.mycompany.myproject {
    import flash.display.Sprite;
    public class AppName extends Sprite {
        public function AppName () {
            trace ("Working!");
        }
    }
}

On my office PC, I see "Working" in the output window when I test this; on my home PC, nothing.

Many thanks in advance for any insight or advice!

[UPDATE]

In response to several comments, here's screenshots of the various settings: enter image description here

Here's the full size image

mattstuehler
  • 9,040
  • 18
  • 78
  • 108

4 Answers4

1

Removing the ".as" from the end of the class name should fix your problem.

The Flash IDE will assume the location of the file from the qualified class name.

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
  • weltraumpirat - thanks for the suggestion. However, that was just a typo in my post. In the class field, I just have "com.mycompany.myproject.AppName". I think my problem must have to do with some difference between the two PCs, since it works perfectly on my office PC. I've looked at the global ActionScript settings, and they appear to be the same. So - I'm wondering if another setting could be responsible? – mattstuehler Mar 16 '11 at 15:21
  • Do you have any entries in the library path? – weltraumpirat Mar 16 '11 at 15:31
  • Dumb question, but are you actually calling the constructor in your fla? `var a:AppName = new AppName();` – Sam Mar 16 '11 at 15:47
  • weltraumpirat, Sam - thanks again for helping out. I've added a screenshot of my various settings. I'm virtually certain that those settings are identical on my office PC (where the app works), and my home PC (where it doesn't). – mattstuehler Mar 16 '11 at 16:32
  • Sam - oddly, no output or compile errors on my home PC. It's just that nothing happens - it's as though Flash doesn't think the SWF has a document class, so there's no actionscript to execute. – mattstuehler Mar 16 '11 at 16:34
  • @mattstuehler: Everything seems to be correct, this is really odd. I'm not a Windows user, but might there be any file or folder permissions preventing the IDE from getting access to the script? Also, have you tried manually copying the folder instead of using DropBox? And last: Are you sure "omit trace actions" is not checked? – weltraumpirat Mar 16 '11 at 16:47
  • Oh, and another one: Try adding a trace in a frame script and see if it correctly sends the output to the console. It might be a configuration issue with your Flash IDE, where the player used for SWF playback is not the debugger version. – weltraumpirat Mar 16 '11 at 16:49
1

Here's something you could try: Go to your output window and click the little icon on the top-right just below the close button. In the menu that appears, go to Filter Level and set it to Verbose and try publishing again. Does that help?

irot
  • 592
  • 1
  • 6
  • 13
0

It's been a long time, but in case anyone encounter the problem again.

I've just experienced this problem today, and luckily I am able to identify my error. I mistakenly add ":String" and that cause Document Class to disappear from FLA.

if (floors = '') {
    floors:String = '{"floors":[{...'
}

by removing the shouldn't-be-there ":String", the Document Class is back in action.

if (floors = '') {
    floors = '{"floors":[{...'
}
Doppio
  • 2,018
  • 12
  • 11
0

I know it's bad form to answer your own question, but I finally figured it out. It had to do with lettercase in the path.

Here's the details (just in case anyone else is interested)...

It turns out that on the computer I originally created the application on (my office PC), the path I used was:

  • "application" folder
  • > "com" folder
  • > - > "[mycompany]" folder
  • > - > - > "[MyProject]" folder

So, my document class begins:

package com.mycompany.MyProject {

As I mentioned, I use dropbox.

So, when I started up my home PC, dropbox automatically starts, and syncs everything.

However, here's what dropbox created:

  • "application" folder
  • > "com" folder
  • > - > "[mycompany]" folder
  • > - > - > "[myproject]" folder

Note that "myproject" is not capitalized the same way.

Apparently, the Flash IDE is not sensitive to case, which is why it was able to find the Class document (MyProject.as), when I tried to edit it. However, the compiler must be, so it was not able to find it.

As soon as I changed the "myproject" folder to "MyProject", everything worked great.

Sorry for such a stupid question.

mattstuehler
  • 9,040
  • 18
  • 78
  • 108
  • .. man , I have same problem and all my folder names are correct ! . I end up with making new file, copy all libraries and mc`s and also resize the stage. It is strange problem. – Katax Emperore Jan 09 '13 at 03:57