App used to work with AIR 3.2 or 3.4, doesn’t work with AIR 3.5 or 3.6

AIR 3.5 and 3.6 SDK for mobile require TLF Text to be merged into code.

Because I just spent the last full day dealing with this issue (without finding an answer on any forum) I thought I would share this so that you don’t have to bang your head against the wall. You probably found this page because your mobile project worked in AIR 3.2 or AIR 3.4 but when you try to publish your iPhone app or Android app using AIR 3.5 or AIR 3.6 SDK it  breaks.

This is the full error that I was getting when trying to publish from Flash CS6 using AIR 3.6:

Warning: Ignoring ‘secure’ attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml. The ‘secure’ attribute is only permitted in HTTPS and socket policy files. See http://www.adobe.com/go/strict_policy_files for details.

TypeError: Error #1009: Cannot access a property or method of a null object reference. at startMeUp/firstRunAnim()[/Users/speedclimb/Documents/cjm/Flash/Mobile/MobileDev/STARTME/startMeUp.as:229] at startMeUp()[/Users/speedclimb/Documents/cjm/Flash/Mobile/MobileDev/STARTME/startMeUp.as:210]

Neither of these AS3 Warnings/ Errors make sense nor have any info to point you to a resolution. Don’t try and troubleshoot AS3 Error 1009 The problem is that Apple now requires that all of this is embedded. Adobe complied with the changes from Apple and because of this when creating a mobile app using AIR 3.5 SDK or AIR 3.6 SDK with TLF Text you must have the .swc “Merged into code”.

Solution:

In order to compile with AIR 3.5 or 3.6 SDK you have to do one of two things. You can change all of your TLF Text into “Classic” text. This works but is not ideal because then you lose all of the great formatting features of TLF Text. The better solution is that you change the “Default Linkage” in your ActionScript settings to “Merged into code”. Sounds complicated but it’s not. Go to File >> ActionScript Settings, when the dialog window pops up make sure you are on the “Library Path” tab and then change the drop down from “Runtime Shared Library” to “Merged into code”. Below is a screenshot showing how to solve this AIR 3.5+ SDK compiler issue. The important areas are highlighted in red.

Change the Default linkage from "Runtime shared library" to "Merged into code"

Change the Default linkage from “Runtime shared library (RSL)” to “Merged into code”

I hope this saves you 16 hours of brain damage trying to compile your code using AIR 3.5 or AIR 3.6 SDK.

As always Happy Flashing (for mobile)

Curtis J. Morley

 

Flex / Flash TypeError: Error #1006: value is not a function.

ActionScript Error #1006: 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 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(“For 100,00 miles”);
}

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

Related AS3 Error:
Flex / Flash Error #1006 addEventlistener is not a function

As always Happy Flashing

ActionScript Error 1050: Cannot assign to a non-reference value.

ActionScript Error 1050 Description:
This Error is rather simple and you will find the solution to AS3 Error #1050 quick and easy. This Flash/Flex error occurs because you have tried (unintentionally I’m sure) to assign something that cannot be referenced later to another value. In other words you could have tried to assign a string in a trace statement to a value. Once the trace statement occurs that value is obliterated and therefore can never be referenced again. I’m sure that made a lot of sense… if not see the examples below. 🙂

Flex / Flash Error #1050 Fix:
Move the equal sign  ( = ) inside of the quotes.

Bad Code 1:

var word:String = “Wrong place for equal sign”;
trace(“AS3 Error 1050” =+ word);

Good Code 1:

var word:String = “Wrong place for equal sign”;
trace(“AS3 Error 1050 = “+ word);

Related Errors:

Flash ActionScript Error 1067 – Implicit coercion of a value of type void to an unrelated type Function. (AS3 Error 1067 is when you try to assign a String to a Number etc…) The above code will give you Flex error 1067 also.

This should help you resolve Flex / Flash Error #1050

Thanks and as always Happy Flashing

Curtis J. Morley

AS3 Error #1126: Function does not have a body.

ActionScript Error 1126: Function does not have a body.

ActionScript Error 1126 Description:

I got this error from one of my UVU students code.  And as promised in honor of her I am thusly naming AS3 Error 1126 the Erin Johnson Error.  This error is given, in this case, because a semicolon is used instead of a colon after the parenthesis.  A semicolon in the ActionScript language is equivalent to a period in the English Language which means that if Flash sees the semicolon it says to the compiler finish this line of code and move on. The colon on hte other hand is used to say what Type something is or in the examples below what “Type” of data will be returned when the function is called. In the example below we don’t want to return a type so we use :void (notice the colon). This should help solve AS3 Error 1126.

 

Flex / Flash Error #1126 Fix:
Replace the semicolon with a colon.

Bad Code 1:

function someFunc(event:MouseEvent);void
{
doSomething();
}

Good Code 1:

function someFunc(event:MouseEvent):void
{
doSomething();
}

Related Errors:

ActionScript Error 1084: Syntax error: expecting colon before leftparen. This error is a psuedo error in this case because once AS3 Error 1126 is reslved this error will also disappear.

This should help you resolve Flex / Flash Error #1126

Thanks and as always Happy Flashing

Curtis J. Morley

New Years Resolutions

Every year I am an avid reoslution maker and keeper.  I love to set golas and achieve them.  It all started in High School when I made a resolution with my best friend and cousin Vaughn Jensen to drink no soda for the entire year.  That was the first time that I set (and kept) a new years resolution.

I have many resolutions but I won’t list them all here.  The ones I will list relate to this blog and to my life as Flash professional.

So here are my New Years Resolutions in no particular order:

  • Post every ActionScript Error that Flash/Fex will ever produce.
  • Speak on Flash/ Flex/ ActionScript at 3 conferences this year (at least 1 major)
  • Reply to all valid blog comments within 24 hours.
  • Post a Flash tutorial at least once a month (12+ total).
  • Organize all posts into the “Grand Poobah” list of all AS3 errors.
  • Create an AIR app that contains all the errors from my blog.
  • Get my training published on RMI and Lynda.
  • Win one major award for a Flash project that I complete.
  • Get ACE re-certified in Flash CS4, Flash Lite and Flex
  • Become an ACI
  • And finally no carbonation for 2009 (cold duck excluded)

And that is the list.  Check back Jan 1st 2010 and see how I did.

Thanks and Happy Flashing,

Curtis J. Morley

ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184 Description:
This error is quite simple.  It just says that you have the wrong type of data in your parameter initializer.  Or in other words you tried to assign a string where you typed the parameter as a uint.

Flex / Flash Error #1184 Fix:
Match the parameter type to the proper data type.

Bad Code 1:

bob(someValue:uint = “Happy”)
{
trace(someValue);//error 1184
}

Good Code 1:

bob(someValue:uint = 5)
{
trace(someValue);//output 5
}

Related Errors:

AS3 Error 1047

This should help you resolve Flex / Flash Error #1184

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.ActionScript Error 1047

Description:
Let’s break down ActionScript Error 1047 into it’s various parts.

  1. Parameter = The variable inside the parenthesis of a function
  2. Initializer = An initial value set on the parameter inside the parenthesis
  3. Compile-time Constant = Something Flash knows the value of without evaluating

So long story short – you are trying to assign a value to a parameter that has to be evaluated.  Still don’t know what I mean?  Check the code examples.

This is actually a really great feature of AS3.  Say for example you have an event listener that calls a function.  You also want to call this same function without the event. Unless you pass a value in you will get AS3 Error 1136.  AS3 allows you to set the Event parameter to null and therefore accept a call to that function without passing in a parameter.  function myUtilFunc( e:Event = null);

You can initialize and function with any Compile time constant for example a string like “Happy”, a constant like null or an int like 5 but you can not throw in anything that needs to be evaluated like a variable, math operation, an in-line array like [a,b,c] or date.

Flex / Flash Error #1047 Fix:
Remove any variable data and use only constants in the initializer such as Strings, Numbers, Null, etc…

Bad Code:

var init:String = “Happy”
function bob(someValue:String = init){
trace(someValue);
}

Good Code:

function bob(someValue:String = “Happy”){
trace(someValue);
}

or

function multiFunction(e:Event = null){
//doSomething;
}

Related Errors:

AS3 Error 1184

This should help you resolve Flex / Flash Error #1047

Thanks and as always Happy Flashing

Curtis J. Morley

Flex / Flash Compiler Error #1023: Incompatible override.

AS3 Compiler Error #1023: Incompatible override.

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like the beautiful description of AS3 Warning 1090

It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an “Incompatible override”.   The first example below demonstrates this behavior. Example 1 will also give AS3 Error 1021 every time.

The second example is when an “Incompatible override” really is the reason.  Method signatures have to match or you will get this error.  Basically it means that you have not matched everything up properly from the method/Class that you are overriding.  So if you are overriding something that accepts events and you forget to put in events you will get this error.  If you give it a different Type you will get this error. Etc…

Adobe gives a good explanation of my second example.  They say:

“A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.”

Flex / Flash Error #1023 Fix:

Make sure that you do not have duplicate names with an object and a function

or

Match the Method Signature of the soon to be overridden class.

Bad Code 1:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 1:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Bad Code 2:

override protected function draw(event:Event = null):void

Good Code 2:

override protected function draw(event:Event):void

Related Errors:

AS3 Error 3596
AS3 Error 1021
AS3 Error 1023 (Different error same number)

This should help you resolve Flex / Flash Warning #1023

Thanks and as always Happy Flashing

Curtis J. Morley

AS3 Compiler Error# 1021: Duplicate function definition.

AS3 Compiler Error# 1021: Duplicate function definition..

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like AS3 Warning 1090 It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an incompatible override.  Sometimes it realy does mean that you have an override that is incompatible but many times it just means that you have a function that is named the same as

Flex / Flash Error #1021 Fix:

Do exactly what the message says use an event listener instead of the onRelease event that was common in AS2.

Bad Code 1:

function bob () {
}

function bob () {
}

Good Code 1:

function bob () {
}

function jim () {
}

Bad Code 2:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 2:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Related Errors:

AS3 Error 3596
AS3
Compiler Error 1023
AS3 Error 1023 (Different error same number.  This one has nothing to do with error 1021)

This should help you resolve Flex / Flash Warning #1021

Thanks and as always Happy Flashing

Curtis J. Morley