Where are the action scripts? - actionscript-3

I'm new to Actionscript.
Someone gave me a .FLA file. I opened it up in Adobe Flash Builder, then pressed Debug>Debug from the menu bar and the project starts running in a flash player as expected.
Then I shut down the flash player and then I wanted to start editing the project.
I go to the canvas area and see nothing but a purple background. I go to the timeline and see one empty layer.
I see in the library a lot of pictures and movie clips. But none of them seem to have action scripts associated with them.
Where do I go to look for all the actionscript that powers this app? I'm pretty sure there is some actionscript involved...but have no idea where to look at this point.
I typically click on a layer/frame then right click and choose actionscript to open up the actionscript dialogue window. But it's always empty.
---- EDIT
I noticed there's a folder src/com/gsk/proj1/myawesomeproject/ . In that are the folders controllers, controls, models, views and a few more. How does the flash project know to read action script from somewhere in this folder? And which as file is fired first?

Look in the following places for code associated with an FLA:
Open the Window > Actions panel and look on the left side drawer (expand it if not showing). This will show the location of all "timeline scripts" embedded in the FLA.
Look at the Properties panel for the main timeline (click on an empty area if necessary to de-select any objects) and look at the "Class" field. This is the root "document class", and if not empty, this class will be instantiated along with the SWF when it is constructed by the player. Of course, that class could be using all sorts of other classes, but it would be the entry point for the SWF.
In the Library panel, look for symbols who have a Linkage value. This indicates the symbol is linked to a class by that name. Open the symbol properties (right click > Properties) for more details. Note that Flash can "auto generate" classes that don't have actual class files (useful for instantiating display objects strictly for visual purposes).

Related

Issue with Document Class and Tutorial

So I've been following this tutorial on AS3 and Flash. Its been going well until, note I have tried to contact the writer of the tutorial and had no reply. Here's what it tells me to do;
Right-click PlayScreen in the library, select Properties, and check Export for ActionScript. This time, instead of accepting the default value, enter the name of your document class. Click OK.
So it pops up an error, first we’ll have to make a new document class, since no two different objects can share the same class. Cancel the Properties box.
Hit File > New and select ActionScript File. Enter the (by now familiar) code.
Save this in the Classes directory as DocumentClass.as. (There’ll be no confusing the purpose of this file!) Now, back in your FLA, change the document class to DocumentClass.
Check everything’s fine by clicking that pencil icon — if it’s all OK, that should bring up the AS file that you just created.
// So this bits all fine, its the next that i'm stuck with:
Now you can set the PlayScreen‘s class to AvoiderGame. So do so!
// So I go ahead into the properties and change the name but then it pops up with the same error as before: 'Please enter a unique class name that is not associated with other library symbols'
What does this mean!? How do I resolve this!?
Full tutorial here:Flash Tutorial
Its hard to tell what you are trying to accomplish without knowing what all the parts you are referring to actually do, which are objects in the library and which are classes, but maybe this can help:
First of all, document class in AS3 typically refers to the project's main set of code that initializes the app. This class can be called anything but is often called Main, and is entered in the property panel that is displayed when you click the projects main stage in the field called class.
Now, when linking a class to an object in the library, its a little different. In the library object's property panel, tick the box for Export for Actionscript, and put a unique name in the top box. This is what you reference in your code to call it, like new somethingOrOther() or using the pic below as an exaample, new Ball(). The second box is the base class, pathed to where it lives in your code base. This is the class you will write that actually controls the object you've linked the class to. Giving a linked object a base class and a unique identifier allows you to use the same base class for multiple linked objects.
Note that when you do this approach, Flash will warn you that there is no class associated with Ball and one will be created for you. Don't worry, this is normal behavior. If you set this up properly, your object will still be controlled by its base class.

Creating skinned components and UI editor for scaleform

Our project is a MMORPG, using scaleform to render UI. Now we use Flash CS5 to create UI panels with scaleform CLIK. With the development of this project, we encountered some problems:
CLIK is not skinned, we have to create separate symbols for each component with different disappearance, so we have PushButton1, PushButton2, RadioButton1, RadioButton2...
Flash CS5 is not a What You See is What You Get tool. For instance, we have a shared component named Window, it has a close button as it's child. In a fla, we first pull a Window on the stage, and modify its size, the close button will be scaled in the stage.
We can constrain the close button in as code, but artists have to see the right result in Gfx Player on runtime.
We have some common components fla like common_button.fla with most of button components in it. Common components are runtime shared in different fla. In a UI fla (e.g. friendpanel.fla), when we need a common component, we copy it from common_xxx.fla and paste it in the new fla library. If a panel is complex, it's library will be confused and not easily managed. If the common one is not satisfying requirement, we will double-click the pasted component and modify it in the local fla, and this caused more resource management troubles.
So I consider if we should create a skinned UI component lib and an UI editor to handle this problems. Does any one has similar experience?
These are common workflow problems reported by many Flash IDE users unfortunately. Certainly, creating your own tool to solve these problems is a good option, but a costly one. The Scaleform team is investigating possible solutions to these types of issues for future versions of the SDK. In the meantime, there's not much that can be done to remedy these issues that I am aware of.

In Flash, despite publishing for "export in frame 2", many classes seem to be in frame 1, why?

I decided to add a preloader, so I wrapped the content of frame 1 in an object and moved it all to frame 2. I assigned the document class to that new object in the library, and cleared the document class from the publish settings, effectively detaching the document class from the main timeline.
I went into Actionscript Settings and set the "Export classes in frame:" option to "2". If you look in the library, each symbol's option for "export in frame 1" now says "export in frame 2", so I have to assume it means what it says.
Despite frame 1 being empty, and despite the ActionScript setting to export classes in frame 2.... the generated size report still reports that most of the classes are exported in frame 1.
I have one SWC file referenced which is set to be "merged into code", but shouldn't that data be defined in frame 2 as well? Again, the size report is showing most imported definitions defined on frame 1.
I figured this out rather quickly.
The problem seems to be having an instance of the main document class on frame 2. By simply having an instance there, its creating a variable of that type on the main timeline, hence it needs to have that definition loaded to instantiate the main timeline for frame 1.
The solution is to make sure that the entire main timeline does not in any way reference any classes you don't want loaded in frame one, especially your document class. Instead, instantiate your main document class via code on frame 2 with the "getDefinitionByName" utility function.

Only the loader images are being exported in frame 1 but the loader still only shows up at 100%

As the title says, the file loads correctly but the loading screen only flashes up at the end.
The only thing being exported in frame 1 is the loader image, and that is extremely small.
Is it possible that there's a queue of things being loaded and the loader image is at the bottom of that queue? Since that was one of the last things added to the project
If your preloader only shows up after the file has loaded, this means that you still have other objects being linked onto Frame 1. Flash is very picky about this, and it's easy for things to be yanked onto Frame 1 regardless of your settings. When you compile, Flash builds a dependency graph to determine what items are needed on each frame. If it thinks an asset is needed earlier than the export frame setting, it will ignore the setting and push the asset onto that frame. In particular, any class that your document class directly references will be automatically yanked onto frame 1.
Checking "Generate size report" in File, Publish Settings, Flash can help you see how much data is being exported onto Frame 1. Here are some tips to ensure that everything is linked onto the proper frame:
In Publish Settings, Flash, ActionScript Settings, make sure that "Export frame for classes" is set to 2 or higher.
Ensure that library symbols say "Export on frame 2" in their linkage properties. Older versions of Flash may export them on frame 1, regardless of the class export frame. In this case, you'll have to do the oldschool method of unchecking the "Export on frame 1" option, and manually dragging these symbols onto the timeline on frame 2.
Do not directly reference classes from your document class or on the main timeline. The Document class and all the assets it references are always placed on frame 1. Anytime you do var f : MyClass; in your document class or on the root timeline, then you are referencing MyClass, and Flash will automatically yank it onto frame 1.
To avoid directly referencing your main app class in your preloader, you want to instantiate it indirectly, using something like this:
var gameClass : Class = flash.utils.getDefinitionByName("Game") as Class;
var game : Sprite = new gameClass();
In this case, your Preloader becomes the document class, and indirectly creates the Game class when the SWF has loaded. This avoids any direct references to Game and its content.

ActionScript not showing up in Actions - Frame window in Flash CS5

In an existing fla file, I'm not able to find strings within actionscript that is contained within certain frames (regardless of which frame it's in). So for example in frame 1 there is the following code:
stop();
But searching for 'stop' (without quotes) doesn't turn up any results.
If I create a new fla file, I'm able to find actionscript in all keyframes. Furthermore, I've noticed that the "Actions - Frame" window shows me a tree of all the ActionScript in the scene, organized by frame. This isn't happening in the first .fla file - I can open up and edit actionscript for a frame, but the tree/index never gets built.
Has anyone run into a situation like this? Is the first .fla corrupt in some way, or is there a setting to allow me to easily find actionscript within all frames? Thanks!
Have you checked the settings in the search box? Maybe the search is document based and the specific file you are having trouble with has different settings from the default one. Try to compare the working file with your "corrupt" file. Actionsctipt should be enabled.