Speaking on Flash and Flex at UVSC

Thanks to Thor for having me come present in the Multimedia Dept. The class was great. As promised here are the links to examples, applications, and books that I talked about.

Applications that I have been a part of

Rifle Builder – Shopping Cart application built originally in Flash 5
LDS.org/cm – The Original Interactive Sheet Music Player
MusicRain.com
– Commercial Interactive Sheet Music
LogoMaker.com – HP Purchased LogoMaker in-part because of the success of this application.
Thanksgiving Point Dinosaur Games – Click on the “Games and Coupons” button
RideHarder.com – New design by Element
SolutionOverview.com – Green Screen interactive video
BrainHoney – Learning tool for self publication, uses mashups and Facebook integration. upload whatever files you want and make a lesson or learn what you don’t know.

Applications turned into web apps:

Photoshop:
http://www.flauntr.com/
http://www.picnik.com/app#/home/welcome

http://www.splashup.com/
– Fauxto now caled Splashup This is the most fully featured one I have found.

Mapping –
FlashEarth.com
maps.yahoo.com

Microsoft Word:
BuzzWord.com
Grant Skinner Spell Checker for text editing

Image seam carving:
http://swieskowski.net/carve/ – Neat example
http://www.quasimondo.com/archives/000652.php – Example with code
http://rsizr.com/ this one is amazing and you can do it yourself

Video Editing:
RichFLV – Flash Based Video Editing Tool done with Flash/Flex and published with AIR

Motion detection & Vid Cam like Minority Report etc..
incomplet.gskinner.com

Sheet Music Applications –
LDS.org/cm – The Original Interactive Sheet Music Player
MusicRain.com
– Commercial Interactive Sheet Music

Books:
Adobe Digital Editions

Quicken:
mint.com – Web based version of Quickenfor money management

The Radio:
www.pandora.com – the music genome project

iTunes:
www.anywhere.fm/player

Outlook:
www.goowy.com/index.aspx – Flash web based Outlook knock-off.

Great Books For Flash, Flex, and ActionScript –

ActionScript

Intermediate Books

Begining Books

Books not to buy

  • AS3 Game Programming University – Only buy this book if you have never used Flash. The games are good BASIC games but the graphics are horrible and the examples don’t really teach the prinicples behind game design.
  • Flash CS3 The missing manual. – You might as well buy the Dummies book(see below) if you are going to buy this one. Not a good place to start. Not comprehensive. Not well written.
  • Flash CS3 On Demand – This book should not be allowed to be called CS3 because some of the examples are not even using AS3. If you own Flash 8 then you will want this book but not for CS3.
  • Flash CS3 for Dummies – You are not a dumb, but may feel like it after spending any money on this book. They do have good cartoons though.

Thanks,

Curtis J. Morley

Flex / Flash CS3 Warning# 3551

ActionScript Warning: 3551: Appending text to a TextField using += is many times slower than using the TextField.appendText() method.

ActionScript Error Description:
I love this ActionScript Warning. This is not technically an ActionScript Error instead it is a warning that helps you code better. It is very clear and easily deciphered. This states that you should not use the old way to add text to a text field but rather use the new TextField.appendText() method. This improves performance dramatically and will prevent the user from getting the 15 sec. timeout. (Error #1502: A script has executed for longer than the default timeout period of 15 seconds.)

Fix:
Use TextField.appendText() instead of +=.

Bad Code:

var something:String = “Happy “;
var somethingElse:String = “Birthday”;
myTF_txt.text = something;
myTF_txt.text += somethingElse;

Good Code:

var something:String = “Happy “;
var somethingElse:String = “Birthday”;
myTF_txt.text = something;
myTF_txt.appendText(somethingElse);

ActionScript Warning #3551 is simple and easy (the way that all ActionScript errors/ warnings should be)

As always – Happy Flashing

Flash / Flex Tutorial – How to Create a crossdomain.xml file.

Flash / Flex Tutorial – How to Create a crossdomain.xml file.

This brief tutorial will teach you how to create a crossdomain.xml file so that you can access files and information from outside domains and load files and data within your Flash / Flex apps. It is as simple as 4 easy steps.

  1. Create an xml file named crossdomain.xml. (XML can be created with Dreamweaver or just simply MS Notepad. Just make sure that you give it the ‘.xml ‘ extension on the end.)
  2. Copy and paste one of the code examples below into the XML file:
  3. Save the file.
  4. FTP / upload the file to the root directory of your website. (you should be able to see the file in a browser by typing the url www.yourwebsite.com/crossdomain.xml).

XML Code 1:
This is a typical crossdomain.xml file. Notice that I included my domain as well as my domain without the ‘www’ in front.

<?xml version=”1.0″?><!DOCTYPE cross-domain-policySYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<allow-access-from domain=”www.curtismorley.com” />
<allow-access-from domain=”curtismorley.com” />
</cross-domain-policy>

XML Code 2:
The follwing Code will allow all domains. This effectively eliminates any security that Flash would have otherwise had. I suggest that you don’t use this example unless you enjoy security holes.

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<allow-access-from domain=”*” />
</cross-domain-policy>

XML Code 3:
The block of code below will explicitly disallow any and all access from any outside domain. As well, any domain that is not spelled exactly how the host domain is spelled will be blocked. This is the tighest cross domain security that you can employee.

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
</cross-domain-policy>

XML Code 4:
The code below illustrates different uses of the ‘*’ wildcard symbol. This is the crossdomain.xml file from Amazon.com The wildcard allows for any variation before ‘.amazon.com’. Amazon does this because of the public services and APIs that it allows others to connect to.

<cross-domain-policy>
<allow-access-from domain=”*.amazon.com”/>
<allow-access-from domain=”amazon.com”/>
<allow-access-from domain=”www.amazon.com”/>
<allow-access-from domain=”pre-prod.amazon.com”/>
<allow-access-from domain=”devo.amazon.com”/>
<allow-access-from domain=”images.amazon.com”/>
<allow-access-from domain=”anon.amazon.speedera.net”/>
<allow-access-from domain=”*.amazon.ca”/>
<allow-access-from domain=”*.amazon.de”/>
<allow-access-from domain=”*.amazon.fr”/>
<allow-access-from domain=”*.amazon.jp”/>
<allow-access-from domain=”*.amazon.co.jp”/>
<allow-access-from domain=”*.amazon.uk”/>
<allow-access-from domain=”*.amazon.co.uk”/>
</cross-domain-policy>

Creating a cross domain policy file is just that easy.

And Happy Flashing.

P.S. I highly suggest that you read one or all of the following articles on cross domain policy files and the Flash Player security sandbox,

Crossdomain Article by Colin Moock

Adobe Crossdomain Technote (this one is required reading)

Flash Player 9 Security Whitepaper

Adobe LiveDocs on Flash Player Security

Flash CS3 / Flex 2 AS3 Error #1093

ActionScript Error #1093: Syntax error.

Update 2/25/2008

Description:
This is one of the least descriptive descriptions that Flash/Flex will provide you. It can be given for a number of reasons. Some that I have run into I have not found the reason for, but instead I just rewrite the entire line of code that it reports. One reason that I have found that is duplicate-able is copying code from the web and pasting it into Flash. Most especially code with quotes.

Fix 1:
Delete the line of rogue line of code and retype it from scratch.

Again I had this error and even after commenting the line of code out entirely I still received this error. Once more I deleted the code and retyped and it worked just fine. Below is the line of code commented out. Don’t beat your head on this one. Just delete and retype. I believe that this error has something to do with the copy and paste functionality within the IDE.

Bad/Good Code 1: (this code actually works after being retyped)

/*//stage.removeEventListener(Event.ENTER_FRAME, moveCar);*/

Fix 2:
Delete the quotes from the code that you copied from the web and replace them with regular quotes.

Bad Code 2:

this.thePlayer.videoSource = main_video.flv;

Good code 2:

this.thePlayer.videoSource = main_video.flv;

Fix 3:
Delete the #(pound symbol) before the color value.

Bad Code 3:

graphics.lineStyle(1, #FFFFFF);

Good code 3:

graphics.lineStyle(1, 0xFFFFFF);

Thanks to grildcheese who left a comment about Fix3 above.

Fix 4:
Do not use #include in ActionScript 3 instead use import.

Bad Code 4:

package
{
#include “myClass.as”

Bad Code 4:

package
{
import myClass;

I will continue to post reasons for AS3 error 1093 as I find them and hopefully it will help you out.

As Always, Happy Flashing

Flash CS3 / Flex AS3 Error #1086

ActionScript Error: 1086: Syntax error: expecting semicolon before mult

Description:
This is a very easy and straightforward error with a horrible description. It actually has nothing to do with a semicolon at all. All this error means is that you forgot a ‘.’ in your import before the ‘*’.

Fix:
Add the Dot

Bad Code:

import flash.events*;

Good Code:

import flash.events.*;

Hopefully the confusing description for this ActionScript Error didn’t cause you to pull your hair out.

As Always Happy Flashing

Flash Error #1086: Syntax error: expecting semicolon before dot.

Description:
Another reason for the Flex / Flash Error #1086 is because a function/method call is typed.  It is very important to type a function but do not type the call to the function.

Fix:
Remove the typing at the end of the method call.

Bad Code:

resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail):void;

Good Code:

   resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail);

Happy Flashing

Flash CS3 / Flex AS3 Error #1053

ActionScript Error #1053: Accessor types must match.

Description:
This is a great error that has absolutely no documentation. This is what Adobe has to say about it.

The non-error error.  ActionScript Error #1053 from Adobe Live Docs
Notice how the right side of the image doesn’t have any text at all. It is simply left blank. To understand this error you need to understand what an ‘Accessor’ is. An ‘Accessor’ is a ‘Getter’ that accompanies a ‘Setter’. The reason it is called an ‘Accessor’ is because it accesses the variable set using a ‘Setter’.

So what does that mean for you. This error means that the Getter(Accessor) is not set as the same Type as the Setter.

Fix:
Make sure that whatever you return in the ‘Getter’ is the same ‘Type’ as what is set in the ‘Setter’.

Bad Code:

function get sClickable():String {
return _clickable.toString();
}
function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}

Good Code:

public function get sClickable():Boolean {
return _clickable;
}
public function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}

So now you know how to solve ActionScript Error #1053.

As Always Happy Flashing.

Flash CS3 / Flex 2 Error #5001

ActionScript Error #5001: The name of package ‘com.cjm’ does not reflect the location of this file. Please change the package definition’s name inside this file, or move the file

Description:
This ActionScript error is a very common one especially if you haven’t defined a good package and class structure. The simple answer is that you misspelled something in your package description or you saved the class in the wrong folder. (See example 1)

Another reason that you can get this error in Flash is because you have a Document Class and you have specified the classpath in the “Document class:” field and you have something different typed in your package. You might say well that is not possible. If your default classpath is defined in the AS3 setting then the file will compile and the class will work properly if you remove the classpath all together out of your package. This is not recommended because it is not good practice. Please review the example2 below.

Solution:
Check your paths in the package, class and ‘Document Class’.
Example 1

Bad Code

package com.ckm
{

}

Good Code

package com.cjm
{

}

Example 2

Good Code – Bad “Document class:” definition

package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}

Flash Document Class Path Bad Example

Good Code – Good “Document class:” definition

package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}

Flash Document Class Path

And those are two ways to resolve ActionScript Error #5001

As Always – Happy Flashing

Flash CS3 / Flex 2 Error #1017

ActionScript 3 Error #1017: The definition of base class ImportedClass was not found.

Description 1
You may get this error from importing a custom class that does not have the proper package path into a parent class. Another reason you will get this error is if you forget to import the Class that the subclass is extending(see example 2).

Bad Code 1
(subClass called ImportedClass)

package
{import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}

Parent Class called ImportingClass

package com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}

Good Code 1

(SubClass called ImportedClass)

package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
ImportingClasspackage com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}

Bad Code 2

package com.cjm
{
//import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}

Good Code 2

package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}

Description 2
ActionScript Error #1017: The definition of base class MovieClip was not found.
This ActionScript Error is due to forgetting to import the MovieClip (or any other  referenced class).

Bad Code 3

package com.cjm.sound
{
public class SoundControl extends MovieClip

Good Code 3

package com.cjm.sound
{
import flash.display.MovieClip;
public class SoundControl extends MovieClip

As always – Happy Flashing