• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

1120: Access of undefined property error AS3

Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Hi! I've been working on an interactive character animation for a school project and have been having some issues with it. I'm very new to Animate and was originally working with an HTML5 canvas. I was having issuses with some of my animations and music not playing, so my professor suggested I convert it to an ActrionScript3 file. That fixed those issues, but presented many more as I have to recode all of my animation.

 

The animation is a basic dress up game where the player can press start, click on an area to reveal a piece of clothing, click on the clothing to put it on the character, and then click a button that restarts the animation. I've been working with simple timeline animation, calling frames and frame labels to jump around, however when using code snippets to re-code my buttons I got an error saying, "1120: Acess of undefined property clothesRVL." My animation was working fine before I added an action to clothesRVL, and I suspect it's not working because I called a frame label and not a frame. I appreciate any help I could get with this as this is my final project and I'd like to get this working by tonight! I'll paste my current AS3 code and original Javascript code below:

 

JS Code ---

 

Frame 1:

 

var _this = this;

_this.stop();

var _this = this;

_this.Button2.on('click', function(){

_this.gotoAndStop(242);

});

 

var _this = this;

_this.blanketBTN.on('click', function(){

_this.gotoAndStop(251);

});

 

var _this = this;

_this.shirtBTN.on('click', function(){

_this.gotoAndStop(253);

});

 

var _this = this;

_this.clothesBTN.on('click', function(){

_this.gotoAndPlay('clothesRVL');

});

 

var _this = this;

_this.pantsBTN.on('click', function(){

_this.gotoAndStop(263);

});

 

var _this = this;

_this.drawerBTN.on('click', function(){

_this.gotoAndStop('drawer open');

});

 

var _this = this;

_this.socksBTN.on('click', function(){

_this.gotoAndStop('Socks On');

});

 

var _this = this;

_this.curtainBTN.on('click', function(){

_this.gotoAndStop('shoesRVL');

});

 

var _this = this;

_this.shoesBTN.on('click', function(){

_this.gotoAndPlay('Shoes On');

});

 

Frame 266:

 

this.stop();

 

Frame 361:

 

//
//var _this = this;
//_this.endBTN.on('click', function(){
//_this.gotoAndStop(1);
//});

 

AS3 Code:

 

Frame 1:

 

Button2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(242);
}

blanketBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

{
gotoAndStop(251);
}

shirtBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

{
gotoAndStop(253);
}

 

clothesBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);

function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
gotoAndPlay(clothesRVL);
}

 

TOPICS
ActionScript , Code , Timeline

Views

231

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

I forgot to add that I looked through other forum posts on this error and tried the suggestion of turing off advanced layers but it didn't work. 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

file > publish settings > tick enable debugging > retest

 

what's the line of code triggering the error?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Hi! Thank you very much for responding. I tried your suggestion and I was still getting the same error. 😞 The error is on line 42, which has the code " gotoAndPlay(clothesRVL);"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

is clothesRVL defined?

 

or is it a frame label that you failed to put in quotes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

My coding skills are very limited, so I'm not 100% sure how to define clothesRVL. Based on working in the HTML5 document, I thought I could just call the frame label in the code because it already exists on the timeline. Changing line 42 to say "gotoAndPlay("clothesRVL");" instead did fix the error I was getting, but now my animation wont function past the start button switching to the next screen.

 

I just reformatted the rest of my code for frame 1 and I'm confused why my this is the case. To be more clear, the player is supposed to first be able to click on a blanket on a bed, which shows an animation of it moving back, revealing a shirt. The player can then click on the shirt and repeat the process for other areas in the room. This is probably a deeper issue with my code that requires looking at my timeline, but thank you for the help with that error!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

what???

 

that's not html5/canvas code. it's as3 code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Oh yeah, that's what I changed! I might've explained it wrong, but the whole section of code is now:

 

function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
gotoAndPlay("clothesRVL");
}

 

Like I said, following your suggestion to add quotes around clothesRVL solved the error, but I'm running into more issues with my code haha. I think I might go back to working in my HTML5 document and just omit the addition of music/SFX in it. Hopefully that makes sense. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

that's still as3.

 

is your app html5 or as3?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

The file I was trying to work with was as3! It was originally html5, but my music and SFX weren't working with that file type so I converted it to as3. Then, in the as3 file my timeline animations stopped working, which was part of what prompted that original 1120 error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

ok.

 

do you see any error messages?

 

if not, when do you see a problem? when that goto button is clicked?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Right now I'm noticing a problem right after the start button is clicked. After the button is clicked, it switches to the next screen. However, I should be able to click on a blanket which would play an animation, but the blanket button is unresponsive. I did just notice I'm getting this error in the output window:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at FinalProjectMilestoneFour_IB_ActionScriptv02_fla::MainTimeline/frame1()[FinalProjectMilestoneFour_IB_ActionScriptv02_fla.MainTimeline::frame1:17]

 

If it would help, I'll paste my full updated code below with a screenshot of where all of the animation is happening in the timeline.

 

Code:

 

Button2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(242);
}

blanketBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

{
gotoAndStop(251);
}

shirtBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

{
gotoAndStop(253);
}

 

clothesBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);

function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
gotoAndPlay("clothesRVL");
}

/* ------- */


pantsBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
{
gotoAndStop(263);
}

drawerBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
{
gotoAndStop("drawer open");
}

socksBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
{
gotoAndStop("Socks On");
}

curtainBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
{
gotoAndStop("shoesRVL");
}

shoesBTN.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
{
gotoAndStop("Shoes On");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

it would help to post the line of cofe with error.

 

and that fla has nothing to do with as2, does it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Hi.

 

I'm not sure if this is your case, but in HTML5 Canvas documents the first frame index is 0 and in AS3 documents is 1. So make sure to adjust it accordingly.

 

If that's not a issue, I think it would be helpful to help debugging the issues you're facing if you can send a link to your FLA here even if you have to use placeholders or even remove assets from your file.

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2024 Apr 24, 2024

Copy link to clipboard

Copied

This is a good point that @JoãoCésar  has made.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2024 Apr 24, 2024

Copy link to clipboard

Copied

LATEST

i don't see how an erroneous line number would trigger a 1009 error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines