Goal:
To run a SWF shows yahoo map in some device rather than IE or Firefox . In my device, I can run swf only, no html.
Till now what I know:
I built a Flex project following the Yahoo map tutorials
(http://developer.yahoo.com/flash/tutorials/as3/maps.html). It worked perfectly in IE or Firefox with the wrapper ***.html. But if I run .swf directly, the map can’t be shown.
The SWF is in fact a wrapper of Yahoo map for AS2, It loads as2map.swf using SWFLoader, which is a subclass of UIComponent. One thing special is, when as2map.swf is loaded, wrapper swf call ExternalInterface.call to communicate with as2map.swf. The call is:
Method name: YahooMapFlex.setMapSize100
Parameter : {w:100,h:100}
“YahooMapFlex” is the name (in firefox) or id (in IE), “setMapSize” is a method exposed by as2map.swf. “ 100” is ID of sa2map instance, the value depends on specification in YahooMapFlex.swf. If you call 101, the map cant show. There’s no document about the grammar of “ 100” .
IE |
As2map.swf |
YahooMapFlex.swf |
ExternalInterface.call
|
Calling “setMapSize” seems to be necessary. It triggers as2map to show itself.
There are same other calls, but not necessary.
Question:
If I open YahooMapFlex.swf in IE directly, map cant be shown. Is there some thing in the wrapper html? I simplify the wrapper html to this:
Firefox:
<embed src="YahooMapFlex.swf" name="YahooMapFlex">
</embed>
IE:
<object id="YahooMapFlex" type="application/x-shockwave-flash" >
<param name="movie" value="YahooMapFlex.swf">
</object>
the key is “name” or “id” property must be specified, to communicate with the SWF. Since I have no wrapper html, I have no way to specify the ID or name.
What’s more , in my device, ExternalInterface.available = flase, means I cant use ExternalInterface.
Now the problem come to a point: how can I communicate with a swf without using ExternalInterface.
I tried SWFLoader.content to make a call:
var movie :*= this.content;
movie.YahooMapFlex.setMapSize100({w:100,y:100});
the result is an Error:
ReferenceError: Error #1069: flash.display.AVM1Movie has no property YahooMapFlex …
The following call also fail:
YahooMapFlex.setMapSize100({w:100,y:100});
movie. setMapSize ({w:100,y:100});
movie.setMapSize100 ({w:100,y:100});
So far I’m confused, any comment is appreciated. Thank you.
My msn : rogeryuan_9@hotmail.com