|5. Click on the Listener input field (to the right of the Type input field) and type in "replay_ecard". Flash will update our code automatically. Here is what you should have.|
Now we are ready to write our function.
6. From the code list, choose Language Elements – Statements, Keywords & Directives – definition keyword – function. As you can see, we have a not_yet_set reminder in our new code. We need to tell Flash the name of our function. Click on the Name input field and type in "replay_ecard". Flash will update our code.
7. The next input field is for Parameters. The parameter that we need to supply for this function is the mouse event. In the Parameters input field type in "event:MouseEvent".
8. Under the Parameters input field is the Type field. Use the drop-down menu to set this field to void. Your code should look like this.
9. We will now add the code that will tell Flash to go back to Frame 1 and play the animation. This will be very similar to the stop() code that we added in the previous tutorial. We will use the gotoAndPlay() code. Click on the Plus sign to open the code list. Choose flash.display – MovieClip – Methods – gotoAndPlay. In the Object input field type in "this" to tell Flash that we are talking about the main Timeline. In the Frame input field type in "1". This will tell Flash to go back to Frame 1.
Here is the finished code.
Save the ecard. Now we can publish our eCard for the web. From the Menubar, click File – Publish.
Join us in the Flash forum.