Programmatic tweens, optimization, and XML

Programmatic tweens

Programmed tweens are excellent not only for saving on file size, but also for handling all sorts of dynamic interactions where a reaction to an event may require an item on the screen to move in a number of unspecified directions.

These next steps will only cover a very basic use of tweens. Keep in mind that if you move on to advanced actionscripting, it may be helpful to look into more advanced ways of tweening, as Adobe's own tweening engine is quite slow.

  1. Open up your lab 7 file and name it xxx_Lab8_1.fla, with the XXX being your initials.
  2. Clear all the frames after the first on the button layers
  3. On frame 1 of the actions layer, add this code

Optimization

Assuming your graphics have been optimized following the material covered in lecture,

and that you are loading in external swfs in logical places, Optimization is a simple matter of tweaking final export settings on the file. These next steps will show you how to optimized our current file.

  1. Click file -> publish settings
  2. In the window that pops up, click 'flash'
  3. Under options, check 'Omit trace actions'. This will speed up any flash file that is tracing out information in large amounts.
  4. Also click 'Protect from import' and specify a password beneath the options list.
  5. Finally click 'generate size report'.
  6. Publish the movie.
  7. You will be presented with output detailing the size output on different frames. Pay special attention to where there are especially large numbers - these are the ones you will want to double-check and try to pair down the data contained in the frame.

Some ways to cut down on other size problems are detailed in the lecture material. Pay attention to the settings applied to your images and sounds - these can have a huge effect on the final size of your file, and can usually be tweaked to smaller sizes without a huge loss in quality.

XML

XML is a great way to pass data into flash. Thankfully getting it into flash is just as easy as loading in an external file ( although some extra parsing is needed ), so here is an example of how to load in some XML info for your about page.

  1. Download info.xml to the same folder as your lab 8 folder.
  2. Open it up and change some of the values within the tags, so you understand the structure of the XML file.
  3. Return to your lab 8 file.
  4. Select the actions on the first frame of the page1 section.
  5. Replace the code currently there with this.

Final task

Taking what you know from this lab, load in your image information from an XML file in imageBox.swf. This data will replace the information contained within stuffArr in imageMain.as. In addition, when the image is loaded, tween it onto the stage via actionscript.

This task is rather easy, but there are some pieces of information I have not provided. As many heads are ( in some ways ) better than one, group work is allowed and encouraged. Blatant code copy is not, so make some effort to understand the process and re-write the code.

Submit your final lab 8 files on Friday.