Maintain Model in your application..! make sure that model is bindable and
follows singleton pattern..! declare a variable in model and bind it in your
main mxml file..! and update that variable from your popup window..! this
will solve your problem...!
use this "Applicaiton.application" (till SDK 3.5) will refer to your main
You can declare a callback function in the popup titlewindow component. And set the popup titlewindow callback function value to a function from the middle component.mxml file where you pop up the popup_titlewindow.
And when the user clicks the button in popup titlewindow you can call that callback function. So the input value would come to middle component.mxml
When the input value came to middle component.mxml file you can create a custom event with bubbling true, which has the value of the property you want to send to main.mxml which was taken as the parameter from the callbackfunction
By having an addEventListener in the main.mxml file you can listen to that event and the get the input value which was stored in the custom event.
If want to pass data
component to Application
this is use the variable and discard..no more in memory...
If you want session like variable in flex
that mean that value can be access in any other components also.It is in the memory for more time than earlier one...
read this article http://forums.adobe.com/thread/799057?tstart=0
I'm really not sure how to go about doing this
I just need the simplest way to do it as i am a novice
I also need to call a function from the titlewindow to the component
So the main file has a function that clears a canvas, and i need to push a button in the titlewindow component to make that function happen
You could just use a presenter for your TitleWindow...
And that means......?
Sorry, i am kinda new to flex so i just need the simplest way to:
1) Trasfer a varible from an inputbox that is in a titlebox, to the main mxml file
2) Make a component run a function that is in the main file
Simplest way which i can think would be use Application variable.
In the main MXMl file when u are calling this component assign some id to it. E.g
<comp:<name of component MXMl> id=newComp>
In the componet file ur inputtext must be having some id say it is "newinput"
Then anywhere in the main MXMl you can use the followig syntax to get the value:
Hope this solve your problem.
Got this error: Access of undefined property Application
This is what's in my main file:
(text is the folder and a is the titlewindow component)
protected function button2_clickHandler(event:MouseEvent):void
p.text = Application.application.text_a.i.text
<text:a id="text_a" />
And how do i call a function thati s in the main file from the component?
It pains me to see a tight tie in like this all the way up to the application, but to solve your issue, just hit CTRL + Space at
the end of the first Application word and it will import the reference.
It didn't work
It got this:
Access of possibly undefined property application through a reference with static type Class
I'm using flex hero in a mobile project with a blackberry sdk if thats any help
Yeah that helps a lot :). With Flex framework 4 and above we don't use Application.application anymore. Now we use FlexGlobals.topLevelApplication. Try that out and let me know.
Can you help me with this also as it is along the same lines:
- I have a button in my main application that when clicked a titlewindow that pops up with buttons on it
- One of those buttons is save and i have a function for it in the main program, but i want to be able to run it from the titlewindow component
How do i do this?
Since you are already tied in to the top level application then I would add a listener at the application level and in the component do a:
However, I can't help but encourage you to decouple this functionality and pass events around rather than what you are currently doing.
There are a few ways you can do this. One is to use an MVC framework to model your application after.
A simpler approach even would be to have the component simploy dispatch events to itself and have whatever is creating the component listen for the events and do higher level functionality.
I dont think the file is in the top level program actually, becuase i have the main file and views, and the part of the program that i'm doing this to is in the views folder. The main file says to go to the first view, which is the file i'm working on
I tried your flexglobal on a test project, not the actual project
I got this error in adobe ait when i did it in my main project:
Error #1069: Property p not found on PlayDraw and there is no default value. (p is the textbox)
I thought you said the function was in your main application. Without seeing your code now I can't really make a recommendation. If you have the function in the TitleWindow you can just call it with the button click. If the function is in antoher location then you should fire an event in the TitleWindow where the button is being pressed and catch that event in the component you are actually wanting to perform the function on.