Flex 2 / Flash CS3 ActionScript Error #1114

ActionScript Error #1114: The public attribute can only be used inside a package.

Description:
This ActionScript Error justs means that you have used the access control modifier ‘public’ in the wrong spot. There are four access control modifiers – public, private, internal, and protected. Each of these specify how the method or variable is accessed. Each access control modifier has it’s own error but they all mean the same thing. Access control modifiers need to be used in the right place. The ‘internal’ and ‘public’ can only be used inside a ‘package’ and ‘private’ and ‘protected’ can only be used on classes.

Fix:
Make sure to only use the ‘public’ access control modifier to define a method or variable within a package and not inside the class itself nor within a method(function).

Bad Code:

package{
	public class MySize {
		public function Connection():void{
			public var bgColor:uint = 0xFFCC00;
			trace(bgColor);
		}
	}
}

Good Code:

package{
	public class MySize {
		public var bgColor:uint = 0xFFCC00;
		public function Connection():void{
			trace(bgColor);
		}
	}
}

or

package{
	public class MySize {
		public function Connection():void{
			var bgColor:uint = 0xFFCC00;
			trace(bgColor);
		}
	}
}

Related ActionScript Errors – AS3 Error 1013, AS3 Error 1115 , AS3 Error 1150

This ActionScript Error is a quick one. I hope this helps you solve it.

As always Happy Flashing

Flex 2 / Flash CS3 ActionScript Error #1013

ActionScript Error #1013: The private attribute may be used only on class property definitions.

Description:
This ActionScript Error justs means that you have used the access control modifier ‘private’ in the wrong spot. There are four access control modifiers – public, private, internal, and protected. Each of these specify how the method or variable is accessed. Each access control modifier has it’s own error but they all mean the same thing. Access control modifiers need to be used in the right place. The ‘internal’ and ‘public’ can only be used inside a ‘package’ and ‘private’ and ‘protected’ can only be used on classes. AS3 error 1013 can also be caused if you misplace a method identifier like ‘:void’

Fix:
Make sure to only use the ‘private’ access control modifier to define a method or variable within the class itself and not within a method(function).

Bad Code 1:

package{
	public class MySize {
		public function Connection():void{
			private var size:uint = 40;
			trace(size);
		}
	}
}

Good Code 1:

package{
	public class MySize {
		private var size:uint = 40;
		public function Connection():void{
			trace(size);
		}
	}
}

or

package{
	public class MySize {
		public function Connection():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Bad Code 2:

package{
	public class MySize {
		public function Connection():void{
			someFunction():void;
		}

 	private function someFunction():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Good Code 2:

package{
	public class MySize {
		public function Connection():void{
			someFunction();
		}

 	private function someFunction():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Related ActionScript Errors – AS3 Error 1114, AS3 Error 1115 , AS3 Error 1150

This ActionScript Error is a quick one. I hope this helps you solve it.

As always Happy Flashing

Flex 2 /Flash ActionScript Error #2044

Error #2044: Unhandled skinError:. text=[IOErrorEvent type=”ioError” bubbles=false cancelable=false eventPhase=2 text=”Error #2036: Load Never Completed. URL: http://curtismorley.com/someURL/SkinUnderAllNoCaption.swf”]

Description:
Here is a combo meal deal of errors that you may get if you are using one of the basic video component skins in Flash. Flash needs to know where the file is and how it interacts with the video you are playing. The reason you will get this error is because the skin didn’t load and so Flash is trying to wrap this video skin around your video unsuccessfully which produces ActionScript Error 2044. I have always seen ActionScript 3 error 2044 coupled with ActionScript Error #2036 which says that the load of the skin never completed. I get this error because of the way wordpress handles includes.

Fix:
Put the file on the server and link to the file in the Flash Authoring Environment.

Step 1:
Convert your video into an FLV with either Flash itself or with the bundled Flash Video Encoder.

Step 2:
Import the video and go through the wizard provided. Make sure that you choose the skin you would eventually want to control your video. In the screenshot below I chose the SkinUnderAllNoCaption skin. This step is critical because it is necessary to have Flash auto generate a swf of the skin for you.

Flash Video Skin Window

Step 3:
Save your file and you check the folder that your main swf is located in. You should find another file with the name of the skin you chose. In my case the file is called ‘SkinUnderAllNoCaption.swf’.Flash video skin Autogenerated by Flash

Step 4:
FTP the ‘skin’ swf to your server.

Step 5:
Open up your Flash file and select the video. Then go to the component ‘Parameters’ palette ad 2x click the ‘skin’ option as shown in the image below.Flash Video Component Parameter Palette

Step 6:
Choose the last ‘Skin’ option called ‘Custom Skin URL’ and then enter the URL of the skin swf into this field and click ok.
Flash video Custom Skin URL

Step 7:
Don’t panic. The skin will most likely not display in the authoring environment. Hit <CTRL> + <ENTER> on your keyboard to test your movie and you will see the same lovely component that you had originally. The two files below show the file before testing your movie and after.
Flash video in Flash Authoring Environment

Flash video component preview

Step 8:
Upload your swf file to the server in the same place as your skin swf and enjoy.

Troubleshooting:
Make sure that you have a crossdomain.xml file on your server to prevent other ActionScript Errors.

You can see this in action at my post about ‘How I Made History’
Now you have a step-by-step description of how to deal with ActionScript Error #2044

As always – Happy Flashing

Flex 2/ Flash CS3 Error #3590

Flex 2/ Flash CS3 Warning / Error #3590: String used where a Boolean value was expected. The expression will be type coerced to Boolean.

or

Warning: 3590: int used where a Boolean value was expected. The expression will be type coerced to Boolean.

Description:
This is a ActionScript error is more of a warning than a true AS3 error. It will be displayed in strict mode and simply means that you have quotes around your Boolean value. Even though you may get this AS3 error it won’t prevent Flex or Flash from compiling nor ActinoScript code. It will convert it for you though. Thanks Flash for doing that for us.

AS3 Warning #3590 Fix 1:
Make sure that your boolean (true or false is not inside quotes).

Bad Code 1:

myObject.visible = “false”;

Good Code 1:

myObject.visible = false;

AS3 Warning #3590 Fix 2:
ActionScript 3 uses true and False rather than 0 and 1 for boolean. Although it does allow 0 to make it through without giving this error.

Bad Code 2:

myObject.visible = 1;

Good Code 2:

myObject.visible = true;

AS3 Warning 3590: Fix #3*Warning* This method will solve the problem temporarily and allow you to publish your code BUT it will cause you many headaches later. You will not get any warnings or error messages and this is a bad thing I Promise! If you are going to proceed down this path make sure to recheck these boxes after you are done publishing your one problem movie. With that much said, The way you do this is to turn off Strict (Verbose) Error Messages in your preferences as shown below.

Go to File >> Publish Settings >> Click on the “Flash” tab >> Next to “ActionScript version:” click the “Settings…”

AS3 Error 1118 -Implicit Coercion

AS3 Warning 3590 Fix #4 – In the example below you will see that the function “Return Type” is listed as Boolean when it needs to be listed as String.  To fix this simply change the Return Type to String or return a Boolean value “true” or “false”.

Bad Code:

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

Good Code:

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

AS3 Warning 3590 is pretty easy and straight forward.

As always – Happy Flashing

Flex 2 / Flash CS3 Syntax Error #1100

Error #1100: Syntax error: XML does not have matching begin and end tags.

Description:
Here is another easy AS3 error. This Flex/Flash Error means that your XML is not valid because the end tag is simply missing or you left off the end slash (/). *Note: This AS3 error is similar to ActionScript Error #1085

Solution:
Close that end tag.

Bad Code 1

var dogXML:XML =
<dog>
<name>Fido
</dog>

or

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido<name>
</dog>

Good Code

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido</name>
</dog>

Related Errors:
ActionScript Error #1085

I hope this helps you solve ActionScript Error #1100

As Always Happy Flashing

Curtis J. Morley

Flex 2 / Flash CS3 Error #1085

TypeError: Error #1085: The element type “name” must be terminated by the matching end-tag “</key>”.

Description:
Here is another easy AS3 error. This Flash Error means that your XML is not valid because the end tag either does not match the opening tag or that the tag is simply missing. When it says “The element type” it is talking about the XML element. In my case this would be <name>. *Note: This AS3 error is similar to ActionScript Error #1100

Solution:
Check your spelling and make sure that you have properly nested tags.

Bad Code 1

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido</namer>
</dog>

Bad Code 2

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido
</dog>
</name>

Good Code

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido</name>
</dog>

I hope this helps you solve ActionScript Error #1085

As Always Happy Flashing

Flash SEO – Google Analytics and Flash Overview

What is the most effective way to use Google Analytics and Flash?

How would you like to be able to know exactly how people are accessing your site and what they do when they are there? With Flash you can. And Google has provided the back end system free of charge for you to do it. It is called Google Analytics.

Google and Flash can show you exactly what people are doing on your site. I know how many people are mousing over the Flash piece. I know how many people are clicking a certain button. I know how many times a button is rolled-over without being clicked. I know how long the mouse is over the object. I can know every piece of data that is possible to know about what and how my users are interacting with the page, advertisement or application.

There are three key components in using Google Analytics combined with your Flash/Flex application or website. First is determining what you want tracked and how you want to use the statistics, the second is creating a Google Analytics account and setting up the proper filters etc.., the third is setting up the code in Flash and Javascript.

This is part 1 of a 5 part series on how to accomplish each of these areas.

Stay tuned for
Part 2 – “What Flash events should & shouldn’t be tracked with Google Analytics?” coming soon.

As always Happy Flashing.

AS3 Quicktip – Reversing a String With one Line of Code

ActionScipt 3 Quick Tip of the Day: How to reverse a string with one line of code.

I had the thought the other day – Is it possible to reverse a string in Flash/Flex with only one line of ActionScript Code?

I determined that it was. And here is the result of my ActionScript conjuring.

var myString:String = “ActionSript 3”;
trace(myString.split(“”).reverse().join(“”));
//Output – 3 tpirSnoitcA

Wondering what this is actually doing? Here is the explanation:

split(“”)

split() takes any string and separates it it based on the value that you pass in the parenthesis. This value is called the delimiter. For example, if I had a string “1!2!3” and split that string using an exclamation mark as the delimiter then I would have an array that includes the elements ["1","2","3"]. If I used “2” as the delimiter then the array would look like this ["1!","!3"]. Because I am not using a delimiter, just empty quotes, the string is split on each character. split() and split("") are not the same. split() without empty quotes will split on nothing and you will get an array with only one element which is the entire word.

reverse()

reverse() is a method that will take an array and and reverse the order. An array like this var myArray:Array = ["a","b","c"] will trace out as c,b,a if you use the following code trace(myArray.reverse());

join(“”);

join() will combine the elements from an array and create a string. The parameter that you pass it is called a separator and will be used to separate all the elements within the string. I use the empty string again in my code so that there will be no separation between the letters of the word. Without putting in the empty quotes you will get the result of 3, ,t,p,i,r,S,n,o,i,t,c,A with a comma separating each character including the space.

So in essence apply functions to the result of the previous function all in one line.  I take a string and split each letter into an array element, reverse that array and then join all of the separate elements back into a single word.

And that is your ActionScript 3 quicktip of the day.

As Always Happy Flashing

Flex / Flash CS3 Error #3553

Warning: 3553: Function value used where type void was expected. Possibly the parentheses () are missing after this function reference.

Description:
This is one of the best descriptions that I have seen for a Flash Error. This Flex/Flash Error is actually just a Flex/ Flash Warning. This error/warning means exactly what it says. You just forgot the parentheses () when you tried to make a method call.

Fix:
Add the Parenthesis

Bad Code:

var myTime:Timer = new Timer(1000, 3);
myTime.start;

or

var myDate:Date = new Date();
myDate.getDate;

Good Code:

var myTime:Timer = new Timer(1000, 3);
myTime.start();

or

var myDate:Date = new Date();
myDate.getDate();

As always Happy Flashing

Flash CS3 / Flex 2 AS3 Error #1116

ActionScript Error #1116: A user-defined namespace attribute can only be used at the top level of a class definition.

Description:
This ActionScript error will pop-up when a namespace is declared anywhere besides the class definition. What is a class definition you ask? It is simply the code that says names the class – something like ‘public class MyClass’

After the class is defined you are allowed to create custom(or ‘user-defined’) namespace on that level. Anywhere else in the code is not legal. This ActionScript Error is closely related to the Flash/Flex error #1114.
This AS3 error may also just be a typo. you may have typed something like ‘publi class’ rather than ‘public class’ or ‘prvate function’ rather than ‘private function’

Fix:
Either fix the misspelling in your code or place the ‘user-defined namespace’ inside the class definition. The second code example shows a namespace to separate cars and animals. Notice how the bad example nested the ‘user-defined namespace’ inside the constructor function.

Bad Code 1:

package com.cjm.somepackage
{
publi
class MyClass {
publi
function MyClass() {}
}
}

Good Code 1:

package com.cjm.somepackage
{
public
class MyClass {
public
function MyClass() {}
}
}

Bad Code 2:

package
{
public class MyClass
{
public namespace Cars;
public namespace Animals;public function MyClass() {
Animals var Jaguar:String = “A large cat chiefly of South America”;
Cars var jaguar:String = “A large car chiefly driven in North America”;
}

Cars function run():void {
trace(“At $30/mile”);
}

Animals function run():void {
trace(“On four legs”);
}
}
}

Good Code 2:

package
{
public class MyClass
{
public namespace Cars;
public namespace Animals;

Animals var Jaguar:String = “A large cat chiefly of South America”;
Cars var jaguar:String = “A large car chiefly driven in North America”;public function MyClass() {
}

Cars function run():void {
trace(“At $30/mile”);
}

Animals function run():void {
trace(“On four legs”);
}
}
}

Adobe has a great explanation of how to use namespaces as well as Collin Moock in Essential ActionScript 3 in Chapter 17

As always Happy Flashing