Make Flash Animations, Video, Slideshows, Text Effects, Buttons & Menus. Designer Templates, 250 Effects, plus Components & Video Controls

简体中文 繁體中文 Français Español Italiano 日本 Polski Deutsch SWiSHzone.com
SWiSHzone.com Banner
You are here: Home > Community > Tutorials
Community
FREE TOOLS!
Laboratory
Community Overview
Movies
Components
Effects
Screencast Tutorials
> Tutorials
Official Blog
Forums
Other Forums
Request help
Search Tutorials

 All words
 Any words

 Similar words
 Exact words

Number of Results:
Monthly Newsletter
Get our monthly newsletter for all the latest news
competitions, tutorials and tips > Sign Up Now

SWiSH Max: SWiSH Max - Introducing the Timeline
Creator: Mike Chrysler
Website: http://www.swishzone.com
Submitted: Wed Aug 01 2007
Description: The aim of this tutorial is to give users a better understanding of the use of the timeline in a SWiSH Max movie.
Zip File: Download


SWiSH Max - Introducing the Timeline

 

Program: SWiSH Max
Build Date: 2005.08.15+

Skill: Beginner


Introduction:

SWiSH Max files are referred to as Movies because animations are played in a Timeline which is expressed in fps (frames per second). A playhead moves in a linear fashion along a timeline unless controlled by scripting within your movie.

In SWiSH Max the fps is defined on the Movie tab. The default setting is 12 fps. Standard motion picture video format speed is 29.97 fps (SMTPE time code) but it is neither required nor encouraged for your SWiSH Max Movie.

The aim of this tutorial is to give users a better understanding of the use of the timeline in a SWiSH Max movie. You should learn that the main timeline is always called _root in your scripting. That _parent is the way to name any particular container sprite if you are targeting it from the child sprite, and that your sprites (Movie Clips) have their own individual timelines, which can all be targeted by using the names of the sprites in your scripts using dot notation.

Getting Started

Let's create a new movie and see how the timeline works with effects events and actions.

Open SWISH Max. Select File | New to create a new movie. From the Layout Panel button menu, select the Text icon (T). Click and drag across the stage to create a text box. Enter some text for this demonstration.

On the Text Panel you will want to make sure:

  • Your text is not selected as a target.

  • That it is a Vector or Vector aligned font.

  • That it is static text.

 

Creating an effect

If you look at the Timeline panel, you should see two rows in the timeline. One for the Scene, and another for your text object. Objects and effects can be placed and removed at any frame along the timeline to appear or disappear at different times.

Right-click on any frame in the text line and select 'Fade ->Fade In' from the context menu. This will place a 'Fade In' effect at the frame you selected. Use 'File | Test in Player' to see what happens. You should see your text fade into view at the point you placed the effect.

 

Click on the center of the effect (sfx) and drag to change the start time of the effect relative to the scene's timeline. Note that clicking and dragging on the last frame (a black dot signifies a keyframe) of an sfx will alter the duration of the effect so you can lengthen or shorten the time taken for the effect.

A movie's natural state is to Play(). If there is nothing to control it, the movie will play from beginning to end (the end, unless you specify it, is at the last place there is any action on the timeline), and then start over again from the first frame (you can see this by testing your current movie in player or browser).

In order to gain more control over the movie, we need to use Events and specify Actions.

Timeline Event/Actions

SWiSH script is a scripting language that uses events and actions to control the movie playhead. First comes the detailing of the event, and then the specification of the action to occur at that event. Events can be assigned to Objects or the timeline itself. A typical event/action script will look like the code below on your Scripting panel.

on Event() {
//Perform Action);
}

In the Scene timeline above the effect right-click and select 'Movie control > Stop()'. The Scene timeline should now have a red square representing the action. By clicking and dragging the red dot, you change when the event is specified to occur and can adjust which frame you want your movie to stop at.

Test in browser, player or in SWiSH Max by clicking the scene play button.  You can also adjust where the effect occurs and the number of frames for your effect in the Script panel. This is nested behind the layout panel (in default layout mode).

Your code should appear as:

In guided mode, click your Event. and you can set a new value for the frame number. For the next example set this to;

onFrame (1) {
stop();
}

Button Event/Actions

Any object (shape. text, image, sprite) can be used for button events. Switch back to the layout panel view to create a shape. Select the rectangle tool from the layout panel. Click and drag across the stage to create your shape. From the shape panel select a color and give the shape a line value.

With the shape selected, return to the Script panel nested behind the layout panel. Make sure that the guided mode is selected.

Add Script> Events > Button . On release()

Add Script Movie Control > gotoAndPlay > goto and play frame(2)

When complete your script should appear like this in the Script panel.

on (release) {
gotoSceneAndPlay("<current scene>",2);
}

Add another stop() action to your Scene timeline. where the animation ends

onFrame (16) {
stop();
}

When testing in browser/player or swishmax your movie should not present the fade in until your shape is clicked. When the shape is clicked again the fade in should occur again. Now that we have an understanding of how the timeline operates, and how to control the movie via SWiSH Script, it's time to expand on the concept with sprites. Here is a sample.swi which recaps what we have covered.


Sprites

Objects known as sprites in SWiSH Max are referred to as Movie Clips in flash or SWiSH Max2. They are "Mini Movies" within the scene, and they have semi-independent timelines relative to the Scene. The dependency is that the sprite must exist in the scene's timeline and a sprite can not extend beyond the scene's timeline (such as to the next scene).

In order for sprites and the movie to communicate we need to name our sprites. Every object that will be referenced in scripting needs a name. When an event action occurs in the sprite's timeline it will only affect the sprite's timeline, unless another target has been specified.

With your text object selected, go to the Modify Menu
in the main menu and select Modify->Convert-Convert To Sprite.

Now test your movie in SWiSH Max. You will notice the fade in occurs without clicking the button.

We need to:

  • Name the sprite.

  • Assign action events within the sprite.

  • Target the sprite from our button.

In the Sprite panel insert a name for your sprite. Sprite names should not be spaced or begin with a number, and should not be named "Sprite"

Tip: You don't need to manually add scripts if you are just duplicating them. You can copy a script and then paste it into a different location. You can also copy Script from text such as this, or any, tutorial and paste the script in.

From the Scene Script Panel right click on the frame event, and select Copy. Next, double click on the Sprite in the Scene Outline to open the Sprite's timeline. Right click on the Sprite timeline and select Paste Script.

Your Sprite timeline script should look something like this:

onFrame (1) {
stop();
}
onFrame (15) {
stop();
}

Targeting the sprite timeline from the scene timeline.

Our button still points to the timeline it resides in. Select your shape from the scene timeline. In your script panel, select the Action. From the 'Target' drop-down menu, select the Sprite name.

Dot Notation
(Or how to target different timelines in your movie)

on (release) {
MySprite1.gotoAndPlay(2);
}

The main timeline in a movie is referred to as _root.  If you have a button in a sprite that acts on a target in the main timeline, you would need to use _root as the target.

Each sprite has it's own timeline, and sprites can also have Child sprites (and they in turn have their own timeline). Dot notation is the way to target those different timelines. If the communication is to the child sprite within the _root you need to identify the path to that sprite.

on (release) {
MySprite1.MyChildSpriteName.gotoAndPlay(2);
}

If the Child sprite is targeting it's parent sprite: 

on (release) {
_parent.gotoAndPlay(2);
}

If any sprite is targeting the _root: 

on (release) {
_root.gotoAndPlay(2);
}

If a sprite is targeting it's sibling sprite _root: 

on (release) {
_parent.MySiblingSpriteName.gotoAndPlay(2);
}

Hopefully, this helps new users to better understand the use of timelines in a SWiSH Max movie. You should have learnt that the main timeline is always called _root in your scripting. That _parent is the way to name any particular container sprite if you are targeting it from the child sprite, and that your sprites (Movie Clips) have their own individual timelines, which can all be targeted by using the names of the sprites in your scripts using dot notation.



Search | Privacy policy | Contact us | Site Map | Copyright SWiSHzone.com Pty Ltd 1999-2010