Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Flash Meets Authorware
Flash Meets Authorware

In this article I show you some of the tricks I've learned over the years and give you some ideas for how to better combine Flash and AuthorWare in your work. I start with the basics and move to the more cpmplex, and I cover some optimization techniques for speeding up flash playback. You can find sample FLA and AW files at www.sys-con.com/mx/sourcec.cfm.

XTRA or ActiveX
There are two ways to embed Flash movies in Authorware, the Flash Asset XTRA and the Flash ActiveX Control. The XTRA is shipped with Authorware and does not require anything on the user's computer, while ActiveX is part of the Flash Player on Windows (see Table 1).

For XTRA, Authorware version 6.0 supports Flash 5, while Authorware 6.5 and 7.0 support Flash MX. Flash MX 2004 is not currently supported as an XTRA and would require use of ActiveX.

Regarding ActiveX, nearly everyone on Windows has a version of Flash ActiveX, but it is not guaranteed. I personally use XTRA because it will work on Macs and PCs, but many people use ActiveX or both ActiveX and XTRA. The samples in this article use XTRA.

A Few Notes on Code
A few quick notes if you aren't used to scripting in both ActionScript and Authorware:

  • In Authorware you set a variable with ":=": myVariable :=5
  • In Authorware you check equality with "=":if myVariable=5 then...
  • In Flash you set a variable with "=": myVariable =5
  • In Flash you check equality with "==": if (myVariable==5) {}...
  • Arrays are "1" based in Authorware and "0" based in Flash.
Consider the following array:

myArray["2", "4", "6"]

In Authorware the first value in an array is referenced by 1; myArray[1] would equal "2". In Flash it is referenced by 0; myArray[0] would equal "2" while myArray[1] would equal "4".

Inserting Flash into Authorware
We first need to insert an existing Flash SWF movie into Authorware. You load a Flash movie into Authorware through the menu: Insert>Media>Flash, which will open the Flash Asset Properties dialog, allowing you to select the file you wish to load. Use the Browse button to find the .swf you want to import (see Image I).

The Media and Playback options are pretty straightforward, but here are two items worth mentioning:
1.  If you link to a file, make sure the link is relative; otherwise it may break when you package it.
2.  Notice the Image and Sound checkboxes. These checkboxes decide whether your Flash movie has visual or audio elements. Though I imagine these are checked 99% of the time, it's good to know they're here since they can have such a dramatic impact on your Flash movies. I once spent an hour trying to figure out why the sound I'd added to my Flash movie wasn't playing before I realized I had the Sound checkbox unchecked - I had told Authorware not to play any sounds!

Sending Messages from Flash to Authorware
Often Flash and Authorware don't need to communicate at all - developers just drop in the .swf and let it play. But that would make for a really short article, so let's take a look at sending information back and forth between the two programs and responding to that information. You may want to have Flash tell Authorware that a button has been clicked or that a specific frame has been reached.

Flash talks to Authorware using the getURL("myMessage") function. You can add getURL() to buttons or in keyframes to let Authorware know an event has occurred or a specific frame has been reached. GetURL() sends a message, and you have to set Authorware to capture the message; you do this using an Event interaction. Drag an interaction icon to the Authorware flowline and add a calc icon to it. Then set the response type to Event, as shown in Image II.

Once you have set this response type to Event, the interaction will switch from a button to an "E". Click the "E" to change the properties of the Event interaction. You need to set this interaction to listen for getURL commands from Flash movies.

In the Sender section is a list of all the icons that send events that Authorware recognizes. In this sample I only have two Flash movies: "10_10_10" and "10_20_10". Double-click the icon (or icons) that interest you. When a "Sender" is selected, the Event field will display a few choices. We are looking for the getURL event, since that is what Flash is using to communicate (see Image III).

Notice the "x" next to each name that has been double-clicked. You can double-click again to deselect one or more items. In Image III I have also double-clicked the getURL Event - it also has an "x".

Note: You have to select an event for each sender. It may look like getURL is selected for both Icon 10_10_10 and Icon 10_20_10, but it is possible that getURL is only selected for Icon 10_20_10. Take your time to get this right, since this is a crucial part of communication.

We still aren't quite finished; we have to capture the actual message sent from Flash and act upon it. This is done with only one line of code.

In a calc icon in this Event interaction you need the following code:

result:= EventLastMatched[#urlString]

It may look complicated, but the code simply asks for the string sent from the Flash movie. The "result" will be whatever is sent from the getURL() function in Flash. GetURL("myMessage") in Flash would make "result" in Authorware equal "myMessage".

Sending messages to Authorware makes it possible to use Flash to create menus or user interactions that can be directly acted upon in Authorware. This allows Flash to be a tool in your courseware, not merely a media type.

Authorware to Flash
Communication often needs to go in both directions. If Flash can tell Authorware when a button is clicked, why not have Authorware tell Flash which buttons to display? Or tell Flash when to play an animation or what data is needed in a chart?

Communicating from Authorware to Flash is simpler than communicating from Flash to Authorware. Authorware uses three main function types - CallSprite(), getSpriteProperty(), and setSpriteProperty(). Each function is relatively straightforward, but you have a lot more options than you have when you send messages from Flash to Authorware. Authorware uses CallSprite(@"Flash Icon", #setVariable, "myVariable", "myValue") to send messages to Flash.

In Image IV, "myCount", a variable, which has to exist in Flash already, would be set to "5".

Note: Even though 5 is a number and "myCount" is most likely a numeric value, the parameter passed has to be a string. Therefore, either wrap it in quotes or use the String() function in Authorware. If it isn't sent as a string, the value of the variable will not be changed in Flash.

This Authorware sample has two icons, a Flash movie called "myFlash" followed by a calc icon that sets a variable in the "myFlash" movie called "myCount" to 5. The corresponding Flash movie file is one frame with a variable called "myCount" (initially set to "1") and a text box that displays "myCount". The text box properties look like Image V.

I use the Var property since it automatically updates when "myCount" changes. Before getting to "The Hard Part" I want to wrap up with some other common functions used to communicate from Authorware to Flash.

The corresponding function to #setVariable is #getVariable.

result:=CallSprite(@"myFlash", #getVariable, "myCount")

You can use this to verify that your #setVariable worked or to check a value if Flash is also changing a variable's value.

Finally we have playback functions, which control the Flash movie timeline (see Code I).

It may take a while to get used to these functions, but eventually they become second nature.

The Rewards
Aside from nice vector animations, Flash offers additional solutions for tricky problems in Authorware.

  • Components: Download the Flash UI components sets 1 and 2 and the Flash Charting Components from www.macromedia.com/cfusion/exchange/index.cfm. These components are usually easy to configure and use. I'm not a big fan of the WinControls in Authorware, so Flash's Tree Menu and input text fields offer great alternatives that are also cross-platform.
  • Embedded fonts and text features: Flash has a great deal of text controls, and I love that you can call asfunctions or hyperlinks from text. When you combine this with embedded fonts it is a great way to handle tricky text issues. Authorware's inability to embed fonts is a hassle, especially when you have to deal with different font encodings for different languages. Flash can allow for HTML, dynamic hot text, and dynamic text styles - all of which are difficult for Authorware.
  • XML: I like the way Flash handles XML better than the way Authorware does, and Authorware can't write XML nodes easily. I tend to embed Flash files when I'm working with XML.

    4.  Animated buttons: I've made a few courses with animated buttons that move to show progress. This can look very nice, but don't overdo it.
    5.  Pan and zoom: Panning isn't too hard in Authorware, but zooming is. This is one of Flash's strong points. From Authorware, look into the #viewScale, #viewH, and #viewV functions. For an example of this, check out the "Flash.a7p" show-me file on the Authorware CD.

    The Hard Part
    In my last example I used the Var property of a textField instead of the more current format of myTextFieldName.text=myCount. I wanted to whet your appetite a little before I got to some of the difficulties you will encounter when integrating Flash and Authorware.

    I used Var because it's easy. There's nothing wrong with easy, but it's often more limited than other ways of doing things. The Var property updates automatically when its corresponding variable updates. However, when you set the text field in ActionScript code, it only updates when that code is run.

    You can also use dot syntax with #setVariable, so CallSprite(@"myFlash", #setVariable, " myTextFieldName.text", "5") would also work. But what happens if you want to do more than just display this variable in your Flash movie? If you need to modify the variable and respond to it, then you need to do it in ActionScript code. If you need to do it in code, then you need to ensure that all the necessary information is already in Flash before that code is executed.

    Many beginners have Flash loop so that the frame containing the needed code is hit often. This works, but it's inefficient and will use a lot of processing power. It also isn't very accurate if you need to act upon more than one simple piece of information.

    The second option is to use stop() functions in Flash and then use #setVariable followed by #play to hit the frame with your code in it after the variable has been set.

    This also works, but leads to awkward Flash files that are confusing to modify and update. With one variable, it isn't bad. But can you imagine a 100-frame animation with variables set at different times?

    This is the hardest part of using Flash in Authorware: responding to events and changes in a timely manner. It takes planning to create integrated projects that work the way you want without either using up processes by continuously looping or creating convoluted Flash files.

    Tips and Tricks
    Okay, here's the part you've probably been waiting for - practical solutions.

    Code for Flash Icons in Authorware
    I almost always attach the code shown in Image VI to every Flash Icon on the flowline.

    "Movable@IconID" should be pretty easy to understand: it just means that a user can't drag the Flash movie around the screen. You may want to allow Movable at times, but usually I want my Flash movie to stay where I put it.

    The second line makes the variable "FlashID" a reference to your Flash icon, allowing you to modify the icon without referring to it by name.

    CallSprite(@FlashID...)
    Instead of
    CallSprite(@"myFlash"...)

    Note: With "FlashID" you don't use quotes. Use @FlashID, not @"myFlash".

    Why is this helpful? A typical Authorware piece of mine may have a dozen or more Flash movies, and this code allows me to accomplish several things:

  • Reuse code where applicable: I usually use code to pass variables or navigate through a Flash movie file. This allows me to change parameters without having to decide which .swf I need to target.
  • Code is easier to read: "@FlashID" tells me I'm working with the current Flash movie. If you use icon names, then it's not often clear what you are changing. (@"01_02_030_Staff.swf")?
  • Global controls in Authorware: This is the biggie. If I always know that FlashID is the most current Flash movie, then I can add a pause/play button that will always work!

    Image VII shows some code that I've used for a global pause button. It should be placed in a perpetual button at the top of your flowline.

    For the pause/play button see Code II.

    It's that easy. You could also add other code here as well. You may want to tell the Flash piece it is inactive, or perhaps toggle the Direct to Screen property so that is doesn't take up as many resources.

    Code for Flash Movie Completed
    I have created a number of courses that don't allow users to proceed in a section until they have completed all activities on each page. It's therefore necessary to know when a Flash file is finished so that the Next or Continue button can be activated.

    It is sometimes possible to use the following code in the active if field of your Continue button:

    getSpriteProperty(@FlashID, #Frame) = getSpriteProperty(@FlashID, #frameCount)

    This won't work, however, if the last frame has either submovie clips or actions the users need to complete. This is why I tend to add a line of code in each Flash piece letting Authorware know when I consider a movie to be complete.

    While occasionally you can get away with checking if the current frame is the last frame, it is easier to simply add a little code in Flash to tell Authorware when it is finished.

    Controlling Flash Files with Multiple Segments
    It is often easier to have one Flash file with multiple scenes instead of maintaining several Flash files with similar content. While you want all the content in the one Flash movie, you'll most likely want to control which segment is played, and when, from Authorware.

    There are easy and hard ways to do this, with the easy way having more limitations. The easy way is to use #gotoFrame at the appropriate times to get to the part of the Flash movie that you want. Here are a few pointers:

  • The Flash file will ignore stop() commands in the frame it's sent to. So if you use CallSprite(@FlashID, #gotoFrame, 5) you'll need a stop() function in frame 6 or higher or the Flash movie will simply continue playing. Another possibility would be to also use CallSprite(@FlashID, #stop) from Authorware.
  • #gotoFrame will not reload the current frame. I've worked around this by navigating twice - once to frame one and then a second time to the frame I want. If your #gotoFrame commands aren't working, make sure you are jumping to a distinct new frame.
  • Using Frame labels in Flash is a lot safer than using Frame numbers.

    A more complex way of controlling Flash playback is to create a control frame in Flash. All navigation takes place from this frame based on a variable that is sent from Authorware. So while Authorware decides when and where to navigate, Flash actually handles the navigation internally.

    Authorware would use #setVariable indicating the desired scene and then would use #gotoFrame to the control frame. Since the control frame always uses goto(), it will never be the current frame for more than an instant.

    Advanced Data Sharing
    You will most likely reach a point where you want to send more than a simple string or number to your Flash movie. You have to send everything as strings, but here are a few methods that I have used to get complex data types to Flash.

    Passing Arrays to Flash
    Linear arrays aren't too hard. Say you have an array "myArray=["fish", 7]" in Authorware:
    1.  Convert the Array to a string and remove the brackets.

    temp:=Strip("[]",String(myArray))

    2.  Send this value to the Flash Movie.

    CallSprite(@myFlash, #setVariable, "PreArray", temp)

    3.  Navigate to a frame containing the code in step 4.

    CallSprite(@myFlash,#gotoFrame, n)

    4.  Add the following code in Flash in frame 'n'.

    myArray=PreArray.split(",")

    5.  myArray is now an array in Flash that mirrors myArray in Authorware.

    Note: The two things to watch out for are commas in your Array and European deployment. In Europe, a semicolon is used to separate lists instead of a comma. If either of these is the case, you will need to loop through your array, adding each index to a string with a different, perhaps multicharacter, separator.

    A colleague suggested the following method for sending arrays. In this example you would need an empty array in your Flash Movie called "_array" (see Code III).]

    You must ensure that "_array" is empty, however, as this method will not clear out pre-existing indexes if the original array has a greater length than the new array.

    Multilinear arrays take more effort. I have had to create a pseudo-subroutine for those. I've never had to pass a property list (an associative array in Flash), but I imagine this could be done with a subroutine, as well.

    A Fake Listener in Flash
    It is much easier to let Flash handle its own navigation than to have Authorware tell it which frames to go to. This is because edits to the Flash movie often add or remove frames, which can break all of your #gotoFrame functions if the frame numbers you jump to change.

    Therefore, I built upon the control frame idea discussed before and created a control Movie Clip for my Flash movies. A simple control Movie Clip has two frames and continuously loops to check for new information from Authorware. Frame 1 is shown in Code IV; Frame 2 is shown in Code V.

    This is just a sample; Frame 2 could also be a case statement, and a real example would probably have more navigation options. On the Authorware side you only need to send one variable and everything else is taken care of by Flash.

    CallSprite(@FlashID, #setVariable, "authorwareEvent", "pause")

    or

    CallSprite(@FlashID, #setVariable, "authorwareEvent", "scene3")

    If you are fairly comfortable coding in Flash, an even better solution would be to use the Watch() function introduced in Flash MX (see Code VI). Code VI can be placed on the main timeline and does not require any looping.

    A Pseudo Subroutine
    Probably the most complex integration of Flash and Authorware that I've attempted is to set up a tree menu in Flash based upon a directory structure in Authorware. Let's say I have a course with frameworks for modules, subframeworks for lessons, and sometimes subframeworks for pages. I can't say I won't have deeper frameworks as well, so I can't limit my code to three layers deep.

    This is too complex to describe here, but it can be done by looping a decision icon in Authorware that sends parent and children information for each Framework to Flash and then waits until Flash lets Authorware know that it has added the nodes to the tree Menu.

    Optimization Techniques for Flash Playback
    If you've ever dropped a large animated Flash movie into Authorware, you've noticed that it can slow things down a lot! Here are some tips for getting the best playback possible. We'll mostly be looking at the display properties.

    You should always:

    • Keep your Flash files as small (in pixels) as possible.
    • Put your Flash movie on a Layer above 0 and which has no other display items.
    • Minimize on-screen events if possible, in Flash and Authorware.
    • Ensure that Mode is Opaque (2) and Direct to Screen (3) should be checked when possible.
    Let me talk about Mode and Direct to Screen for a moment. Direct to Screen will tell Authorware to display the Flash movie above everything else and is significantly faster than placing the Flash movie on a layer. However, you can't have a transparent Flash movie when you check Direct to Screen - the transparency simply doesn't take effect.

    You'll want to use Direct to Screen unless there is something else that you need to display above your Flash movie or if you need the Flash movie to be transparent. It may be necessary to toggle Direct to Screen on for complex scenes and off for standard use (SetSpriteProperty(@FlashID, #directToStage, true), SetSpriteProperty(@FlashID, #directToStage, false)) if you need that level of control.

    Setting Mode to Transparent is a wonderful feature, but it will slow things down, especially since you can't set the Flash movie to Direct to Screen. You only want to use transparency when you need to. There are modes other than Opaque and Transparent, but they don't seem to have any affect on Flash Movies, so stick to Opaque or Transparent.

    If you use Transparent, then also be sure to set Authorware's GlobalTempo to the same frame rate as your Flash Movie (Using 'GlobalTempo:=n') in an Authorware Calc.)

    If you still need to increase playback performance, you have additional options in the Options button from the Properties panel.

    Additional Options:

  • You can set Quality to Low, which will turn off anti-aliasing.
  • Experiment with Rate. I'm a little fuzzy on this, but I believe "Normal" skips frames in the Flash movie if it is lagging behind. Both Lock-Step and Fixed allow a little more control for frame playback.
    - Lock-Step will match frames per second to Authorware's global tempo (which can be changed in Authorware with this code 'GlobalTempo:=n'). I believe this will force Flash to refresh at this rate. Flash Asset Help says this is the best performance of the three options.
    - Fixed allows you to set a playback rate to a specific fps rate.
    - Experiment to find what works best.
  • Avoid unnecessary looping in your Flash Movie.

    There are other excellent tips in the Flash Asset documents [path to Authorware on your computer]\xtras\FlashAsset\Help\FlashAsset.html. If you're still having trouble, post a question to the Authorware Listserv http://listserv.cc.kuleuven.ac.be/archives/aware.html.

    This is an excellent resource where new users and experts exchange ideas and assistance, with Flash performance being a frequent topic.

    Conclusion
    I hope that this article has given you some new ideas as to how to blend Flash into your Authorware work and provided enough code snippets to get you started. I started as an Authorware developer, so my knowledge of what Flash could do was limited and learning what was possible has been a challenge over the years. Pan and Zoom is just not something I would consider in Authorware alone, but with Flash it's fairly easy. Consider whether Pan and Zoom would help in your current courseware.

    If you are writing courseware that involves scheduling or history, consider whether the calendar component would make things easier. Would graphing components add a nice visual element?

    I hope that you are able to use these samples. Look for these and other source files on my Web site as well (www.guitar-learning.com/awflash). Happy Coding!

  • About Derek Stottlemyer
    Derek Stottlemyer has produced a number of guitar- and music-related software titles using Authorware, Flash, and Central. He also develops training and Web applications for the automotive, health, and financial industries.

    In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1

    Enterprise Open Source Magazine Latest Stories . . .
    Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP). The...
    With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
    AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
    During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
    Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
    A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
    Subscribe to the World's Most Powerful Newsletters
    Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


    SYS-CON Featured Whitepapers
    ADS BY GOOGLE