| By Niqui Merret | Article Rating: |
|
| November 17, 2003 12:00 AM EST | Reads: |
15,398 |
Director is a great application for new media promotion and promotions together can create an audience for a project and assist with beginning stages of the design process. Stickmancan is a prerelease for a project called "stickmancan ". It is structured as an interactive screensaver that also acts as a countdown to the launch of the product.
The stickman has a series of actions that it can perform. These have been created as Flash animations that are called by the user. They can be called as individual actions or can be set up as a sequence. The main project is split into a Flash movie that has a stickman with associated animations. This has been nested in a Director movie with the controls. The user can then save out sequences of actions so that they will be available the next time the project is run.
Director Is the Shell
Director is the container for multiple types of media. It can incorporate formats ranging from bitmaps, sound, digital video, and 3D, to Flash. It allows you to integrate these formats together to output to a variety of mediums. Although Director has the bulk to output to CDROMs, kiosks, and other heavy media, it also has the ability to compress down to a more than acceptable Web size with the shockwave player.
The different media elements that are loaded into Director are merely actors for Director to control. For all the power that Flash is capable of, Director can take it to the next level, adding further control and functionality. Director is able to not only control the different types of media that it has stored within, but allows the user far greater control of operating-system functions. A text file could be written to the hard drive, then retrieved by any other presentation. This method of saving and retrieving a text file was useful to stickmancan because it allowed actions and sequences to be saved to the user's machine.
Through the power of extras, further control can be applied across applications and within Director. Extras enable Flash movies to run in Director. If these extras are not included, Flash will not be displayed.
Planning
As a general rule, all projects should be well planned with full specifications laid out before work commences. One of the areas that will need to be considered is how to split up the project between Flash and Director. Some areas of a project would be best suited for Flash and others for Director. This may depend on a number of factors, but will generally be based on what you are comfortable with.
It is preferable, however, to take all the elements for a project and look at the applications with an unbiased opinion before making any decisions. It would be easy with the stickman to create the whole project in Flash, but that would not necessarily accommodate the full project specifications. The ability to write a text file to the hard drive would be lost.
The other option would have been to bring the stickman in as a series of Flash movies and just link from one to another. This approach would have saved the need to communicate with Flash altogether. It would, however, have meant adding in a whole series of cast members for the project, a new one for each action.
Due to differences in the scripting language, there may be cases where ActionScript would be better to use than Lingo. Performing date calculations, for example, would be easy and quick in Flash, and the values can then be passed back to Director with ease. Each action for the stickman could carry a date and display information about the last date it was called, how many times during the day it was called, as well as any other useful information.
Variables
You will find that as you are sending variables between Flash and Director there are some differences in the way in which each program handles them. Director and Flash have different conventions for naming and working with variables. Director will treat a variable as a local variable unless otherwise stated. Flash, on the other hand, will treat variables as timeline variables by default.
There are three types of variables in Director: local, global, and property. We will look at both local and global variables in this article. Stating a name and assigning a value to the variable will create a local variable. The variable is available until the end of the handler. This is normally when the keyword end is encountered. The value is not stored unnecessarily in the computer's memory and cannot be used anywhere other than in the handler. A global variable must be declared as a global before it is used. It is not dependent on any levels or attached to any objects. This can be used at any point in the project. The value is stored until the project is quit or it is cleared as a variable. For example:
Local variable in Director:
StickmanAction = "walk"
Global variable in Director:
Global gStickmanAction
gStickmanAction = "walk"
Flash variables, however, are timeline variables by default. This means that they are available at any point on the timeline after they have been created. However, they are grouped to objects or levels, so in order to be used, they must be called with a reference to their associated level or object. If you wish to use a local variable in Flash, it must be declared as a variable when it is created. It will then be cleared out of memory as soon as the block of code has executed. Flash also has global variables, which are treated in a similar way to Director globals in that they are declared as global every time they are used. For example:
Local variable in Flash:
var StickmanAction;
StickmanAction = "walk";
Timeline variable in Flash:
StickmanAction = "walk";
Global variable in Flash:
var _global.StickmanAction = "walk;"
Notice that both Director and Flash use the keyword "global" when referring to the global variables. This must be continued throughout, otherwise it will be considered to be local or timeline depending on the situation used.
From Within Flash
The original way to work with Flash and Director was to call Director commands from within the Flash movie. A Flash button would contain an on(press) event that contained a call to Lingo. The following will tell a Director movie to move the playback head to another frame on the timeline.
on(press){
getURL("lingo: go to frame
25");
}
The main problem with this method is that only expressions can be passed to Director. One of the methods to get around this is to call custom handlers in Director.
Director Handlers
Handlers contain Lingo commands that run when the associated event calls them. A handler could be associated with a mouseDown event, and when the user clicks down, the relevant script will execute. The following example will send the playback head to a marker called "stickman" when the user clicks on the sprite that the event is associated with.
on mouseDown
go to "stickman'
end
A custom handler can be created to act as a holder for commands that could be called from a number of different events. The handler is called by its name from any location in the Director presentation and the scripts associated with it will run. The following is the above link converted to a custom handler and then called from a mouseDown event.
On gotoStickman
Go to "stickman"
End
On mouseDown
GotoStickman
End
This could be fairly limiting as it stands, so to add to the flexibility, one can pass through different parameters. The following is the same handler as above, only the marker name can be sent through when the handler is called.
On gotoStickman target
Go to target
End
On mouseDown
GotoStickman "stickman"
End
Flash and Custom Handlers
The same method is used from Flash to call up any Lingo commands. The getURL option basically tells Flash that the commands in the brackets must trigger the object holding the Flash movie. This object is usually a browser window, but in this case the Flash is nested into a Director movie. The Lingo part of the command tells Director that what follows the colon will be code that it will understand as Lingo. The following example calls the Director handler that will move the playback head to the stickman marker in the movie.
on(press){
getURL("lingo:
GotoStickman");
}
The custom handler in Director:
On gotoStickman
Go to "stickman"
End
The only problem with this is that you cannot send a string parameter through to the Director movie, so the above case would not work if we tried to do the following:
on(press){
getURL("lingo: GotoStickman
"stickman"");
}
The custom Director handler:
On gotoStickman target
Go to target
End
Director Control
With the getURL command from Flash limited only to expressions and calling custom handlers, a serious loss of integration between the two applications occurs. To counter this, there are some commands in Director that will control the Flash movie. We have now moved mostly into Director to tell the Flash movie how to behave. This can basically be done with two different methods: getVariable() and setVariable(). They are as they sound; one will get a variable from a Flash movie and return the value to Director; the other will set the value of a variable in Flash.
The following example will send the title of the action to the Flash movie to be displayed on the stage. The displaying variable is called displayAction and the value that will be displayed is "walk". Sprite 1 is the Flash movie that the variable must be sent to. This must refer to the channel that the sprite is in on the score.
on mouseDown
sprite (1).setVariable(displayAction,
"walk")
end
The syntax is:
sprite
(whichSprite).setVariable(variableName
, newValue)
The process to get a variable from Flash to be used in Director is the same. The main difference is that it will return a value from Flash whereas the setVariable will not return anything.
The following will return the state that stickman is in. Is he acting or stationary?
On mouseDown
sprite (1).getVariable(State, true)
end
The syntax is:
sprite
(whichSprite).getVariable(variableName
, stringOrReference)
The stringOrReference option is used to control the variable's value type. If this is set to true, then a string value will be passed; if this is false, then a literal will be passed. This is set to true by default.
Accessing Flash Functions
There are times when merely getting and setting variables does not offer enough control. The next level is to call Flash functions from Director. These can be either custom functions or Flash functions. This process needs to be broken down into two steps. A reference to the Flash object will need to be created. The functions can then be attached directly to the object.
The following code will need to be attached to the Flash sprite on the stage as a sprite script. The reference will need to be stored in a global variable so as to be accusable at a later stage. The beginsprite handler ensures that the code will set up the reference to the Flash sprite as soon as the playback head reaches the Flash sprite in the score. The reference in this example has been created to the main timeline in Flash on level 0.
global gStickmanMain
on beginsprite me
gStickmanMain
=getVariable(sprite(me.spritenum),"_le
vel0",False)
end
Now that you have created the reference to the main timeline you can call up Flash functions from anywhere in Director. The following example will now tell the Flash movie to play frame 2 of the main timeline.
global gStickmanMain
on mouseUp me
gStickmanMain.gotoAndPlay(2)
end
In the case of stickmancan, we need to create a reference to the stickman movieclip so that any of our stickman functions can be called. The following code is the same as above but creates a
reference directly to the movieclip
stickmanMC.
global gStickmanMC
on beginsprite me
gStickmanMC=getVariable(sprite
(me.spritenum),"_level0.stickmanMC",Fa
lse)
end
The following will tell the stickmanMC to stop on frame 2:
global gStickmanMC
on mouseUp me
gStickmanMC.gotoAndStop(2)
end
To call a custom function in Flash that has been created in the stickmanMC is a simple process of calling the function and passing through the correct parameters. The following calls a Flash function called stickmanAction, which takes a parameter that is the type of action to be performed.
global gStickmanMain
on mouseUp me
gStickmanMain.stickmanAction("walk")
end
The basic Flash function that is called is the following:
function stickmanAction(action) {
gotoAndStop(action);
display_txt.text = action;
}
Published November 17, 2003 Reads 15,398
Copyright © 2003 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Niqui Merret
After many years as an instructor and developer in South Africa, Niqui now
works at London-based rich Internet solutions firm, Prismix. She feels that
she is a Director addict in a Flash-mad world.
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- Adobe Cans Another 9% of its Workforce
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets




































