[Solved] "Potentially undefined methods" error with Global Attributes blocks


  • Posts: 591
So, I was just trying to write a simple function, which would get a character from string Map treated as array with dimensions MWidth and MHeight. All those three variables (Map, MWidth, MHeight) are Game Attributes. When arguments are out of range, it's treated like there's no wall (that's what "if" block is for).
Here's the image for block with this function: [LINK]

However, when I try to compile that, such error is shown:
Code: [Select]
Behavior: Design_4_4_MakeCorner at line 169
Invoking potentially undefined method getGameAttribute.
        if((((__MX < 0) || (__MX >= (getGameAttribute("MWidth") as Number))) ||
((__MY < 0) || (__MY >= (getGameAttribute("MHeight") as Number)))))
...and so forth for four other places where Game Attributes are used.

I wasn't using code at all and I don't know the possible reason for this to happen. I already tried restarting and Ctrl+R - ing Stencyl (the latter was suggested by someone on support chat), but it didn't work.
I didn't have opportunity to test this function, so it's not something which happened because of not initialized variables.

Could anybody find the possible solution or source of the problem? O.o

« Last Edit: July 08, 2011, 03:08:17 am by Sunflower »


  • Posts: 1118
I have a feeling you are using a Global Custom Block? If that is the case, it is likely that is the reason you are having this issue.

It appears to me that the method getGameAttribute() is scene specific, or rather, non static and instance specific, which means that a Global Custom Block - which is a Static function - would not be able to access the method.

I'd suggest changing it to a non Global Custom Block and see if the alleviates the issue.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs


  • *
  • Posts: 3132
Yeah, the problem is that you're fetching a GA from within a Global Custom Block.

This kind of things should be hidden from Design Mode users.
"Find the fun"


  • Posts: 591
Yes, when I changed them to regular Custom Blocks, it worked properly. Thanks a lot. :)