
Copy link to clipboard
Copied
Hi
what is the reccomended way to bind a datasource of a sub-component to a Bindable collection in the top level application location.
in 3, for this I would use {Application.application.instance_of_bindable_variable}, now I get a warning saying that data binding will not be able to detect assingments to {FlexGlobals.topLevelApplication.instance_of_bindable_variable}
so, how do i bind a data source of a sub-component to a variable instantiated at the Application level in Flex 4?
Thanks,
Jed
1 Correct answer
My bad, instead of Application use the name of your application MainApp(FlexGlobals...).someProperty
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Copy link to clipboard
Copied
Bump!
Copy link to clipboard
Copied
Try "{Application(FlexGlobals.topLevelApplication).somePropOnApplication}"
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Copy link to clipboard
Copied
Hi Alex, thanks for the reply.
i added an import statement to mx.core.Application to the component and cast the FlexGlobals.topLevelApplication call, as you suggested, and it will not find the property now : "Eror 1119, access of possibly undefined property."
I am trying to bind to a public ArrayCollcection that is marked with metadata as bindable in the toplevelApplication mxml file. as such
## index.mxml
[Bindable]
public var myArrayCollection:ArrayCollection;
## myComponent.mxml
<myComponent source = "{Application(FlexGlobals.topLevelApplication).myArrayCollection}" />
-------------------
The project is imported from a Flex 3.x project and we are trying to move it over. Would it matter if the namespace for the script tag is mx vs fx, eg <mx:Script> | <fx:Script> ?
any help would be much appreciated. Thanks in advance.
Copy link to clipboard
Copied
My bad, instead of Application use the name of your application MainApp(FlexGlobals...).someProperty
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Copy link to clipboard
Copied
hi alex,
I spoke too soon. still no binding detected. I can reference index.myArrayCollection directly but I get a error that I am trying to cal and undefined method through a reference to a static Class. is the defaultApplication file compiled into a static class? Will I need to move the source of these bindable arrays outside the main application file?
Copy link to clipboard
Copied
Can I see some code snippets?
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Copy link to clipboard
Copied
thanks Alex. for any readers interested, the name of the app is the actual name of the default mxml application file, in our case its generically called, index.mxml, as opposed to the name property that you can assign to the Application tag.
Copy link to clipboard
Copied
I'm getting the compiler warning; Description Resource Path Location Type
Data binding will not be able to detect assignments to "topLevelApplication".
Regardless, what do I do if I want to bind to a global but use it in multiple applications?
"{myApp1(mx.core.FlexGlobals.topLevelApplication).someVar}"
"{myApp2(mx.core.FlexGlobals.topLevelApplication).someVar}"
Copy link to clipboard
Copied
You could define a common interface that both applications implement if you
want to use the exact same code in two different apps.
I think you would get the same warning in 3.x if you used
"{myApp1(Application.application).someVar}"
I would try just ignoring the warning and see if it works. If not, I would
recommend placing all app data you want to bind to in a data model instead.
Copy link to clipboard
Copied
I'm a one man shop and this touches 74 files, in one project for one client. I have over 400 compiler warnings. I like to keep them as clean as possible, because once in a very great while they really save my bacon. Shame on me for using globals. Shame on the Flex team for all the "make work" for simple contractor trying to make ends meet.
Copy link to clipboard
Copied
My Application variables are like this:
EmployeeID = Application.application.parameters.EmployeeID
How should it look like now?
FlexGlobals.topLevelApplication.parameters.EmployeeID ?
Not sure, anyone
thanks
George
Copy link to clipboard
Copied
Sure. You may want to cast to Application though.
Application(FlexGlobals.topLevelApplication).parameters.EmployeeID

Copy link to clipboard
Copied
I just tried it and was able to bind against my FlexGlobal ArrayCollection.
It does produce a warning "DataBinding will not be able to detect assignments to topLevelApplication".
I am unsure what that really means, will it not detect changes from other components bound to this ArrayCollection? I dont know yet.
Copy link to clipboard
Copied
Using parentApplication to navigate to where I wanted worked for me. Actually was the only way to get rid of the warrning.
Regards,
Janez
Copy link to clipboard
Copied
Thanks Janez, parentApplication worked for me too.
