Split Paths : Timeline Coding
<p>Reviewing the more simple and traditional way of developing in flash: taking the easy path. In this video we break down the timeline and explain how to utilize it with code for Flash. </p> <h1>Split Paths cont. Timeline Coding</h1> <p>For Flash coding, if you choose not to work in OOP the opposing alternative is timeline coding. Learn what this means, how to create a layer, and use frames effectively. Start by simply clicking the first frame on the TimeLine, opening the Actions Panel, and then typing:<br /> <br /> trace ("Hello World");<br /> <br /> Find out what happens when you run this application! <br /> <br /> Now you see the different paths available for programming in Flash: the traditional timeline coding, or OOP. While Timeline coding is simple to begin with, the longer you do it, the harder it gets as you must search for more complicated things to add. If you simply start coding using OOP, possibly the learning curve is steeper but the farther you go, the easier it gets. In the long run, OOP saves time and trouble: this verifies the answer to "why use OOP" !</p> <h2>Timeline Coding Video Transcript</h2> <div class="expandable"><pre> Now if you choose not to work in this format, and again we recommend that you do, but if you choose not to, the way you would do that is if you click on your main again and you get back into your main.fla, and you go into your properties panel, what you would want to do is delete your main reference: now there's no linkage between our main and our class. If we'd now click on our edit, it's not going to go anywhere. It's going to ask us to put a name because we don't really have one. So I'm going to save my file now. Now because I've opened this file previously in a earlier version, it's asking me if I want to save it up to Flash CS5. So I'm not going to save it right now because it's not really important for me to save. If I run the application now, it's going to output nothing, because there's no connection now between our main and our *.as file. The way we would program in Flash if we choose to work not in an object oriented mode is to go to our timeline, we're going to create a new layer, and we're going to name that layer, so I'm going to double click on layer two, I'm going to select everything, and I'm going to type here "as" just to make sure that everyone knows that our code is in the *.as layer. Now that we have our *.as selected, I have to select the first frame. Every one of these lines are possible frames, although they're disabled -- these don't exist yet. The only active frames right now are these two, and I want to select my frame right now in frame one, and now that it's selected, I could click on my window> actions panel. Now, make sure that you don't have something selected by mistake, , so if I just go here and create a rectangle, and it has a really big thick stroke, but that's fine, and you can see that now that it's selected, you'll see that in ActionScript 3.0, code cannot be placed directly on objects. Please select a frame or use the code snippets panel yadda yadda yadda. To our point, what that means is that we want to make sure that our frame is selected and not the object. The way I make sure that that will happen is that, for any items that I create, I don't create on the same layer as my *.as layer. So I'd like to just lock my *.as layer, making sure that I won't put anything on it. So I could select that layer, and directly go into my actions frame in my actions panel, and then I could start coding, so for example if previously we saw the sample of "hello world," let's create that sample again. We could just type "trace," open a round bracket, open a double quote, type Hello, space, world, close our double quote, close our round bracket, and then semicolon. trace ("Hello world"); Now if you run our application, we should be getting in our output panel, "hello world". That's all you really need to do to make that choice between our path of the object oriented path, and the traditional path of coding directly on the timeline. </pre> </div>