[PLUG] href in flash??

Carlos Konstanski ckonstanski at pippiandcarlos.com
Sun Aug 9 00:15:41 UTC 2009


Keith Lofstrom <keithl at kl-ic.com> writes:

> Thanks again for the great answers to the last question.
> Unfortunately, it encouraged me to ask another.   :-)
>
> I am adding a small improvement to wydiwys - actually, to the
> html template file (I hope).  
>
> I want "mouse left click" to advance to the next image. 
>
> The obvious reason is for ease of use, the subtle reason is
> to provide an href that search engine spiders can use to
> find all the images in a slide set.  
>
> So - I have that working for my image slides, which are
> imbedded in an:
>
>    <a href="nextslide.html"><img src="thisslide.png" ></a>
>
> ... kind of wrapper.  Standard stuff. 
> However, I get no joy if I try:
>  
>    <a href="nextslide.html"> <object data="thisslide.swf"
>    ... other stuff > ... params ... </object> </a>
>
> or
>
>    <object href="nextslide.html" data="thisslide.swf"...
>
> Neither of these respond to a click.
>
> I can probably intercept the left mouseclick in javascript, but
> the search engine spiders probably aren't smart enough to figure
> that out.  Perhaps I combine that with the first nonfunctional
> aref method above, which will probably fool a spider.
>
> Given the way I am implementing things now, the javascript
> approach is a little ugly.  Some pages (not image or flash
> slides) have normal clickable links in them, and I would have
> to turn off the code that intercepts the left mouseclick.
>
> Ideas?  Lateral thinking?
>
> Keith
>
> (p.s. - if I am putting my slide shows up for public consumption,
> I want the images searchable.  I've found vendors of odd hardware
> using Google Image Search, for example.  The static image slides
> in the presentations are linearly linked with arefs, but the chain
> is broken by the swf slides. )

Your two reasons might require two distinct, concurrent solutions.
Here's my take on the problem; someone else might have a much snazzier
solution, and I am eager to see it!

While it's true that you cannot make an entire flash movie into a link
via a simple href wrapper, the search engines will still find the link
and follow it.  To appease the search engines, you don't even need to
put anything inside the <a> and </a> tags.  They just look for links
and follow them.  onclick handlers don't get followed; bots ignore all
javascript.  Put your hidden hyperlinks inside a <noscript> tag so
that humans don't see them displayed in the browser.

To make the whole flash movie clickable as though it were one big
hyperlink, you will need to add the code inside the flash movie,
specifically to an outer container's clicked() event in actionscript,
like Canvas.click() in flex.  This is generally easy enough to do once
you have a function that will do the work, provided you have access to
the flash code, and you can recompile it.  Precise directions will
depend on the specifics of your flash movie.  A bare minimum example:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Canvas id="mainCanvas" width="300" height="300" click="handleCanvasClick();"/>
    <mx:Script>
        <![CDATA[
            import flash.net.URLRequest;
            import mx.controls.Alert;

            private var url:String = "http://www.google.com/";

            private function handleCanvasClick():void {
                var request:URLRequest = new URLRequest(url);
                try {
                    navigateToURL(request);
                } catch(e:Error) {
                    Alert.show(e.message);
                }
            }
       ]]>  
    </mx:Script>
</mx:Application>


http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/package.html#navigateToURL()

If I ever have to make a flash website google-catalogable (I'm
referring to larger, navigational flash applications), I would use the
trick of having the <noscript> block of the containing HTML document
contain raw, wget-friendly HTML that displays a tree of hyperlinks
that mirrors the entire navigation map within the flash movie, and
then I'd architect the flash so that each URL in the tree will reload
the flash movie in the correct navigational state.  Some descriptive
content whould also be included within the <noscript> tag so it would
show up in google.  But the flash movie would not necessarily have to
reload the browser upon normal user navigation; this whole setup is
entirely for the purpose of letting google users come into any
navigational point of the flash movie in the correct state, and have
each navigational point cataloged in google.

Carlos



More information about the PLUG mailing list