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
Pingback: as3 _parent | Born2Design
Thanks for this post, i found it really interesting and helpful, i wish i read this a week ago lol.
what may be the reason…i really need to get around it….help any is appreciated
i get this error as follows:
Severity and Description Path Resource Location Creation Time Id
1119: Access of possibly undefined property CustomerTypeID through a reference with static type Number. Best Quote/src/WebService webService.as line 59 1245240864810 5817
for the following code:
package WebService
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.*;
/* import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService; */
public class webService extends Sprite
{
public function webService()
{
super();
var ur:URLRequest=new URLRequest(“http://sreejith/bestquote/services/bestQuoteAdmin.asmx/getCustomerType”);
var ul:URLLoader=new URLLoader();
ul.dataFormat=URLLoaderDataFormat.TEXT;
ul.addEventListener(Event.COMPLETE,eventLoad);
try{
ul.load(ur);
}
catch (error:Error)
{
trace(“Unable to load URL: ” + error);
}
sendToGrid();
}
public function eventLoad(event:Event):void
{
//trace(event.result);
var recordArray:Array=new Array;
var z:XML;
var i:int;
var loader:URLLoader = URLLoader(event.target);
//trace(event.target);
var xml:String=loader.data;
z=XML(loader.data);
trace(“Customer details”);
for(i=0;i<2;i++)
{
trace(” Customer ID is “+z..CustomerTypeID[i]+” and Customer Type is “+z..TypeName[i]);
}
}
public function get(obj:Array=null):Array
{
obj=new Array;
obj.push(z..CustomerTypeID[0]) ;
trace(obj);
return obj;
}
/* var appXml = new DOMParser();
var xmlobject = appXml.parseFromString(event.target.data, “text/xml”);
air.trace(“Connection Status=”+Status);
var Status = GetXMLNodeValue( xmlobject, ‘Status’)
if (Status == 1)
{
Company_ID = parseInt(GetXMLNodeValue(xmlobject, ‘Company_Id’));
}
*/
public function sendToGrid():void
{
}
}
}
Pingback: Flash/ Flex Error « RIAdobe
Pingback: curtismorley.com » ReferenceError: Error #1069: Property addEvent not found on flash.utils.Timer and there is no default value.
Phillip,
Thanks, this is great and I will add this example to the ones above. Good luck at Flash Forward. I’m sure your presentation will be great.
Thanks,
Curtis J. Morley
Another “good” way to get this error to pop up:
draw a dynamic text field onstage…give it an instance name.
put text input on stage–with the same instance name.
publish, and enjoy the cryptic message
Great info. Thanks.
I’d like to add my problem and the solution that was found for it.
I’m setting up a swf that will display some balls on the screen. These balls will pulse in and out. When the user mouse over the ball it will grow and display some hidden text. The balls are then dragable. To add better functionality to the display i wanted to make sure that the ball only ballons out and contracts at the full extent of the balls size, otherwise the ball will start from the start of the label. So i set three labels in the ball MC, “waiting”, “active” and “out”. At the end of “active” label i put some code to change a string value (the string value is tested in the main time line):-
moveToOut = “out”;
which i set in the main time line –
moveToOut = “”;
I tried parent, parent.parent, root and this only to get the same error this article is about. The solution works as below
(root as MovieClip).moveToOut = “out”;
Now it’s great that this works, but i’m a bit confused as to why. Since my variable is a String. What is being changed here?
Pingback: curtismorley.com » Search Engine Optimization Example
Pingback: curtismorley.com » Added More Info to ActionScript Error #1119
jon,
Sorry you are so frustrated. I can sympathize. If your variable is a member variable, it should persist throughout any method within that class. Here is what I would suggest. I would look for something in the code that removes the variable or sets it to null. I would also throw in a trace statement that traces out variable and move it around until you find out where the variable is missing. Don’t forget to use your break points. They are awesome for debugging.
I would be happy to look at your code. Just post it here.
Thanks and Happy Flashing.
Curtis J. Morley
This is a rubbish error message that has no basis in reality.
My variable is declared as a class variable, in perfect scope.
I am using it in a timer event which increments the variable with no
problem. When I try and display it in the same function, it complains
that it is “possibly” undefined even though it has just modified it.
Wonder if Silverlight has these problems.
Pingback: Q4 « Programming Sustainability
Jens which fix are you talking about specifically. I believe that you are talking about Fix #1 for error 1119. This is a generic error and will be displayed in a number of scenarios. If you are getting this error it means that Flex, in your case, doesn’t recognize the property and it shows up as undefined. This means that it is either not there, not there yet (meaning that the order of operation hasn’t executed the property that you are trying to access), or you are incorrectly accessing the property. Let me know a few more details and I am sure that I can help you out.
Thanks,
Curtis J. Morley
It does not always mean that. I’m not doing anything with movies and I see this in Flex 2 when trying to compile. The scope of variables seems to be hard to make sense out of in Flex, declaring them does not always help anything.
Pingback: curtismorley.com » Blog Archive » Added new info to Error #1119