Just got the text to pass through as well.

In the end, I added this to the myMap event listener setup

   //my custom event
   myMap.addEventListener('onHtmlLinkClicked', onHtmlLinkClicked);

I didn't add a callback there as I don't need to access it through this event from Flex.

I then added this function (after onMinZoom)

function onHtmlLinkClicked(data:String) { // accepts the string from asfunction
   var rtnObj:Object = new Object();
rtnObj['data'] = data; // makes a data attribute of the object passing in the string data
   // make a new EIBuffer call for this action to pass through
EIBuffer.addCall({method:swfDomId + ".onHtmlLinkClicked" + id, data:rtnObj});
}

In MapEventDispatcher.as I added

to the Event metatags:

[Event(name="onHtmlLinkClicked", type="MapEvent")]

in the setListeners function

ExternalInterface.addCallback("onHtmlLinkClicked" + UUID, onHtmlLinkClicked);

Though that may not be necessary since I am not using the callback... just in case though...

Then added a new function to dispatch the MapEvent

private function onHtmlLinkClicked(ev:Object):void {
   dispatchEvent(new MapEvent('onHtmlLinkClicked', ev));
}

then in my Cairngorm app, in mapInit added

mapEventDispatcher.addEventListener('onHtmlLinkClicked', htmlLinkClickHandler);

and within htmlLinkClickHandler, the string from the asfunction is available via the ev.lastResult.data.

Cool. I think that was all I did. THAT was an education. Thanks again for your help!

Michael





Michael Wills wrote:
One more tidbit, using the XPanel logger, logging "this" from the map,
getting it's path (_root.mapClip in this case) I can now call functions
from the map itself from within the marker.

However I am not yet able to register a new event. I may just hijack one
of the current ones and pass a new fake object that will let my Flex app
know it's my custom call.

So, any takers on registering a new event with the yahoomap component? :-)

If that works, then it's a hack, but a usable hack. Eventually true AS3
map components will be available so this kind of thing won't be as
necessary... keeping fingers crossed. :-)

Thanks for the inspiration all,

Michael

Michael Wills wrote:
Yeah the POI marker click event is fine and quite useful. I think it was after reading your post Anupam. :-) However after that, I can't trigger anything in the Cairngorm app. I even tried to make a function with the original as2map.fla that would simply trigger a new POIMarkerClick event with data passed from the asfunction call within the marker. That hasn't worked yet either.

I also tried to use FlashInterface which, by itself, should work. However it blocks the communication of the YahooMap communication kit as is.

Basically, similar to Anupam's change to the code, I'd like to add an htmlTextClick function which can be can be called via asfunction. Something like:

function onHTMLLinkClick(ev:Object) {
var rtnObj:String = new String();
EIBuffer.addCall({method:swfDomId + ".onHTMLLinkClick" + id, data:rtnObj});
}

and where it sets up listeners in the mapClip object

myMap.addEventListener('onHTMLLinkClick', onHTMLLinkClick);

and then in the description of a POI Marker have

description:"<a href=\'asfunction:onHTMLLinkClick,someString\'>Click me...</a>"

or would this have to be:

description:"<a href=\'asfunction:_parent.onHTMLLinkClick,someString\'>Click me...</a>"

and in the Flex project

mapEventDispather.addEventListener('onHTMLLinkClick', htmlLinkClickHandler);

So the link would trigger the new event which would call the function in the loaded as2map.swf which would then trigger the new event which would be picked up by Flex, etc.

So is this possible? Since this function isn't in the original API, is it possible to add it this way? It looks like the .addCall would add it to the methodQueue array in the ExternalInterfaceBuffer.as file. Here's to hoping...

And Benoit, thanks for the tip about adding the setMapSize snippet in the MapController.as. It sized fine when first loading but that could be VERY useful when dynamically resizing.

Thank you to you both. I'll give these a shot and see if there is any progress with it.

Michael

Benoit Hediard wrote:
Are you sure you can catch events generated by an href link in the description htmlText?

I think we've tried to play around with the POIMarkerClick event.

But it was only dispatched when you first click on the marker to open it.

Further click on a link in the htmlText description was not generating any POIMarkerClick events, so we could not catch anything.

But may be, we did something wrong, we have to check it out again...

Benoit Hediard

#affinitiz.com

*De :* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *De la part de* anupam_111181
*Envoyé :* mercredi 25 avril 2007 09:27
*À :* flexcoders@yahoogroups.com
*Objet :* [flexcoders] Re: yahoomaps POI marker click event, htmltext asfunction

Hi michael,
I have done this and its pretty easy,
You can call any flex event on the click of the marker click
there is one event called onPOIMarkerClick in the Yahoo map component.
You should have the latest code because this event handler was not
there in the previous versions.

I have written a blog entry on this...
Check it out..
http://digitallyinsane.wordpress.com/2007/03/13/yahoo-maps-as3-communication-tool-kit/ <http://digitallyinsane.wordpress.com/2007/03/13/yahoo-maps-as3-communication-tool-kit/>

Cheeers!
Anupam
--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>, Michael Wills <[EMAIL PROTECTED]> wrote:
For clarification, the idea is simply to allow a marker to be
clicked to
open it, but then trigger an event/call a function in the cairngorm app
when clicking on a link in the description.

Thanks,

Michael

Michael Wills wrote:
Hello all,

Just wondering if it's possible to use asfunction to call a function
in a cairngorm app from the htmltext in the description of a POI
marker within a Yahoomap in a Flex 2 app without making modification
to the as2map.fla file.

It's a long shot, but I was just wondering if it's been done, and
eagerly anticipating a true AS3 map component.

The new AS3 "event:" protocol of course isn't recognized by the Flash
8 interpreter and so it's not available.

So I was hoping it would be something like:

markerDesction = "<a asfunction:doNotKnowWhatGoesHere.myFunction/>"

Is that a possibility at all?

Thanks,

Michael


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links



Reply via email to