Copy link to clipboard
Copied
Hi
I have had problems with the input code and keep getting this error: 1119: Access of possibly undefined property nameInput through a reference with static type Class.
The code is here below
function captureText():void
{
var myText = Page5.nameInput.text;
Page6.nameOutput.text = "Hello "+myText+"!"
}
Page 5 is the page the input is on
Page 6 is where the outpu is
nameInput and nameOutput are my text area and dynamic text boxes
Apparently they are static classes??
Any ideas will be greatfully appreciated
Thanks
Copy link to clipboard
Copied
always type your vars:
so it should be:
var myText:String = Page5.nameInput.text;
Page6.nameOutput.text = "Hello "+myText+"!"
then:
make sure that when you call captureText(), Page5 and Page6 (which I guess are Sprites/MovieClips) are part of the current Displaylist
if you are for example on Scene5 of your file and Page6 is on Scene6, calling Page6 will throw an error, because Flash can`t find it on its current DisplayList
Copy link to clipboard
Copied
Thanks for your response
I have just tried this and I still have the same errors.
Can you suggest anything else ?
Thanks
Copy link to clipboard
Copied
The error appears to be indicating that the words Page6 and/or Page5 represent class names, not movieclip instance names. How are these names defined?
Copy link to clipboard
Copied
...And this is one of the many reasons why you shouldn't get in the habit of using global static things to access things in different scopes instead of using dependency injection. Because if you're not clear in your head about exactly what it is you're doing, you can run into this type of error.
To clarify what Ned says, you've created a Class, knowingly or not, called Page5. Page5 will either be an Actionscript Class or a symbol in your library that has "Export for Actionscript" checked.
Looking at your code, it looks like you're using frame scripts, so you need to look to your timeline and make sure you have something on stage that is an instance of Page5. To follow good naming conventions, you should name your instance in camel case, starting with a lower case letter, such as page5. Now, your code should become:
function captureText():void {
var myText = Page5(page5).nameInput.text;//cast to Page5 Class so we can refer to nameInput without error
//etc...
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now