10.07.12

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

Posted in Adobe, Error, Error, errors, Flash, Flash CS5.5, Flash CS6, Flex, quicktip at 5:46 am by Curtis J. Morley

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

03.18.11

Posted in Error, Error, errors, Flash, Flash 10, Flash CS5.5, Flex at 6:14 am by Curtis J. Morley

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