Creating a Sprite
Top  Previous  Next


This is a step-by-step tutorial for creating a Sprite. This tutorial illustrates some of the features seen in the "first.swi" file in the File | Samples | Tutorials Menu.

A Sprite is a Movie within a Movie. Perhaps the greatest advantage of using Sprites in your Movies is that their Timeline runs independently of the main Movie's Timeline, as you will see in the "pop_up" Sprite you will be creating. Another advantage of using Sprites in your Movies is that you can easily reuse them throughout your Movie, saving time and with only a slight increase to the file size of the Movie.

1.Open "myfirst.swi" saved from the previous tutorial.  

2.Check that Scene_2 appears in the Scene row on the Timeline Panel. If Scene_2 does not appear in the 'Timeline Panel', select Scene_2 from the Outline Panel  
3.Select the recti Rectangle/Square Tool from the Toolbox. Create a rectangle approximately 1/2 the height and width of the stage. From the Transform Panel, change the Width to 420 and the Height to 220, and center on the stage  

4.From the Shape Panel select the solid line and set the line's width to 2. Change the line's color to a dark green. Select a solid fill in a light gray. Set the shape name to "window"  

The Layout Panel should look something like this:

Tute6_1  


5.Select the new rectangle then from the Modify Menu, select Convert | Convert to Sprite. A Sprite icon sprite will appear in the Timeline. Select the Sprite Panel and type "pop_up" in the Name edit box. Check the 'Stop Playing At End of Sprite' box  

6.Select the Outline Panel and click on the plus (+) symbol next to the "pop_up" Sprite to display the Sprite's 'Object' tree  

Note: In this view, the rectangle you have just created is visible in the 'Layout' Panel. In the 'Timeline' Panel, only the "pop_up" Sprite and the rectangle within this Sprite are present. Also note that the Sprite Object has its own Timeline. You can toggle this view at anytime by clicking on the plus (+) or minus (-) symbol in the 'Sprite Object' tree

7. Make sure you are viewing the Sprite's timeline by pressing the (+) next to the "pop_up" Sprite in the Outline panel, and with the "pop_up" Sprite selected, press the inserttext 'Insert Text' button. From the Text Object Panel, change this text to the letter X, change the font to Arial and the size to 20, and change the color to a dark green.

8. Drag the X Text Object over to the top-right corner of the rectangle

The Outline and Layout Panel should look something like this:  
 
Tute6_2  


The "pop_up" Sprite Object's Timeline should look like this:

Tute6_3  


9.Select the window object from the Timeline Panel. Click on Frame 2 and press the addeffect 'Add Effect' button, select Fade | Fade In from the Menu. Double click on any Frame of the Fade In Effect in the Timeline. From the 'Fade In Settings' dialog box, change the Effect's duration value from 10 to 3 Frames, and press the 'Close' button to accept the new value  
10.Select the X Object row from the 'Timeline' Panel and click on Frame 4. Press the addeffect 'Add Effect' button, and select Place from the Menu  

11.From the Insert Menu, select Content. In the 'Open' dialog box, from the 'Files of Type' drop-down Menu, select Plain Text (*.txt) and select "first.txt" from the Samples folder  
12.From the Text Panel, change the font size to 11, and the paragraph alignment to panels-object-text-left left. Name this new Text Object "link 1" in the 'Text Object' Panel  
13.On the Timeline Panel, click on Frame 4 in the link 1 Object row, press the addeffect 'Add Effect' button and select Place from the Menu  
14.Click on Frame 5 in the "pop_up" Sprite Object row. The addeffect 'Add Effect' button will change to an panels-timeline-addaction 'Add Script' button. Press the panels-timeline-addaction 'Add Script' button and select Movie Control | Stop from the Menu  

15.Press the playscene 'Play Timeline' button on the Control Toolbar. You should see your 'window' fade in quickly, and the 'X' and your imported text will show. Press the stopmovie 'Stop Movie' button on the Control Toolbar  

16.Select the window Shape Object from the Timeline Panel and click on Frame 7. Press the addeffect 'Add Effect' button, and select Fade | Fade Out from the Menu. In the 'Fade Out Settings' dialog box change the Effect's duration value from 10 Frames to 3. Press Close to accept the new value  
17.Select the X Text Object from the Timeline Panel and click on Frame 7 in the in the X Object row. Press the addeffect 'Add Effect' button and select Remove from the Menu  

18.Select the link 1 Text Object from the Timeline Panel and click on Frame 7 in the in the link 1 Object row. Press the addeffect 'Add Effect' button and select Remove from the Menu  
19.Select the X Text Object from the Timeline Panel, then select the Script Panel. From the 'Script' Panel, press the panels-timeline-addaction 'Add Script' button and select the Menu options Events | Button | on (press)  

20.Press the panels-timeline-addaction 'Add Script' button and use the Menu options: Movie Control | gotoAndPlay | gotoAndPlay(FRAME);. Leave the 'Target' box blank (implies this Sprite) and enter 6 into the Frame field. The 'Script' Panel should now look like the one below:  

tute6_3a  

21.On the 'Timeline' Panel, click on Frame 10 in the "pop_up" Sprite row. Press the panels-timeline-addaction 'Add Script' button and select Stop from the Menu  
22. Click on Frame 1 in the "pop_up" Sprite row. Press the panels-timeline-addaction 'Add Script' button and select Stop from the Menu. This Action will hide the Sprite until it is played by the main Movie. This will be applied in the next tutorial.  

The "pop_up" Sprite's Timeline should look like this:  
 
Tute6_4  

23. To preview this Sprite from within the Sprite's Timeline, you will need to be in Preview Frame
mode. Press the fpview 'Preview Frame' button on the Control Toolbar. Click on Frame 1 and drag the Play Head right across the Timeline to preview the animation, or use the arrow controls on the 'Control' Toolbar either side of the fpview 'Preview Frame' button

my2first-sprite_framepreview  

Advancing one Frame should show the window Object starting the fade in. Advancing to Frame 3 will show the link 1 Text Object and the X Object appear, and at Frame 6 the window Object should start to fade out as the link 1 Text Object and X Object disappear  


Grouping a Sprite

1. The "pop_up" Sprite should be the topmost object listed under Scene_2 in the Outline Panel. Press the (-) button next to the name of the sprite in the Outline panel to close it. All other Objects in this Scene belong to your Menu and should appear from the second row and down in the Outline Panel. Select the Object in the second row of the Outline Panel (which should be the "E-MAIL" button), press and hold the Shift key and select the rectangle shape on the bottom row. As pressing and holding the Shift key allows you to select multiple Objects, these two Objects and the Objects in the rows between them should all be highlighted.

The Outline Panel should look something like this:  
 
Tute6_5  

2. With these Objects selected, select Group | Group as a Sprite from the Modify Menu. This will create a Sprite Object consisting of every Object in your Menu

Note: If a number of Objects are selected and you select Convert | Convert to Sprite from the Modify Menu, you will create a separate Sprite for each Object selected

3. Select the Sprite Panel and type the word "menu" in the 'Name' edit box.Check the 'Stop playing at end of Sprite' box

tute6_6  

This Sprite will be controlled from the Movie's main Timeline, and our purpose for grouping and converting this Menu into a Sprite is twofold. Firstly, it will allow you to have this Menu fade in (rather than suddenly appearing after your intro/splash page) as a Sprite, so that you need only apply the Fade In Effect to the Sprite Object rather than applying this Effect to each Object within it. Secondly, this Sprite can be quickly copied and pasted and used later on in the Movie  

4. Select Scene_2 from the top row of 'Timeline' Panel and select the Menu Sprite Object. Select Frame 1 and press the addeffect 'Add Effect' button, select Fade In from the Menu.

5. Press the playmovie 'Play Movie' button on the Control Toolbar. Your Menu will fade in after your introduction and the Movie will stop. The "pop_up" Sprite will not show (we will use this Sprite later). Press the stopmovie 'Stop Movie' button on the Control Toolbar

6. Save your Movie


You are ready to continue with the Adding Interactivity to your Movie tutorial.