Adobe Dreamweaver Forums



Last 10 THreads :         CS4 Motion Editor issues (Last Post : aaronlyon - Replies : 4 - Views : 9 )           »          Bridge No Longer Rotates Automatically (Last Post : Michael_Palumbo@adobeforums.com - Replies : 1 - Views : 2 )           »          dollarFormat / numberformat problem (Last Post : izdabye - Replies : 0 - Views : 1 )           »          Call out side flex (Last Post : Amy Blankenship - Replies : 15 - Views : 16 )           »          captions for photos (Last Post : dc111652 - Replies : 0 - Views : 1 )           »          Re: CS4 GPU Acceleration and Intel X3100 (Last Post : Paul_B_Brown@adobeforums.com - Replies : 0 - Views : 1 )           »          error 1034 (Last Post : shottogan - Replies : 0 - Views : 1 )           »          Keyboard events don't work in player or projector (Last Post : tunghoy - Replies : 0 - Views : 1 )           »          Help with caption box question (Last Post : NZ-developer - Replies : 1 - Views : 2 )           »          Realistic Cat Hair and... (Last Post : chrisf111 - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-02-2008, 01:32 AM
thejavafreak
 
Posts: n/a
Diggs:
Default Calling a method in Parent component from Title Window

Hi all,

I have a parent component that opens up a Title window when I click a button.
Now I want to call a method in that parent component from the Title window. How
do I do this in Flex? Could anyone give me a hint please.

Thank you in advance for the help



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-02-2008, 01:32 AM
atta707
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from TitleWindow

Here is a good start:
http://weblogs.macromedia.com/pent/a...can_you_h.html
Reply With Quote
  #3 (permalink)  
Old 11-02-2008, 01:32 AM
happybrowndog
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from TitleWindow

That's goddamned ridiculous. What were Flex developers thinking that you have
to write a custom event to call back to a parent component?? Other GUI
libraries such as WxWidgets, Fox, Qt, Delphi, MFC, WinForms, etc., all allow
you to either call via a reference to the parent object or submit a callback
function into the child object. That's just basic OO programming. Flex is
looking more and more ridiculous and more like Swing - tons of unnecessary
coding to do simple things.


Reply With Quote


  #4 (permalink)  
Old 11-02-2008, 01:32 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from Title Window


"happybrowndog" <webforumsuser@macromedia.com> wrote in message
news:gctmql$4t5$1@forums.macromedia.com...
> That's goddamned ridiculous. What were Flex developers thinking that you
> have
> to write a custom event to call back to a parent component?? Other GUI
> libraries such as WxWidgets, Fox, Qt, Delphi, MFC, WinForms, etc., all
> allow
> you to either call via a reference to the parent object or submit a
> callback
> function into the child object. That's just basic OO programming. Flex
> is
> looking more and more ridiculous and more like Swing - tons of unnecessary
> coding to do simple things.


You absolutely _do_ have the capability to pass in a reference to the parent
component, or to create a "hard" reference to Application.application. But
these are not recommended practices, because anything you create this way is
then tied to an environment that implements those properties and methods.

Q (3): I want to run a function in my main application from inside my
custom component. But when I try to refer to myFunction() in that
component, I get a compile time error Call to a possibly undefined function
myFunction. How can I fix this?

A: Your component has its own scope, so it doesn't know anything
about the functions in the main file. You can get around this by directly
referencing the main application scope like this:
Application.application.myFunction(). However, this makes your component
tightly coupled, which is a quick way of saying that your component is only
usable in an application that has a myFunction() function in it. You're
better off dispatching an event from your component and letting the
application decide how to handle it. For more information, check out the
following resources:
http://www.adobe.com/devnet/flex/art..._coupling.html
http://www.adobe.com/devnet/flex/art...ating_pt1.html



From http://www.magnoliamultimedia.com/fl...s_Flex_FAQ.pdf






Reply With Quote
  #5 (permalink)  
Old 11-02-2008, 01:32 AM
happybrowndog
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from TitleWindow

[q]Originally posted by: Newsgroup User

"happybrowndog" <webforumsuser@macromedia.com> wrote in message
news:gctmql$4t5$1@forums.macromedia.com...
> That's goddamned ridiculous. What were Flex developers thinking that you
> have
> to write a custom event to call back to a parent component?? Other GUI
> libraries such as WxWidgets, Fox, Qt, Delphi, MFC, WinForms, etc., all
> allow
> you to either call via a reference to the parent object or submit a
> callback
> function into the child object. That's just basic OO programming. Flex
> is
> looking more and more ridiculous and more like Swing - tons of unnecessary
> coding to do simple things.


You absolutely _do_ have the capability to pass in a reference to the parent
component, or to create a "hard" reference to Application.application. But
these are not recommended practices, because anything you create this way is
then tied to an environment that implements those properties and methods.

You didn't mention passing a callback function from the parent to the child,
which would truly achieve the loose coupling you desire. In any case, writing
a custom event also requires the parent application to be modified to know what
that event is going to be and be coded for it. That's not loose coupling
either.


Reply With Quote
  #6 (permalink)  
Old 11-02-2008, 01:32 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from Title Window


"happybrowndog" <webforumsuser@macromedia.com> wrote in message
news:gcu3ou$j0l$1@forums.macromedia.com...
> [q]Originally posted by: Newsgroup User
>
> "happybrowndog" <webforumsuser@macromedia.com> wrote in message
> news:gctmql$4t5$1@forums.macromedia.com...
> > That's goddamned ridiculous. What were Flex developers thinking that
> > you
> > have
> > to write a custom event to call back to a parent component?? Other GUI
> > libraries such as WxWidgets, Fox, Qt, Delphi, MFC, WinForms, etc., all
> > allow
> > you to either call via a reference to the parent object or submit a
> > callback
> > function into the child object. That's just basic OO programming. Flex
> > is
> > looking more and more ridiculous and more like Swing - tons of
> > unnecessary
> > coding to do simple things.

>
> You absolutely _do_ have the capability to pass in a reference to the
> parent
> component, or to create a "hard" reference to Application.application.
> But
> these are not recommended practices, because anything you create this way
> is
> then tied to an environment that implements those properties and methods.
>
> You didn't mention passing a callback function from the parent to the
> child,
> which would truly achieve the loose coupling you desire. In any case,
> writing
> a custom event also requires the parent application to be modified to know
> what
> that event is going to be and be coded for it. That's not loose coupling
> either.


The parent always has to know something about the children.


Reply With Quote


  #7 (permalink)  
Old 11-02-2008, 01:32 AM
ntsiii
 
Posts: n/a
Diggs:
Default Re: Calling a method in Parent component from TitleWindow

Further, a custom event is not required. If the component exposes the data in public properties, then any handler can access that data via the event.target reference.


Tracy
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 03:27 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk