Adobe Dreamweaver Forums



Last 10 THreads :         Multiple Netstreams (live feeds) best practices (Last Post : techeye - Replies : 3 - Views : 4 )           »          Dynamic XML Array Push ? (Last Post : Jadeivy - Replies : 0 - Views : 1 )           »          How to make a paypal button? (Last Post : loki2357 - Replies : 0 - Views : 1 )           »          How to align XML loading text to right (Last Post : Boxing Boom - Replies : 8 - Views : 9 )           »          Why is this not working!!! (Last Post : NedWebs - Replies : 10 - Views : 11 )           »          ProgressBar and myPlayer (Last Post : kglad - Replies : 3 - Views : 4 )           »          Flash-PHP Mail Form (Last Post : richmaxw - Replies : 2 - Views : 3 )           »          flash loader reappears after movie plays (Last Post : lyshamo - Replies : 2 - Views : 4 )           »          Call out side flex (Last Post : mab_bond - Replies : 1 - Views : 2 )           »          Flex compiler in FlexBuilder and Flex SDK (Last Post : mab_bond - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-31-2008, 06:27 PM
ks_flex_user
 
Posts: n/a
Diggs:
Default Waiting for event handlers to return

I have the following code:

.......
public function foo():void {
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest(filename));
}
......

The caller for foo needs to get some fields that are set by the onComplete
function. Since foo returns before onComplete returns, the caller is unable to
get the correct value. How do I specify that I want to wait for onComplete to
finish before foo() returns?

Thanks.




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-31-2008, 06:27 PM
atta707
 
Posts: n/a
Diggs:
Default Re: Waiting for event handlers to return

You can't. Done want to either! Let the onComplete do whatever you want the caller of the foo to do. Or simply, dispatch another custom event from onComplete and let the interested party handle it.
Reply With Quote
  #3 (permalink)  
Old 10-31-2008, 06:27 PM
ks_flex_user
 
Posts: n/a
Diggs:
Default Re: Waiting for event handlers to return

Can you please explain why this is not advisable? I feel that doing it your way
would mix, in my case, the model and the view. Here's a simplified version of
what I'd like to do: Parse the XML, create an instance of the model (a .as
class file). The view then gets updated with the model (from a .mxml file)
contents. If I do things as you suggest, I'd have to pass a handle to the view
into the onComplete method that's a part of the model. In case I need to update
more than once, then your other suggestion of handling a custom event also
seems a bit unwieldy: I'd have to keep some flag to know if the event has
occured or not, so that the first view update happens in the handler which only
gets called once and sets the flag, and the next updates need to rely on the
flag being set.

I'm sure that it has been implemented this way for a very good reason. I'm
probably missing the right way to do this all!! Can you please explain it?
Thanks!!

Reply With Quote


  #4 (permalink)  
Old 10-31-2008, 06:27 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Waiting for event handlers to return


"ks_flex_user" <webforumsuser@macromedia.com> wrote in message
news:gd77k7$6rl$1@forums.macromedia.com...
> Can you please explain why this is not advisable? I feel that doing it
> your way
> would mix, in my case, the model and the view. Here's a simplified version
> of
> what I'd like to do: Parse the XML, create an instance of the model (a .as
> class file). The view then gets updated with the model (from a .mxml file)
> contents. If I do things as you suggest, I'd have to pass a handle to the
> view
> into the onComplete method that's a part of the model. In case I need to
> update
> more than once, then your other suggestion of handling a custom event also
> seems a bit unwieldy: I'd have to keep some flag to know if the event has
> occured or not, so that the first view update happens in the handler which
> only
> gets called once and sets the flag, and the next updates need to rely on
> the
> flag being set.
>
> I'm sure that it has been implemented this way for a very good reason. I'm
> probably missing the right way to do this all!! Can you please explain it?
> Thanks!!


http://www.adobe.com/devnet/flex/art...ating_pt1.html


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 10:46 PM.


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.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk