|
by kirupa chinnathambi Let's continue on with this tutorial, shall we? In case you stumbled on this page from another location and did not chance to finish page one, click here to start the tutorial from the beginning.
Adding Actions Let's add the code to our Flash animation, and I will explain why we used the code afterwards. Make sure you have the movie displayed in Flash:
[ copy and paste the above code into the actions dialog box ]
[ copy and paste the above code into the actions dialog box ]
[ copy and paste the above code into the actions dialog box ]
[ copy and paste the above code into the actions dialog box ] You have just completed adding the code to all the buttons. Save the animation and preview it in your browser by going to File | Publish Preview | HTML. Now, click the buttons. Notice that the individual pages load in the main window. Once you have completed exploring the animation, press the Refresh button. You will see the splash page again. Do you notice something strange from your animation and from my sample animation on the previous page? No? Maybe the following images should help you out:
[ my example ]
[ your example ] If the difference still eludes you, click the home button. Notice how the CLUB Kirupa logo appears. Yet, when the page is loaded initially in the browser (press the Refresh button), the home page containing the logo does not appear in your version of the animation. That is because we did not code that in there. We did code the home page button, but that works only when the user actually clicks on the home link. When the page initially loads, the user does not click anything. The home page content should display without having the user input anything. To solve that problem, follow the following steps:
[ copy and paste the above code into the actions dialog box ]
Much better! Notice how the logo from the home page animation displays when the animation loads. Now, let me explain how and why the code works the way it does. The Code: An Explanation
Here is where knowing a little bit of ActionScript comes in quite handy. Having read and used the loadMovie action, I figured that it would suit my requirements perfectly. The loadMovie action in Flash MX follows the basic structure:
MovieClipName in the above code is the name of the movie clip that the movie, "url to movie.swf", will load into. Basically, the LoadMovie action helps me to accomplish the two requirements I set forth above. Therefore, let us take a peek at a section of code added to one of our buttons. The following section of code has been taken from the home button.
The first line is basically the event handler that triggers the code in the lines that follow. The second line is where the loadMovie code appears. While the code looks a little different from the loadMovie code I explained above, it is quite similar. The name of my movie clip where the animation main_content.swf loads is called contents. I added _root before contents because the movie clip contents is located on the main timeline. Each of the other buttons have similar code with only the movie different. For example, the locations button will not have the action "main_content.swf". The locations button has the movie's name specified as location.swf. You can see the other animations by going to the folder where you extracted all the animations. Finally! You have completed this tutorial. |