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
Hi guys,
I am a complete noob at flash coding. basically all i am trying to do is import a movie into a rectangle movie clip called ContentHolder. This worked hundreds in AS2 except that the movie clip i am importing needed AS3 to behave correctly.
So here i am trying to recode th base swf in AS3. This is the code i have tried:
stop();
btnBio.addEventListener(
MouseEvent.MOUSE_UP,
function(evt:MouseEvent){
this.ContentHolder.loadMovie(“biographyClip.swf”);
}
);
Ofcourse i get Error #1010:
I can only assume it is the ContentHolder that is undefined.
I have given it an instance name – and dont know what else to do.
Can you help this green as a cucumber, new kid on the block please?
Kris,
I actually get Error # 1119: Access of possibly undefined property DisplayObject through a reference with static type flash.display:Sprite.
Here is the code as it should be
circle1.scaleY = 1.5;
circle1.scaleX = 1.5;
Here is what you had previously
circle1.DisplayObject.scaleY = 150;
circle1.DisplayObject.scaleX = 150;
Note that you do not need to reference the code through the “DisplayObject” and also that most properties now are using decimal for percentages. So you use 1.5 to size something up to 150%.
Hope this helps and Happy Flashing.
I have included all of the code below
// This code creates a drag-and-drop interaction using the mouse-following
// technique.
// circle and square are DisplayObjects (e.g. MovieClip or Sprite
// instances).
import flash.display.DisplayObject;
import flash.events.MouseEvent;
var offsetX:Number;
var offsetY:Number;
var draggedObject:DisplayObject;
var circle1:Sprite = new Sprite();
circle1.graphics.beginFill(0xFF0000);
circle1.graphics.drawCircle(40, 40, 40);
circle1.name = “circle1”;
addChild(circle1);
var circle2:Sprite = new Sprite();
circle2.graphics.beginFill(0x0000FF);
circle2.graphics.drawCircle(140, 40, 40);
circle2.name = “circle2”;
addChild(circle2);
var circle3:Sprite = new Sprite();
circle3.graphics.beginFill(0x0000FF);
circle3.graphics.drawCircle(140, 40, 40);
circle3.name = “circle3”;
addChild(circle3);
var square1:Sprite = new Sprite();
square1.graphics.beginFill(0xFFCC00);
square1.graphics.drawRect(0, 0, 40, 40);
addChild(square1);
// This function is called when the mouse button is pressed.
function startDragging(event:MouseEvent):void
{
// remember which object is being dragged
draggedObject = DisplayObject(event.target);
// Record the difference (offset) between where the cursor was when
// the mouse button was pressed and the x, y coordinate of the
// dragged object when the mouse button was pressed.
offsetX = event.stageX – draggedObject.x;
offsetY = event.stageY – draggedObject.y;
// move the selected object to the top of the display list
stage.addChild(draggedObject);
// Tell Flash Player to start listening for the mouseMove event.
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragObject);
}
// This function is called when the mouse button is released.
function stopDragging(event:MouseEvent):void
{
// Tell Flash Player to stop listening for the mouseMove event.
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragObject);
}
// This function is called every time the mouse moves,
// as long as the mouse button is pressed down.
function dragObject(event:MouseEvent):void
{
// Move the dragged object to the location of the cursor, maintaining
// the offset between the cursor’s location and the location
// of the dragged object.
draggedObject.x = event.stageX – offsetX;
draggedObject.y = event.stageY – offsetY;
circle1.scaleY = 1.5;
circle1.scaleX = 1.5;
// Instruct Flash Player to refresh the screen after this event.
event.updateAfterEvent();
}
circle1.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
circle1.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
circle2.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
circle2.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
square1.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
square1.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
Hi Curtis. After years of thinking I was fairly OK with Flash, I have just started using Flash CS3 and am baffled! I am trying to create a small game where you can drag and drop objects. I got the code below from Adobe and it works. However, when I try to add the code to scale the object to 150 when dragged, I am getting Error #1010. I haven’t set up an array so am unsure what to do next. I have left my code in the code below but have turned it into a multiline comment so you can see what I’ve done… Any help would be amazing.
// This code creates a drag-and-drop interaction using the mouse-following
// technique.
// circle and square are DisplayObjects (e.g. MovieClip or Sprite
// instances).
import flash.display.DisplayObject;
import flash.events.MouseEvent;
var offsetX:Number;
var offsetY:Number;
var draggedObject:DisplayObject;
// This function is called when the mouse button is pressed.
function startDragging(event:MouseEvent):void
{
// remember which object is being dragged
draggedObject = DisplayObject(event.target);
// Record the difference (offset) between where the cursor was when
// the mouse button was pressed and the x, y coordinate of the
// dragged object when the mouse button was pressed.
offsetX = event.stageX – draggedObject.x;
offsetY = event.stageY – draggedObject.y;
// move the selected object to the top of the display list
stage.addChild(draggedObject);
// Tell Flash Player to start listening for the mouseMove event.
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragObject);
}
// This function is called when the mouse button is released.
function stopDragging(event:MouseEvent):void
{
// Tell Flash Player to stop listening for the mouseMove event.
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragObject);
}
// This function is called every time the mouse moves,
// as long as the mouse button is pressed down.
function dragObject(event:MouseEvent):void
{
// Move the dragged object to the location of the cursor, maintaining
// the offset between the cursor’s location and the location
// of the dragged object.
draggedObject.x = event.stageX – offsetX;
draggedObject.y = event.stageY – offsetY;
/* circle1.DisplayObject.scaleY = 150;
circle1.DisplayObject.scaleX = 150;
*/
// Instruct Flash Player to refresh the screen after this event.
event.updateAfterEvent();
}
circle1.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
circle1.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
circle2.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
circle2.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
square1.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
square1.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
Will,
I would be happy to help.
Are you using AS3? If you would like to use AS3 this is the code:
stop();
button1.buttonText.text = “HOME”;
//This needs to be a movieClip or you will get the following error
//1119: Access of possibly undefined property buttonText through a reference with static type flash.display:SimpleButton.
function over(e:Event) {
//I am guessing that you want to target the main timeline
//Make sure this code is on the maintimeline or you have set this Class as your document class
this.gotoAndPlay(2);
}
function out(e:Event) {
this.gotoAndPlay(6);
}
button1.addEventListener(MouseEvent.MOUSE_OVER, over);
button1.addEventListener(MouseEvent.MOUSE_OUT, out);
If you are using AS2 here is the code that should work for you:
//This line needs to be applied to a movie clip to get it to work
//If you want to target a text field inside of an object it needs to be a movieClip
button1.buttonText.text = “HOME”;
function over() {
this.gotoAndPlay(2);
trace(“over”);
}
function out() {
this.gotoAndPlay(6);
trace(“out”);
}
//This is the syntax for targeting functions directly
button1.onRollOver = button1.onDragOver = over;
button1.onRollOut = button1.onDragOut = out;
I am getting this error i am still sorta new at the flash world…but here is my actionscript
button1.mouseover = over;
button1.mouseout = out;
button1.text.buttonText.text = “HOME”;
function over() {
this.gotoAndPlay(2);
}
function out() {
this.gotoAndPlay(6);
}
any help would be great
BTW this is for a menu for a website that i am putting togther for a company. There will be a total of 4 active buttons
Thank you, thank you, thank you. I was scratching my head over why I was constantly getting those 1010 errors with my array.