ActionScript 3 Error #1120: Access of undefined property myButton_btn.
Description:
ActionScript error #1120 means that an object “property” within Flash or Flex is not defined. But this doesn’t really help you fix it. One main reason for this AS3 Error is that you haven’t given the MovieClip or Button an instance name when you placed it on the stage in Flash. Another reason is that the reference is not correct.
AS3 Error 1120 –Fix1:
Give your instances a proper instance name.
Bad Example:
Good Example:
ActionScript 3 Error #1120: Access of undefined property myBatton_btn.
AS3 Error 1120 –Fix2:
Check that your reference is the proper instance name.
Bad Code:
myBatton_btn.addEventListener(MouseEvent.CLICK, someFunction);
Good Code:
myButton_btn.addEventListener(MouseEvent.CLICK, someFunction);
ActionScript 3 Error #1120: Access of undefined property ftouchBeginHandler.
AS3 Error 1120 – Fix3:
Make sure that you are calling the function with the correct name.
Bad Code:
square.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler);
function fl_TouchBeginHandler(event:TouchEvent):void
{
//Drag something
}
Good Code:
square.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler);
function touchBeginHandler(event:TouchEvent):void
{
//Drag something
}
This should help you fix Flash AS3 Error #1120.
As Always, Happy Flashing
Curtis J Morley
Hi,
can anybody help me with error 1120? I have named the instance correctly. there seems to be no problem with names as far as i know. the structure is like this, I have four buttons on the main page -home, portfolio, features and contact. all these four buttons work. but the complication is that i have sub galleries inside the features button. the sub gallery buttons dont work. when i test it without the codes for the sub gallery, i have no error. but when tested with the codes for the sub gallery i get the 1120 error. it says i’m calling for the undefined property. my layers on the timeline are labelled just the way for the main page. and my actionscript is on the first frame on the timeline.
the actionscript code goes like this.
stop ();
home.addEventListener (MouseEvent.CLICK, clickSection) ;
portfolio.addEventListener (MouseEvent.CLICK, clickSection) ;
features.addEventListener (MouseEvent.CLICK, clickSection) ;
contact.addEventListener (MouseEvent.CLICK, clickSection) ;
function clickSection (evtObj:MouseEvent) : void{
gotoAndStop (evtObj.target.name);
}
So far this works fine. but then i add the code for the sub gallery which is labeled on the timeline as stilllife. and it matches the instance name.
“stilllife.addEventListener (MouseEvent.CLICK, clickSection) ; “with this code in the actionscript, it shows the error. can anyone help?
That last entry should have read “new to AS3”. I’m using Flash CS5.
Long-time programmer, new to CS3 (paradigm shatters)
I’m trying to put all my code in an outside .as file, and import it to a simple fla file.
FLA FILE FRAME 1
import flash.events.KeyboardEvent;
import flash.text.TextField;
import comm.LaserTypingDevelop;
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler);
I created a “comm” folder in my project’s root folder, and made the source path in publish settings the root folder for the project.
Here is the comm/LaserTypingDevelop.as file’s (edited) content:
package comm
{
public class LaserTyping extends movieClip
{
public var gCurrentLetter:String = “”;
public var gCurrentKey:String = “”;
public function keyDownHandler(e:KeyboardEvent):void
{ code for function}
public function keyDownHandler(e:KeyboardEvent):void
{ code for function}
}
}
I don’t get the 5001 error anymore, so I know it is finding the .as file, but it doesn’t seem to be seeing the class and functions.
Someone tell me what stupid thing I did (or didn’t do)?
Thanks
package
{
import flash.xml.*;
import flash.events.*;
import flash.net.*;
import flash.display.*;
public class koder extends MovieClip
{
var trollXML: XML;
var myLoader: URLLoader = new URLLoader();
var theURL:URLRequest = new URLRequest(“trollXML.xml”);
myLoader.load(theURL);
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void
{
trollXML = new XML(e.target.data);
trace(trollXML.*);
}
}
}
This gives me the error #1120 on 4 places. myLoader 2 times, processXML and theURL.
I dont get whats wrong. The code is suppose to work.
If i put the code inside a .fla file instead of a .as file, it suddenly works.
Can ANYONE explain this blasphemy?
Gostaria quer me dissesse o que há com esse código, pois estou tentando criar uma galeria de imagem e não funciona. Ja tentei várias maneiras de fazer funcionar mais sempre aparece o seguinte erro:
Scene 1, Layer ‘action’, Frame 1, Line 17 1120: Access of undefined property evt.
Scene 1, Layer ‘action’, Frame 1, Line 17 1120: Access of undefined property evt.
ele me da esses dois erros, mais não consigo achá-los.
Pode me ajudar por favor.
Abaixo segue o código:
import flash.display.Loader;
import flash.net.URLRequest;
//Declaração de variáveis
var i:uint;
var carrega:Loader = new Loader();
for(i=1;i<=27;i++){
this["foto"+i].fotos.gotoAndStop(i);
this["foto"+i].addEventListener(MouseEvent.ROLL_OVER, over);
this["foto"+i].addEventListener(MouseEvent.ROLL_OUT, out);
this["foto"+i].addEventListener(MouseEvent.CLICK, clique);
}
function over(event:MouseEvent):void {
evt.currentTarget.gotoAndPlay("over");
}
function out(event:MouseEvent):void {
evt.currentTarget.gotoAndPlay("out");
}
function clique(event:MouseEvent):void {
var botao:String = evt.currentTarget.name.toString();
carrega.load(new URLRequest(botao+".jpg"))
mc_foto.addChild(carrega);
}
Lembrando que uso o Flash CS5.
hi again, never mind I fixed it. I was putting capitals on “loader” and it was messing up. It works now.
Great site by the way.
Hi Curtis, I’m having this error as well. Here’s the code:
import flash.events.MouseEvent;
this.home_btn.addEventListener(“click”, loadHome);
function loadHome(e:MouseEvent){
var my_loader:Loader = new Loader();
my_Loader.load(new URLRequest(“home.swf”));
addChild(my_Loader);
}
What I’m trying to do is, get “home.swf” to load on my main fla. file when I click on the home button (instance name home_btn). Not sure why it’s giving me problems, I can’t find any errors in the code.
Thanks
Try putting it in the constructor like wise, it works for me.
public class uControl extends MovieClip {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
public function uControl():void {//constructor
xmlLoader.load(new URLRequest(“bin/XMLFile.xml”));
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
}
private function loadXML(e:Event):void {
xmlData = new XML(e.target.data);
xmlData.ignoreWhite = true;
trace(xmlData);
try {
parseXML(xmlData);
} catch (e) {
trace(e);
}
}
SOLUTION:
Hi Eric, I think the solution is just a matter of labeling the frames that you are calling in your functions:
function gotoSlide01(e:MouseEvent):void{mcEnglish.gotoAndStop(’slide01′);}
Instead of numbering the frame where you want it to go, which would look like this, gotoAndStop(1) or what ever frame number you may want, you are saying that the frame is named as slide01. To label the frame you must locate the place where you label it, the frame label is located in the same place where the instance name appears but you have to click on the frame you want to jump to for it to label that frame, the name you gave it should appear on the time line next to the frame you labeled.
(hint: if you label the frame and you still cant see the label on the time line, just give it a few extra frames on the time line by pressing f5 a few frames over or just don’t worry, it doesn’t matter if you cant “really” see it, just make sure you did do something)
Also, I’ve never wrote a MouseEvent function as (e:MouseEvent),
I always use (event:
I created a set of buttons to perform a specific task. They all worked fine until I change the order in which the scenes play. When the scene that contains the buttons and script is first to play, everything works as it should. Once that particular scene is removed from the first position, I get the following message:
ArgumentError: Error #2109: Frame label onbishop not found in scene Home.
at flash.display::MovieClip/gotoAndStop()
at bethelRedo2_fla::MainTimeline/bishopClick()
HELP!!!
Curtis! Thank you much! It wasn’t EXACTLY what I was looking for, but it definitely threw me in the right direction. it gave me the idea to input event within the parenthesis, and it worked. So I had mem(event); and clickit(event); and they both worked great.
At Eric:
Try
function gotoSlide01(event:Event):void {
gotoAndStop(“slide01”);
}
OR
if you’re trying to get to the first frame
function gotoSlide01(event:Event):void {
gotoAndStop(1);
}
Thanks bro!!!
I found that my problem was that i hadn´t given the button the instance name in every single keyframe it appeared in….
Hope this helps anyone…
thanks curtis
thank you curtis
Hi everyone,
does anyone knows why this very simple class doesn’t work?
package ab
{
import flash.display.MovieClip;
public class Utility extends MovieClip
{
private var old:Number=10;
private const recent:Number=30;
public function Utility()
{
trace(“The class Second has been instantiated successfully”);
old+=10;
trace(old);
trace( recent );
trace(clip_mc);
clip_mc.x = stage.stageWidth/2;
clip_mc.y = stage.stageHeight/2;
}
}
}
.fla code
import ab.Utility;
var ut:Utility = new Utility();
error 1120
1120: Accesso alla proprietà non definita clip_mc.
(in english should be access to undefined property clip_mc)
I don’t know how to code. I found a forum post with a working AS3 example and just ran with it. http://www.actionscript.org/forums//showthread.php3?t=147984
I’m not able to get it to work for anything other than the first frame of the movie clip. I just mirrored the example but on a larger scale. I wanted to make a row of numbers 1-20 on the bottom that will go to the according slide inside the mc. This is my code:
function gotoSlide01(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide01’);}
function gotoSlide02(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide02’);}
function gotoSlide03(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide03’);}
function gotoSlide04(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide04’);}
function gotoSlide05(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide05’);}
function gotoSlide06(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide06’);}
function gotoSlide07(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide07’);}
function gotoSlide08(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide08’);}
function gotoSlide09(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide09’);}
function gotoSlide10(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide10’);}
function gotoSlide11(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide11’);}
function gotoSlide12(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide12’);}
function gotoSlide13(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide13’);}
function gotoSlide14(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide14’);}
function gotoSlide15(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide15’);}
function gotoSlide16(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide16’);}
function gotoSlide17(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide17’);}
function gotoSlide18(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide18’);}
function gotoSlide19(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide19’);}
function gotoSlide20(e:MouseEvent):void{mcEnglish.gotoAndStop(‘slide20’);}
btn01.addEventListener(MouseEvent.CLICK,gotoSlide01);
btn02.addEventListener(MouseEvent.CLICK,gotoSlide02);
btn03.addEventListener(MouseEvent.CLICK,gotoSlide03);
btn04.addEventListener(MouseEvent.CLICK,gotoSlide04);
btn05.addEventListener(MouseEvent.CLICK,gotoSlide05);
btn06.addEventListener(MouseEvent.CLICK,gotoSlide06);
btn07.addEventListener(MouseEvent.CLICK,gotoSlide07);
btn08.addEventListener(MouseEvent.CLICK,gotoSlide08);
btn09.addEventListener(MouseEvent.CLICK,gotoSlide09);
btn10.addEventListener(MouseEvent.CLICK,gotoSlide10);
btn11.addEventListener(MouseEvent.CLICK,gotoSlide11);
btn12.addEventListener(MouseEvent.CLICK,gotoSlide12);
btn13.addEventListener(MouseEvent.CLICK,gotoSlide13);
btn14.addEventListener(MouseEvent.CLICK,gotoSlide14);
btn15.addEventListener(MouseEvent.CLICK,gotoSlide15);
btn16.addEventListener(MouseEvent.CLICK,gotoSlide16);
btn17.addEventListener(MouseEvent.CLICK,gotoSlide17);
btn18.addEventListener(MouseEvent.CLICK,gotoSlide18);
btn19.addEventListener(MouseEvent.CLICK,gotoSlide19);
btn20.addEventListener(MouseEvent.CLICK,gotoSlide20);
Thanks.
-Eric
Pingback: 1120: Access of undefined property… « AS3 Errors
I’m trying to create a banner that loops over and over, but it’s not doing this. I have several movie clips embedded in a parent timeline. Each movie clips has a stop(); at the end respectively. In the last frame in the actions layer of the last movie clip called social_media_mc, I have this piece of code:
gotoAndPlay(1);
The intend for this code is so that the swf will loop back to the beginning and continue to loop over and over. Instead, it jumps to the previous movie clip in the timeline. What am I doing wrong?
Hi, I am in desperate need of help right now. Every time I test my movie my buttons do not work. I do not understand because no errors show up. Could you please tell me the possible reasons for this. I have had so much trouble with this projectt, I just want it to be over with!
Hello,
I am still receiving this error, despite making the changes listed above.
I am trying to link to an external page.
The code I am using is listed below:
button.addEventListener(MouseEvent.CLICK, callLink);
function callLink (event: MouseEvent) :void {
var url:String = (“http://www.google.com”);
var request:URLRequest = new URLRequest (url);
try { navigateToURL (request, “_blank”);
} catch (e:Error) {
trace (“Error occurred!”);
}
}
Any help would be much appreciated
Hey Curtis,
Great site, it’s a huge help. You should publish a book with all this.
Anyway, i found that you can also get this error by declaring a function static. For some reason your variables change scope and i don’t know how to access them anymore. Can you help or explain?
Bad code: (gives you error “1120: Access of undefined property myText”)
package
{
import flash.display.MovieClip;
import flash.text.TextField;
public class Main extends MovieClip
{
public var myText:TextField = new TextField();
public function Main()
{
addChild(myText);
myText.text = “Hello.”;
change_text();
}
public static function change_text() {
trace(“changing…”);
myText.text = “Hello there.”;
}
}
}
Good code (no errors):
package
{
import flash.display.MovieClip;
import flash.text.TextField;
public class Main extends MovieClip
{
public var myText:TextField = new TextField();
public function Main()
{
addChild(myText);
myText.text = “Hello.”;
change_text();
}
public function change_text() {
trace(“changing…”);
myText.text = “Hello there.”;
}
}
}
Weird, AS3 can be so frustrating. I need to call the function “change_text” from elsewhere so it needs to be static.
Thanks!
Hi Curtis!
I cant thank you in words. I wish you were around and I would have given you a big hug. thx 🙂 I gave my whole day to this and solved in now after 14 hours whithin a minute of reading your solution for it. now I am facing this error
the team
ArgumentError: Error #2109: Frame label the team not found in scene Scene 1.
at flash.display::MovieClip/gotoAndStop()
at CANVASWEB_fla::MainTimeline/clicktheteam()
the team
ArgumentError: Error #2109: Frame label the team not found in scene Scene 1.
pls help me out.
cheers !!!
Hi Curtis,
I making a game in Flash CS3. I keep getting this error. Here’s the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.at my_algebra_map_11_24_fla::MainTimeline/checkDoors()
and here is the function checkDoors:
function checkDoors(event:Event):void {
var doors:Array = new Array();
doors=[map.door1, map.door2, map.door3, map.door4];
if(character.hitTestObject(map.door1)) {
gotoAndStop(5);
}
if(character.hitTestObject(map.door2)) {
gotoAndStop(5);
}
}
I am lost as to how the code isn’t finding door1 and door2.
Any suggestions would be great!
thanks for the wonderful site,
Scott
HI,
I have often used your site to reference the MANY actionscript errors I am generating. Your information is very useful and I thank you.
I am an MFA student studying graphic design and this is my first foray into coding. My current project is to create a website using flash. My design is based on a vertical layout that the user will control using buttons or only the mouse. I want interactivity to occur at different stages of the site. yikes. I tend to want it all.
Anywho, my teacher doesn’t seem to know actionscript to the level you do and I was hoping maybe you could offer some insight on how to get this done. I’m down to the wire and the tutorials have been helpful, but I’m my pulling my hair out.
If you could help, that would be awesome.
Brooke
here is a site to reference what I am going for:
http://www.booneoakley.com/
Curtis,
New to AS3 and having same issue. Following code throws error 1120. I copied about_btn text and pasted into instance just to make sure all was exact.
about_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(“about.html”),”_self”);
}
Hi Curtis – I also get a 1120 Error when referencing slideshow (properly named instance of a movie clip that is present on the stage from frame 1) in this code:
jk1_btn.addEventListener(MouseEvent.CLICK, vid1);
function vid1(e:Event):void {
slideshow.visible = false;
vidPlayer.source = “jenvid.flv”;
}
jk2_btn.addEventListener(MouseEvent.CLICK, vid2);
function vid2(e:Event):void {
slideshow.visible = false;
vidPlayer.source = “SJH_Rendering1.flv”;
}
jk1_btn and jk2_btn are both movie clips behaving as buttons…and the error message appears when I test the movie, without the function(s) being called by pressing either jk1_btn or jk2_btn.
Do you know why this might be?
Thanks for any help – and I appreciate your site!
Eric
Rishi,
The button may be named correctly but it may also not be there when you are trying to call it. Triple check the name but then check at what point does it your script make a reference to the script? If the timing is wrong you can also get this error.
Thanks,
CJM
P.S. Is this in Flex or Flash?
Hi Curtis,
Thanks for all your work with Flash Error messages – I was getting this error, and I tried your fixes, but I am still getting it. Here’s the trouble code:
MyButton_btn.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
My button in my .fla is definitely called MyButton_btn in the Properties inspector. All my code is here: http://pastebin.com/f27e71dcf
Any ideas?
Thanks a lot
Rishi
Hey Stefan,
Just noticed that you are having a problem that I was having.
My flash buttons had an action applied which is exactly what you have. This code that Curtis suggested did end up working for me. You did check that the instance name for you button is “join_btn”?
All my buttons were separate flash movies placed in Dreamweaver.
That code will open in the same window since you have the target as “_self” the inverted commas are necessary.
Hope to be of help, Brigs
Hi,
Thanks for the great site! Its really been awesome being able to refer back here when all goes wrong!
I’m getting this error and I can, for the life of me, figure out why. The compiler says it objectContainer and readyTimer are undefined (this code is actually straight out of the “Using the external API” manual) but I don’t see how this can be:
var containerReady:Boolean = isContainerReady();
if (containerReady == true)
{
setupCallbacks();
}
else
{
var readyTimer:Timer = new Timer(100);
readyTimer.addEventListener(TimerEvent.TIMER, timerHandler);
readyTimer.start();
}
Any help would be greatly appreciated as I’m starting to think I’ve lost my mind.
I have been having the same problem as Briggs. I have seven buttons that I created in Flash (home, about us, events etc, etc) I have named each instance (both button and and movie). Yet every time I try to link to another page in my site the button does not work at all. I would also like the pages to open in the same window and not launch another browser window or tab.
join_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(”eventsTest.html”),”_self”);
}
crap, sry that previous post applied to error #1046
hey curtis, i was just telling you that there is another reason that this error will appear. If you name your variable the same thing that the symbol is named then you will get this error. here is an example:
Good Code:
var goButton:playButton = new playButton();
goButton.x = 100
goButton.y = 75
addChild(goButton);
Bad Code:
var playButton:playButton = new playButton();
playButton.x = 100
playButton.y = 75
addChild(playButton);
hope this helps someone! 🙂
I keep getting this error when I try to load an XML file into Flash (and I’m extremely new with flash, so I would not be the least bit surprised if it’s a stupid error, although I have checked what you went over and it’s all correct as far as I can tell).
Here is my code:
playlist = new XML();
playlist.ignoreWhite=true;
playlist.onload = function (success) {
if(success) {
_global.songname = [];
_global.songfile = [];
for (var i=0; i0) {
delete this.onEnterFrame;
this._parent.display_txt.text=name;
} else {
this._parent.display_txt.text=”loading…”
}
}
}
playlist.load(“playlist.xml”);
Any help would be greatly appreciated, friend.
Thanks,
Joe
hi, Curtis
i have a bunch of buttons nested inside a movie clip inside a custom scroll bar. i i want to be able to scroll through all those buttons and cue up different animations on the main stage. i keep getting the 1120 error. im not sure how to fix this problem
function onP001Click(evt:MouseEvent):void
{
trace(“ye”);
}
p001_btn.addEventListener(MouseEvent.CLICK, onP001Click);
**my p001_btn is located inside a mc named text_mc – inside another MC named lurker_mc
please help me.
thanks,
andy
Keith,
You’re welcome. Glad I could help. It is always the little things that get overlooked.
Thanks,
Curtis J. Morley
Thanks Curtis
I was pulling out what little hair I do have left!
I cannot believe I forgot to name instance!
Much appreciated
Keith
Hi Curtis,
Thanks for your quick reply much appreciated. Unfortunately I haven’t quite achieved what I hoped.
I’ll try and explain myself better. I’ve been testing my pages in Firefox, Opera and Safari and Safari opens every html page in a new browser window while Firefox uses tabs in one window.
What I was hoping to do is is avoid tabs and have only one browser window for all html page to appear in? Have I created a problem by using my own flash buttons to link to Dreaweaver html pages?
Cheers, Brigs
Brigs,
I believe you when you say that you have the button named correctly. In this case the error is coming from the argument _self. As written, the code is expecting a variable named _self instead of the string “_self” just add the quotes and you will be fine.
navigateToURL(new URLRequest(“about.html”),”_self”);
Thanks,
Curtis J. Morley
Hi There, great site, really straight forward to use. I’m not sure if you can help me but I have this error 1120 and my code looks like this:
about_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(“about.html”),_self);
}
I promise you that I have named my instance properly but I am a novice. What I am trying to achieve is flash buttons (navigation) that link to html pages but open in one browser window. Do you know where I’ve gone wrong?
Cheers, Brigs
This still did not work for me Curtis. I have “FilmsBtn” in my instance name but it still says 1120: Access of undefined property FilmsBtn.
The code I am using is below. I am VERY new at this. Thanks.
stop();
FilmsBtn.addEventListener(MouseEvent.CLICK, FilmsPge);
function FilmsPge(event:MouseEvent):void {
gotoAndStop(61);
}
Adam, Dalton,
I am really happy that I can help. Thanks for the kind words.
Curtis J. Morley
your site works better then advil..for my actionsript headaches
Thanks! That was exactly what I was looking for!
A.