# Logic flow confusion

**URL:** <https://forum.kirupa.com/t/logic-flow-confusion/272399>\
**Category:** Uncategorized\
**Created:** [October 4, 2008, 10:32pm UTC](https://forum.kirupa.com/t/logic-flow-confusion/272399 "2008-10-04T22:32:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandpaw\_broon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/grandpaw_broon/32/3985_2.png) [@grandpaw\_broon](https://forum.kirupa.com/u/grandpaw_broon)\
**Post date:** [October 4, 2008, 10:32pm UTC](https://forum.kirupa.com/t/logic-flow-confusion/272399/1 "2008-10-04T22:32:19Z")

</div>

[LEFT]If a public method of an instance sets up the event listeners, then how can the results of those listener methods be returned?[/LEFT]

Hi all,

I am a bit confused with a situation i have. I will try to explain as best i can.

Ok this is for google maps but bare with me coz its not really focused on that.

With google maps, in order to search the map from a string then you need to use the google map API to send that string to google and have googles API return a Latitude/Longitude co-ordinate.

I do not know how to write a method for my maps class that returns a value. Here is an unrelated basic local class.

```auto
 
private var someVar:String = "hi";
 
public function doReturnString(): String
{
    return someVar;
}

```

That means some other class can call Map.doReturnString();

```auto
var myword:String = Map.doReturnString() as String; //hi

```

[LEFT]But what about if you need to wait for information? Back to maps…[/LEFT]

```auto

[LEFT]public function doReturnGeocode(s:String): void
{
  var geo:ClientGeocoder = new ClientGeocoder();
  geo.addEventListener(GeocoderEvent.FAILURE, onFailure);
  geo.addEventListener(GeocoderEvent.SUCCESS, onSuccess);
  geo.geocode(s);
}[/LEFT]

```

[LEFT]There is nothing to return… So pretend i wanted to ask for the geocode of a user inputted place and put a marker on the map at that place… The above method will return nothing. The only way i can think to do it is inside the onSuccess method[/LEFT]

```auto

[LEFT]private function onSuccess(e:GeocoderEvent): void
{
 var myCoords:LatLng = e.result.lastResult as LatLng; //here is my geocode info!
}[/LEFT]

```

[LEFT]However there seems to be no way i can access that information from the outside and it means creating a new SUCCESS and FAILURE method for each feature (panning, zooming, goto, centre screed, bounds…).[/LEFT]

[LEFT]Id just like to call a public method… have it do all the work with google and then return the information back to the user like below.[/LEFT]

[LEFT]var user:LatLng = map.doReturnGeocode(“Edinburgh, Scotland, UK”);[/LEFT]

[LEFT]Is this making any sense to anyone?[/LEFT]

[LEFT]Thanks![/LEFT]
