Learning from Others

From MySLife DAS Wiki

Jump to: navigation, search

Contents

Topic Summary: Programmers often share code and help each other solve problems. In this topic you will learn how to look at another person's Flash source code (.FLA) file, find a piece of code or an object you want to try in your game, and copy it into your own .FLA file.


Topic Assignments

How to copy movie clips from another .FLA

You can copy a Movie clip from either of two places: the Stage and the Library. In the diagram below, an instance of "hi_mc" is located in the Library to the right, and also on the Stage.

Copy the Stage instance by clicking on the Movie clip with the Selection tool, then right clicking (apple-click) and choosing Copy (or Edit > Copy). Be aware that when you paste this instance to your Stage, you will also be copying all attributes of that movie clip including height, width, instance name, and any ActionScript.

Image:Mc_properties.jpg

If you like the way the movie clip looks and you want keep the ActionScript, the Stage copy method is fine. Just keep in mind if you paste more than one instance of that Movie clip to the Stage and it contains ActionScript, there will be a conflict in ActionScript in the main Timeline because it will have the same instance name.

You can also copy a Movie clip by clicking on it in the Library, then right clicking (apple-click), and choosing Copy (Edit>Copy is not an option in the Toolbar). To paste the Movie clip to your Library, you can right click (apple-click) in the white space of your Library. If your Library is not being shown, use the Toolbar to go to Window > Library (or simply hit Ctrl+L) and then Paste.

How to copy Layers from another .FLA

If you want to copy all the content of one Layer, click on the Layer name, and all the frames in that Layer will become selected, like this:

Now right click (apple-click) anywhere on the black and choose Copy. Go to your .FLA file, create a new Layer (or if this your Layer 1 click on the blank Keyframe), and Paste. This will copy the contents of each frame, the attributes, and any ActionScript that is present in the Layer.

Notice that the contents are also in your Library. You can name the Layer what ever you like.

How to copy scenes from another FLA

If there is a section of a Layer you like, also known as a Scene, you can copy just that section. Just like in Assembling The Game, highlight the specific section you want in the Timeline, right click (apple-click) in the black and chose Copy.


You can insert this Scene anywhere on the Timeline. Right click(apple-click) in the frame, and paste. As with copying Layers, this will copy the content, attributes, and any ActionScript if any is present.

How to copy ActionScript code from another .FLA

When looking at another person's FLA file, you need to be able to recognize where the ActionScript code is located. The hard way of doing it is by going through the Timeline and clicking on any frame that has the "a" on it to see if that is the right code. Another way is going through every Movie clip until you find what you need. But there is a better way: using the Actions panel.

Image:Actions_panel.jpg

There are 3 windows to the Actions panel. The first window is the Code Library. The second window contains all instances of ActionScript; this the window we'll be looking at. Window number 3 is the Actions window, where the code is written.

In Window number 2, you will find all instances of ActionScript, whether it is in a Movie clip, or a frame. Use this panel to browse around all the code to find what you need. Make sure that when you locate the code you want, you copy any variables and functions that are needed to make the code to work. Copy and paste the code to the Actions window in your own .FLA.


Update the Wiki:

  • Upload the assets (.SWF and .FLA) you create to your Wiki project page.


Update the Blog:

  • Write a Blog post about this topic, share your learning experience!


Related Links and Tutorials


Search the Web for more information

Here are some search results on Flash ActionScript programming:


Image:Icons-mini-icon_user.gifImage:Icons-mini-icon_user.gifImage:Icons-mini-icon_user.gif Students Contributions

Personal tools