03.17.08

AS3 Error 1120

Posted in Error, Error, Flash, Flex, errors at 6:25 am by Curtis J. Morley

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.

Fix1:
Give your instance the proper instance name

Bad Example:

Flash properties dialog without an instance name Flash properties dialog without an instance name

Good Example:

Flash Properties Dialog with Instance Name Flash properties dialog with MovieClip instance name

Fix2:
Check that your reference is the proper instance name
Bad Code:

myButon_btn.addEventListener(MouseEvent.CLICK, someFunction);

Good Code:

myButton_btn.addEventListener(MouseEvent.CLICK, someFunction);

This should help you fix Flash Error #1120.

As Always, Happy Flashing

Curtis J Morley

35 Comments »

  1. Adam said,

    July 8, 2008 at 3:56 pm

    Thanks! That was exactly what I was looking for!

    A.

  2. dalton said,

    July 9, 2008 at 6:58 am

    your site works better then advil..for my actionsript headaches

  3. Curtis J. Morley said,

    July 9, 2008 at 7:02 am

    Adam, Dalton,

    I am really happy that I can help. Thanks for the kind words.

    Curtis J. Morley

  4. Scott said,

    August 5, 2008 at 3:07 pm

    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);
    }

  5. Brigs said,

    August 17, 2008 at 11:57 pm

    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

  6. Curtis J. Morley said,

    August 18, 2008 at 4:14 pm

    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

  7. Brigs said,

    August 19, 2008 at 8:21 pm

    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

  8. Keith said,

    August 20, 2008 at 7:32 am

    Thanks Curtis

    I was pulling out what little hair I do have left!

    I cannot believe I forgot to name instance!

    Much appreciated

    Keith

  9. Curtis J. Morley said,

    August 20, 2008 at 12:09 pm

    Keith,

    You’re welcome. Glad I could help. It is always the little things that get overlooked.

    Thanks,
    Curtis J. Morley

  10. andy said,

    September 1, 2008 at 8:11 pm

    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

  11. Joe said,

    September 5, 2008 at 5:00 am

    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

  12. zach said,

    September 5, 2008 at 6:04 pm

    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! :)

  13. zach said,

    September 5, 2008 at 7:34 pm

    crap, sry that previous post applied to error #1046

  14. Stefan said,

    September 15, 2008 at 11:46 am

    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”);
    }

  15. Horst said,

    September 16, 2008 at 10:09 am

    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.

  16. Brigs said,

    September 17, 2008 at 12:23 am

    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

  17. Rishi said,

    November 13, 2008 at 5:56 pm

    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

  18. Curtis J. Morley said,

    November 14, 2008 at 1:11 pm

    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?

  19. Eric V. said,

    November 14, 2008 at 1:37 pm

    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

  20. Thomas Reichstetter said,

    November 27, 2008 at 4:37 pm

    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”);
    }

  21. Brooke Creef said,

    December 1, 2008 at 10:17 am

    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/

  22. Scott Guthrie said,

    December 11, 2008 at 9:52 pm

    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

  23. Dee said,

    February 1, 2009 at 3:13 pm

    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 !!!

  24. Chris said,

    February 28, 2009 at 1:23 pm

    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!

  25. srawr42 said,

    March 24, 2009 at 2:17 pm

    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

  26. Bonnie said,

    April 9, 2009 at 5:12 pm

    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!

  27. stephen said,

    May 8, 2009 at 9:46 am

    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?

  28. 1120: Access of undefined property… « AS3 Errors said,

    July 16, 2009 at 6:47 am

    [...] Curtis Morley’s Writeup [...]

  29. Eric said,

    July 20, 2009 at 11:38 am

    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

  30. Davide (Rome) said,

    July 22, 2009 at 4:28 am

    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)

  31. Joe said,

    July 27, 2009 at 6:48 pm

    thank you curtis

  32. Santiago said,

    November 30, 2009 at 8:07 pm

    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

  33. Danny said,

    December 16, 2009 at 11:33 am

    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);
    }

  34. Greg said,

    January 10, 2010 at 4:42 pm

    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!!!

  35. Mike said,

    February 4, 2010 at 5:53 am

    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:

Leave a Comment