Flash CS3 / Flex 2 AS3 Error #1078

Error #1078: Label must be a simple identifier.

Description:
The main reason you will get this ActionScript error comes because of mistyping a colon. You can get AS3 Error 1078 by putting a a colon at the end of a line instead of a semicolon. You can get it by trying to ‘Type’ an object without the ‘var’ keyword, and my personal favorite – If you are in Flash writing a Class and hit the quick keys esc >> t >> r to get a trace(); statement you will get trace():void; instead.

Fix 1:
This error can be resolved by correctly typing a semicolon.

Bad Code1

myText.border = false:

Good Code1 :

myText.border = false;

Fix 2:
This can be resolved by using the keyword var. (The bad code example here is really bad code)

Bad Code 2:

this.box:MovieClip = new MovieClip();

Good Code 2:

var box:MovieClip = new MovieClip();

Fix 3:
Delete the silly extra stuff that Flash puts in there for you. If you have the bad code as shown below you will most likely get another error like 1083. Just fix the first and the second will also be resolved.

Bad Code 3:

trace():void

Good Code 3:

trace();

And that is how you solve ActionScript Error #1078

Happy Flashing

Flash CS3 / Flex 2 AS3 Error #1119

Error #1119:
Access of possibly undefined property buttonText through a reference with static type flash.display:SimpleButton

or

Error #1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObject.

Description:
This means that you are trying to change dynamic text nested inside a button. This is a simple fix. Just change the button to a movieClip.

Another more prevalent reason that you will get ActionScript Error #1119 is because the the new way Flash/flex handles parent objects has changed. In AS2 parent.myVar would work just fine. In ActionScript3 the compiler doesn’t know what the parent is unless specifically typed or casted instead it chalks everything up to DisplayObjectContainer. This means that it doesn’t know that the ‘parent’ is a MovieClip. The reason for this is because you can now change the object from one displayObject to another easily at compile time. You could change the parent object from a MovieClip to SimpleButton at compile time.

You also want to check your syntax to make sure that you have dynamically targeted an object correctly. For example, if you are trying to use AS3 to target a series of movieClips dynamically and each of the names start with ‘card’ and have a sequential value as well then you must use the code in Fix3 to prevent AS3 Error #1119. Fix #4 is similar to Fix 3 but Fix 4 is specific to the DisplayObject.
Fix 1:
You need to cast the parent as the type that you want or you need.

myTextField.text = MovieClip(this.parent).someVar
or
myTextField.text = (this.parent as MovieClip).someVar

One of the best explanations of casting for this error is written up by Josh Tynjala go visit his blog called “Why doesn’t the ‘parent’ property work the same in ActionScript 3”

.

Fix 2:
Rather than looking outside the movie for the variable you can push the variable into the child movieClip and then access it within itself. For example if I have a movieClip named bob that is inside of a clip named joe then I would have Joe push the variable into bob and bob would access it within himself and not need to ask his parent for the variable because he already has it.

From Joe

bob.someVar = “This is the variable”;

From Bob

myTextField.text = someVar;

Fix 3:

Bad Code:

this.card[i].id = “something”;

Good Code:

this[“card”+i].id = “something;

Fix 4:
The good code below uses a direct reference to the object that holds the property someProperty. Whereas the Bad Code example is trying to access the property through a reference through the displayObject. Because the displayObject doesn’t have the property it cannot change it.

Bad Code:

this.getChildByName(‘card’+_setClicksCounter).someProperty = true;

Good Code:

this[“card”+_setClicksCounter].someProperty = true;

Fix 5:
1119: Access of possibly undefined property nestedMovieClip through a reference with static type Class.
This is easy to fix. It just means that you are trying to access a nested object within the class statement rather than from within the Class. The problem is that the keyword “this” in the first example doesn’t references the Class itself rather the object the Class is linked to.

Bad Code:

package com.cjm.sound
{
public class SoundControl extends MovieClip
{
var _progwidth:uint = this.progBar.width;
public function SoundControl (url=null):void
{
doSomething();
}}}

Good Code:

package com.cjm.sound
{
import flash.display.MovieClip;
public class SoundControl extends MovieClip
{
var _progwidth:uint;
public function SoundControl ():void
{
_progwidth = this.progBar.width;
}}}

Related Errors:
Flash / Flex Error 1056 – You will get AS3 Error 1056 instead of 1119 if you don’t properly type your object before referencing a property on it. For example var s:Sprite = new Sprite(); s._x = 10; will give error 1119 but var s = new Sprite(); s._x = 10; will give Error 1056.

As always – Happy Flashing

Flash CS3 / Flex 2 AS3 Error#1168

Error #1168: Illegal assignment to function setTextFormat.

This is another easy one. It just means that you assign the format within parenthesis rather than after the “=” sign.
Bad Code:

var myText:TextField = new TextField();
var myFrmt:TextFormat = new TextFormat();
myFrmt.color = 0x336699;
myFrmt.font = “Franklin Gothic Book”;
myText.text = “Flash is fun – Happy Flashing Everyone”;
myText.border =true;
myText.wordWrap = true;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.setTextFormat = myFrmt;
this.addChild(myText);

Good Code:

var myText:TextField = new TextField();
var myFrmt:TextFormat = new TextFormat();
myFrmt.color = 0x336699;
myFrmt.font = “Franklin Gothic Book”;
myText.text = “Flash is fun – Happy Flashing Everyone”;
myText.border =true;
myText.wordWrap = true;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.setTextFormat(myFrmt);
this.addChild(myText);

And this is how you resolve Error #1168: Illegal assignment to function setTextFormat.

Flash CS3 / Flex Error Messages – Error #1063:

ArgumentError: Error #1063: Argument count mismatch on com.cjm::DrawLines/::onEnterFrame(). Expected 0, got 1.

This is an easy one it means that you got an argument passed to your function yet you did not specify that one was coming. So you did this “function Bob ()” instead of “function Bob (myEvent:Event)” This error is common when dealing with Events.

Flash CS3 / Flex Error Messages #1010:

So that you don’t have to figure out all the cryptic error messages that are being thrown from Flash 9 and Flex I have decided to compile a list of error messages and what they mean in a practical sense.

TypeError: Error #1010: A term is undefined and has no properties.

What this error means is that you are trying to access a property of an object that isn’t there. This is very common when using Arrays. This error will also pop-up if you are trying to access a property of an Object that has not been assigned/created.
Bad Example 1:

for (var i:uint=0; i<=internalArray.length; i++) {
if (internalArray[i].length > 10){
trace(internalArray[i].length);
}
}

Good Example 1:

The above example will throw the error because you are trying to access 1 extra element on the end of your array. Just remove the final loop by removing the “=” sign in the comparison. Because Arrays are “0 based” i<=internalArray.length will take you beyond the last index of the array and try and evaluate for a value that is not there. For example var newArray:Array = [“Bob”, “Joe”, “Jim”]; has a length of 3 but Jim has an index of 2.

for (var i:uint=0; i<internalArray.length; i++) {
if (internalArray[i].length > 10){
trace(internalArray[i].length);
}
}

Bad Example 2:

for (var i:uint=0; i 10){
trace(internalArray[i].bob);
}
}

Good Example 2:

The above example will not work because the property bob has not been defined anywhere in the code. You can remedy this by removing the reference to “bob” or by declaring what the “bob” property for each item in the array.

for (var i:uint=0; i 10){
trace(internalArray[i]);
}
}

Bad Example 3:

This example tries to access a property that is created(instantiated) a few lines down.

for (var i:uint=0; i 10){
trace(internalArray[i]);
}
}

var internalArray:Array = [“bob”,”jim”,”joe”];

Good Example 3:

The order of operation is important because even though Flash/Flex does some “hoisting” you will still get errors if you don’t order things properly.

var internalArray:Array = [“bob”,”jim”,”joe”];

for (var i:uint=0; i
if (internalArray[i].length > 10){
trace(internalArray[i]);
}
}

As always – Happy Flashing

Flex2 Builder not installing on Vista

So for all you people that jumped on the Windows Vista bandwagon you may be experiencing difficulty running Flex2 Builder after you have installed it.

This is the error that I was getting:

!SESSION 2007-05-11 20:10:31.205 ———————————————–
eclipse.buildId=unknown
java.version=1.4.2_12
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.update.configurator 2007-05-11 20:10:31.696
!MESSAGE Cannot backup current configuration

!ENTRY org.eclipse.update.configurator 2007-05-11 20:10:31.727
!MESSAGE Could not rename configuration temp file

!ENTRY org.eclipse.osgi 2007-05-11 20:10:32.644
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: no swt-win32-3139 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:123)
at org.eclipse.swt.internal.win32.OS.(OS.java:18)
at org.eclipse.swt.widgets.Display.(Display.java:125)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:381)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:155)
at com.adobe.flexbuilder.standalone.FlexBuilderApplication.run(FlexBuilderApplication.java:45)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)

!ENTRY org.eclipse.osgi 2007-05-11 20:10:32.647
!MESSAGE Bundle
update@plugins/com.adobe.flexbuilder.debug.e32_2.0.155577/ [70] was not resolved.
!SUBENTRY 1 org.eclipse.osgi 2007-05-11 20:10:32.647
!MESSAGE Missing required bundle org.eclipse.debug.ui_[3.2.0,99.0.0).

And this is how to resolve it:

I experienced the same issue when I tried to install Flex on a new Vista system. Here’s how I corrected it:

1) Navigate to C:\Program Files\Adobe\Flex Builder 2\plugins

2) Look for the file “org.eclipse.swt.win32.win32.x86_3.1.2.jar”. You will need to open this in a file compression program such as WinAce, WinRar or WinZip. If you don’t have such a program you can try:

2a) Copy (make sure you COPY, not MOVE) the file to another location, such as your desktop.

2b) Rename the file with a “.zip” extension (i.e. change “.jar” to “.zip”). NOTE: You will not see the file extension if your system is configured to hide extensions. In this case, open a Windows Explorer window (“My Computer”, etc.) and press the “Alt” key. A menu bar will appear. Select “Tools -> Folder Options”. Select the “View” tab, and look for “Hide extensions for known file types”. Uncheck the box, then click OK.

2c) You should now be able to right-click the file and use Vista’s built-in .zip extraction to extract the contents to a folder.

3) Within the org.eclipse.swt.win32.win32.x86_3.1.2.jar file is a file called “swt-win32-3139.dll”. Copy this file to C:\Windows\System32\ (You will be asked for a confirmation when you do this).

Once that is done, Flex should run correctly. You can now delete the copy of the .jar file that you made, as well as the folder created by Vista’s .zip extraction (if applicable).

Hope this helps!

The above excerpt was taken from the following website at Adobe

http://www.adobe.com/cfusion/webforums/forum/rss.cfm?forumid=60&catid=539

As always Happy Flashing/Flexing