Highlighted

1120: Property access undefined in Scene 2

Community Beginner ,
Feb 21, 2019

Copy link to clipboard

Copied

Hello

I'm trying to navigate from scene 1 to scene 2 through the button, but I get 1120: Property access undefined when I try to access the text property of a text object.

This is my code:

//SCENE 1

import flash.events.MouseEvent;

stop();

Inst_btnContinuar.addEventListener(MouseEvent.CLICK, click_btnContinuar);

function click_btnContinuar(event:MouseEvent):void{

                MovieClip(this.root).gotoAndStop(1, "Cena 2");

}

//SCENE 2

stop();

Inst_txtNomeUtilizador.text = "Bom dia";

Hi pvalentim

I've simulated your scenario in Animate and yes, I get the same 1120 Compiler error

1120: Access of undefined property Inst_txtNomeUtilizador

This error shows only when the Compiler Mode is set to Strict. You can set the mode to Standard when you select File -> Actionscript Settings... and uncheck Errors : Strict.

But then you'll get a Run-Time-Error:

ReferenceError: Error #1065: Variable Inst_txtNomeUtilizador is not defined.

So what does that all mean? The Dynamic TextField Inst_txtNomeUtilizador is in that situation, when the code tries to execute, not registered as a Variable. Hence not available and ready for manipulation.

If you try this simply on Cena 1, it works. But not in Cena 2. Why? I tried a couple of things like having Inst_txtNomeUtilizador in frame 1 and 2 but apply the code first in frame 2. Still the same. Either 1120 Compiler Error or 1065 Reference Error.

The whole trouble is related to using scenes. Read this page . There is stated clearly:

Scenes combined with ActionScript might produce unexpected results. Because each scene Timeline is compressed onto a single Timeline, you might encounter errors involving your ActionScript and scenes, which typically require extra, complicated debugging.

I myself don't use Actionscript since 2015. Since then I work in Animate with CreateJS/Javascript. But before that, when still using AS3 I never used Scenes.  One of the main reasons for this becomes clear again when I see your problem.

One way as alternative to scenes could be creating seperate SWFs instead of scenes and combine them to a bigger presentation with the Loader Class and URLRequest method. See here or here. I know, that seems to be a horribly steep learning curve at first, but believe me, it's worth it.

But if you want to stick to the out-dated way of Scenes, I fear in your scenario, you would have to create the Dynamic TextField dynamically with Actionscript. If you remove the ready-made textField and code in Cena 2 / frame 1 the following:

import flash.text.TextField;

stop();

var Inst_txtNomeUtilizador = new TextField();

Inst_txtNomeUtilizador.text = "Bom dia";

addChild(Inst_txtNomeUtilizador);

That works without both error types. But it's cruel, the text would just sit on x/y = 0/0 and would have no proper formatting like fontSize, fontColor, width, height or Embedded Font. For that you needed to apply more code and additionally the textFormat class. All that is reasonably easy explained on this page: AS3: Text Fields and Formats .

Sorry that can't offer a quick fix

Klaus

Views

535

Likes

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

1120: Property access undefined in Scene 2

Community Beginner ,
Feb 21, 2019

Copy link to clipboard

Copied

Hello

I'm trying to navigate from scene 1 to scene 2 through the button, but I get 1120: Property access undefined when I try to access the text property of a text object.

This is my code:

//SCENE 1

import flash.events.MouseEvent;

stop();

Inst_btnContinuar.addEventListener(MouseEvent.CLICK, click_btnContinuar);

function click_btnContinuar(event:MouseEvent):void{

                MovieClip(this.root).gotoAndStop(1, "Cena 2");

}

//SCENE 2

stop();

Inst_txtNomeUtilizador.text = "Bom dia";

Hi pvalentim

I've simulated your scenario in Animate and yes, I get the same 1120 Compiler error

1120: Access of undefined property Inst_txtNomeUtilizador

This error shows only when the Compiler Mode is set to Strict. You can set the mode to Standard when you select File -> Actionscript Settings... and uncheck Errors : Strict.

But then you'll get a Run-Time-Error:

ReferenceError: Error #1065: Variable Inst_txtNomeUtilizador is not defined.

So what does that all mean? The Dynamic TextField Inst_txtNomeUtilizador is in that situation, when the code tries to execute, not registered as a Variable. Hence not available and ready for manipulation.

If you try this simply on Cena 1, it works. But not in Cena 2. Why? I tried a couple of things like having Inst_txtNomeUtilizador in frame 1 and 2 but apply the code first in frame 2. Still the same. Either 1120 Compiler Error or 1065 Reference Error.

The whole trouble is related to using scenes. Read this page . There is stated clearly:

Scenes combined with ActionScript might produce unexpected results. Because each scene Timeline is compressed onto a single Timeline, you might encounter errors involving your ActionScript and scenes, which typically require extra, complicated debugging.

I myself don't use Actionscript since 2015. Since then I work in Animate with CreateJS/Javascript. But before that, when still using AS3 I never used Scenes.  One of the main reasons for this becomes clear again when I see your problem.

One way as alternative to scenes could be creating seperate SWFs instead of scenes and combine them to a bigger presentation with the Loader Class and URLRequest method. See here or here. I know, that seems to be a horribly steep learning curve at first, but believe me, it's worth it.

But if you want to stick to the out-dated way of Scenes, I fear in your scenario, you would have to create the Dynamic TextField dynamically with Actionscript. If you remove the ready-made textField and code in Cena 2 / frame 1 the following:

import flash.text.TextField;

stop();

var Inst_txtNomeUtilizador = new TextField();

Inst_txtNomeUtilizador.text = "Bom dia";

addChild(Inst_txtNomeUtilizador);

That works without both error types. But it's cruel, the text would just sit on x/y = 0/0 and would have no proper formatting like fontSize, fontColor, width, height or Embedded Font. For that you needed to apply more code and additionally the textFormat class. All that is reasonably easy explained on this page: AS3: Text Fields and Formats .

Sorry that can't offer a quick fix

Klaus

Views

536

Likes

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
Feb 21, 2019 0
Advocate ,
Feb 22, 2019

Copy link to clipboard

Copied

Hi pvalentim

I've simulated your scenario in Animate and yes, I get the same 1120 Compiler error

1120: Access of undefined property Inst_txtNomeUtilizador

This error shows only when the Compiler Mode is set to Strict. You can set the mode to Standard when you select File -> Actionscript Settings... and uncheck Errors : Strict.

But then you'll get a Run-Time-Error:

ReferenceError: Error #1065: Variable Inst_txtNomeUtilizador is not defined.

So what does that all mean? The Dynamic TextField Inst_txtNomeUtilizador is in that situation, when the code tries to execute, not registered as a Variable. Hence not available and ready for manipulation.

If you try this simply on Cena 1, it works. But not in Cena 2. Why? I tried a couple of things like having Inst_txtNomeUtilizador in frame 1 and 2 but apply the code first in frame 2. Still the same. Either 1120 Compiler Error or 1065 Reference Error.

The whole trouble is related to using scenes. Read this page . There is stated clearly:

Scenes combined with ActionScript might produce unexpected results. Because each scene Timeline is compressed onto a single Timeline, you might encounter errors involving your ActionScript and scenes, which typically require extra, complicated debugging.

I myself don't use Actionscript since 2015. Since then I work in Animate with CreateJS/Javascript. But before that, when still using AS3 I never used Scenes.  One of the main reasons for this becomes clear again when I see your problem.

One way as alternative to scenes could be creating seperate SWFs instead of scenes and combine them to a bigger presentation with the Loader Class and URLRequest method. See here or here. I know, that seems to be a horribly steep learning curve at first, but believe me, it's worth it.

But if you want to stick to the out-dated way of Scenes, I fear in your scenario, you would have to create the Dynamic TextField dynamically with Actionscript. If you remove the ready-made textField and code in Cena 2 / frame 1 the following:

import flash.text.TextField;

stop();

var Inst_txtNomeUtilizador = new TextField();

Inst_txtNomeUtilizador.text = "Bom dia";

addChild(Inst_txtNomeUtilizador);

That works without both error types. But it's cruel, the text would just sit on x/y = 0/0 and would have no proper formatting like fontSize, fontColor, width, height or Embedded Font. For that you needed to apply more code and additionally the textFormat class. All that is reasonably easy explained on this page: AS3: Text Fields and Formats .

Sorry that can't offer a quick fix

Klaus

Likes

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
Reply
Loading...
Feb 22, 2019 1
Community Beginner ,
Feb 22, 2019

Copy link to clipboard

Copied

Thank you very much for your response kdmemory.

I understood perfectly.

I thought that when drawn, the objects would already be declared in the second scene.

as3.png

Likes

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
Reply
Loading...
Feb 22, 2019 1
Adobe Community Professional ,
Feb 22, 2019

Copy link to clipboard

Copied

Hi.

You can either turn off the advanced layers mode in the Document Settings (Ctrl/Cmd + J) or insert the name of the layer in which your text field is placed like this:

THE_NAME_OF_YOUR_LAYER.Inst_txtNomeUtilizador.text = "Bom dia";

I hope this helps.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Feb 22, 2019 2
Advocate ,
Feb 22, 2019

Copy link to clipboard

Copied

Blimey!!

Of course it is caused by the Advanced Layers. How embarrassing. I was blended by the ghosts of Actionsscript 3 and Scenes, that I didn't see the obvious.

Sorry pvalentim, there's the quick fix. Nevertheless thank you for marking my answer as correct .

Klaus

Likes

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
Reply
Loading...
Feb 22, 2019 1
Community Beginner ,
Feb 22, 2019

Copy link to clipboard

Copied

Simple things.

I could never do it alone.

Thanks.

Likes

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
Reply
Loading...
Feb 22, 2019 2