I have a simple object defined by an object literal, and have a couple functions assigned to this object. Inside the functions, I try to access global variables, and it only gets undefined. The Flex debugger tells me the variables are just right up the scope tree.
Yes, I know I can access Thing by using ‘this’, that doesn’t solve my scope issue though.
Project Flex Compiler Settings: Flex SDK 3.4, Require Flash Player 10.x.
Example:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="Thing.bling();">
<mx:Script>
<![CDATA[
var Thing:Object = {
doStuff: function():void {
trace(blah); //blah is undefined
},
bling: function():void {
Thing.doStuff(); //Thing is undefined
},
};
]]>
</mx:Script>
<mx:Panel id="blah">
</mx:Panel>
</mx:Application>
I’m not sure what your trouble is, but I cut and paste your exact code into a new Flex project and despite a simple syntax error (extra trailing comma in the Thing declaration) it traced what I would expect:
(Given that my project name is Test and the panel blah is the first object).
I used Flex 3.3 then tried Flex 3 both on Flash Player 10,0,22,87
edit:
I can reproduce now if I alter the project properties by following the instructions in the comments:
Flex Builder -> Properties -> Flex Compiler -> Require Flash Player Version -> 10.0.0
With this setting the behaviour does not appear in Flex 3.0 but does appear in 3.2, 3.3 and 3.4.
I suggest this is a bug and you should find a way to work around it.