AS3 hotkeys reference

Are you looking to speed up your coding in AS3 when you are working in Flash environment?  Here is a list of hotkeys that you can use in your actions Panel or with external .as files.  Just hit the [Esc] key and then individually hit the two keys listed after and Flash will spit out a snippet of code for you.

If you want to add your own Flash Quickeys go into the ActionsPanel.xml file and add a quickey.  For example if I wanted to create a pacakage that contained a class and a constructor then I could create my own quickey to do all of that. or if I just wanted to create a package then I would add id =”package” quickey=”pk” to the line that starts <string name=”package” in a similar fashion as the rest of the line with quickeys.

Flash ActionScript3 HotKeys

AS3 output Quickey
   
trace ( ); [Esc – tr]
break( ); [Esc – br]
case condition : [Esc – ce]
continue; [Esc -co]
default : [Esc -dt]
do { } while ( ); [Esc-do]
} else { [Esc -el]
for ( ) { } [Esc -fr]
for ( ) { } [Esc -fi]
if ( ) { } [Esc -if]
return ( ); [Esc -rt]
switch ( ) { } [Esc -sw]
throw ; [Esc -th]
try { } [Esc – ty]
catch ( ) [Esc -ch]
finally { } [Esc -fy]
” “ [Esc -ev]
while ( ) { } [Esc -wh]
with ( ) { } [Esc -wt]
class { } [Esc -cl]
function ( ) { } [Esc -fn]
var ; [Esc -vr]
// [Esc -//]

As always happy Flashing

Curtis J. Morley

P.S.  Here is the code I used to grab all of the quickeys from the ActionsPanel.xml file.  I love E4X.

var quickeyXML:XML = {I pasted the XML from ActionsPanel.xml here}

for each (var element:XML in quickeyXML..@quickey)

{

trace(“[Esc – “+element+”]”);

}

Heeeee-lariouos – Design Minstrel sings about Flash

Matt Maxwell Sings at Flash ForwardAll right you Flashers. Stop banging your heads because of the latest Flash Error and go spend a little time with Matt Maxwell. Matt understands your pain and even sings about it. Once you hear Matt’s lucid tomes you will be blown away at how well he understands your pain.

Matt recently sang one of his Songs about Flash at Flash Forward to a crowd of raving fans.

This is my favorite:
Flash Song by Matt Maxwell – Long Preloader

Matt is a phenominal designer, Flasher, interactive 3D website creator, and a stinking funny performer.

Check out his stuff:

www.MattMaxwellDesign.com

www.designmnistrel.com

Hopefully this will give you a break from those wicked Flash/Flex/AS3 errors and give you a good laugh.

Happy Flashing,

Curtis J. Morley

Teaching Flash again at UVU

Utah Valley University For everyone that has wanted help with their Flash now is your chance to get it. If you have ever said, “Man! I wish I could just ask Curtis this question in person.” sign up for DGM 2870 at the newest University in the Nation, UVU. The class is going to focus on ActionScript Fundamentals and will have a syllabus that looks something like this. I started teaching over 8 years ago and was the first person to teach Flash in Utah. I spent most of my time teaching at UVU (then UVSC) and had a little stint with SLCC (Salt Lake Community College) and then a few years teaching in the Masters of Information Systems at the Largest Private University in the nation, Brigham Young University.

Flash CS3 IconNow I am back to my roots. I am excited to start teaching College Flash again. I will cover ActionScript Fundamentals using the book by Rich Shupe. Arrays, External AS, functions, conditionals, interactivity, usability, Object Oriented Programming, and mobile will be taught. I will be using GoCourse as my LMS/Content Creation Tool/ Grading system for enhanced learning for my students and easier teaching for me.

Super Smash BrothersThe class is extremely fun. It is also a lot of work but the reward is fantastic. I don’t know if it is quite as fun as Super Smash Brothers Melee Theory and Practice taught by Brian Mazur, Mike Blejer and Quentin Jones at Oberlin College (Don’t believe me? Click the link and scroll to the bottom under “Physical Activities and Games”) they also list Stilting as a 1 credit course.

Stilt JumpingAlthough we wont be walking on stilts or playing Nintendo for 2 hours we will learn how to create kick-butt applications, games, widgets, mobile applications, and websites with ActionScript. So go to UVU.edu and sign up today for the night class (7:30-8:45 p.m.).

Flash Error #1180: Call to a possibly undefined method myCustomClass.

ActionScript 3 Error: 1180: Call to a possibly undefined method CustomClass.

ActionScript 3 Error #1180 Description:

One reason for this this error is because you are using the name of the variable that you are assigning to the Class rather than the Class itself.  Adobe also states that this error will only display when “Strict Mode” is turned on.

Flex / Flash Error #1180 Fix:

Make sure that when you instantiate the Object that you are using the Class name and not the variable name.

Bad Code:

var myCustomClass:CustomClass = new myCustomClass();

Good Code:

var myCustomClass:CustomClass = new CustomClass();

Links:

http://www.flashcomguru.com/index.cfm/2007/4/17/Flex-Builder-2-to-write-AS3-code-for-Flash

This should help you resolve Flex / Flash Error #1180

Thanks and as always Happy Flashing

Curtis J. Morley

AS3 Error #1051: Return value must be undefined.

ActionScript 3 Error: 1051: Return value must be undefined.

ActionScript 3 Error #1051 Description:
This error is popped up when you have specified the return type of a function as “void” and then returned something like a String, Number, etc…

Flex / Flash Error #1051 Fix:

If you need to return something from this function then simply specify the return type properly.

Bad Code:

function bob():void
{
return “message”;
}

Good Code:

function bob():String
{
return “message”;
}

Related Errors:

Flash Error 1067 (If you specified a return type of int, uint, Number, Array, Bitmap, etc…)
Flash Warning 3590 (If you specified a return type of Boolean)
Flash Error 1046 (If you specified a return type of Button)

This should help you resolve Flex / Flash Error #1051

Thanks and as always Happy Flashing

Curtis J. Morley

WordPressの私のブログに今日本語がある

I have added multi-lingual support to my blog.  Anyone can now enter comments in Japanese (and all other languages for that matter). I am not fluent in Japanese but fairly conversational and I can understand most phrases and grammar.  I will do my best to answer your questions.  Making WordPress support Japanese in the comment fields was not as hard as I thought.  My only other language is Japanese so I won’t be able to answer questions in other languages. So this is for all my fellow Flashers in 日本.

Happy Flashing,

Curtis J. Morley

ActionScript 3 Error: 1038: Target of break statement was not found.

ActionScript 3 Error: 1038: Target of break statement was not found.

ActionScript 3 Error #1038 Description:
A break statement is used only with loops. They will not work in if statements. This is directly from the documentation:

Appears within a loop (for, for..in, for each..in, do..while, or while) or within a block of statements associated with a particular case in a switch statement. When used in a loop, the break statement instructs Flash to skip the rest of the loop body, stop the looping action, and execute the statement following the loop statement. When used in a switch, the break statement instructs Flash to skip the rest of the statements in that case block and jump to the first statement that follows the enclosing switch statement.

In nested loops, break only skips the rest of the immediate loop and does not break out of the entire series of nested loops. To break out of an entire series of nested loops, use label or try..catch..finally.

The break statement can have an optional label that must match an outer labeled statement. Use of a label that does not match the label of an outer statement is a syntax error. Labeled break statements can be used to break out of multiple levels of nested loop statements, switch statements, or block statements. For an example, see the entry for the label statement.

Pay attention to the last two paragraphs if you want to break all the way out of a function/method rather than just the loop that the break statement is inside then you need to use label. A very handy but seldom used method

Flex / Flash Error #1038 Fix:
Make sure that your break statement is within a valid loop such as for, while, switch statements, etc… Another alternative is to use a return statement without any parameters. Warning: Using return will break out of the function entirely and will not execute any code after the if statement. return is typically used as the last line of code in a function.

Bad Code:

if (totalScore < 10)
{
finalMsg = “Sorry!<br /> You need more practice”;
break;
}
else if (totalScore < 20)
{
finalMsg = “Congratulations!<br /> You kept yourself and others safe”;
break;
}

Good Code:

if (totalScore < 10)
{
finalMsg = “Sorry!<br /> You need more practice”;
return;
}
else if (totalScore < 20)
{
finalMsg = “Congratulations!<br /> You kept yourself and others safe”;
//break can be removed to get rid of the error;
}

This should help you resolve Flex / Flash Warning #1038

Thanks and as always Happy Flashing

Curtis J. Morley