[Mapserver-users] Mapserver and flash

Yewondwossen Assefa assefa at dmsolutions.ca
Thu Aug 21 16:02:37 EDT 2003


In you layer movie, there are 2 arrays defined : Attributes and Element. 
  The Attribues array contains the an entry for each attribute defined 
in the SWFDUMPATTRIBUTES metadata. In your case It should be defined like :

   nAttributes= 1;
   Attributes = new Array();
  Attributes[0] = "Name";

The Element array is a mulidimentional array, and contains an entry for 
each shape id with values for each attribute. For example for shape id 1 
and attribute 0 (1st attribute), the value will be in Element[1][0]. The 
first array indice is the shape id and the second indicates the 
attribute index.


Later,


PS : If you have access to an SWF decompiler and are able to see the 
ActionScript, you should see something like this (generated from my 
tests files where SWFDUMPATTRIBUTES" "NAME_E,AREA_KMSQ"):

// Action script...

nAttributes = 2;

Attributes = new Array();

Attributes[0] = "NAME_E";

Attributes[1] = "AREA_KMSQ";

Element = new Array();

Element[0] = new Array();

Element[0][0] = "Ellesmere Island National Park Reserve";

Element[0][1] = "39500.000";

Element[1] = new Array();

Element[1][0] = "Aulavik National park";

Element[1][1] = "12200.000";

....



Geoffrey Rowland wrote:
> Okay, Thanks, I have made the function ElementSelected and can get the 
> LayerID,ShapeID, and Event.
> 
> But I'm still at a loss how to get the SWFDUMPATTRIBUTES then?  lets say 
> my attribute is called Name.  how do I get the value using ActionScript?
> 
> Here is what I have so far (just doing this as a test)
> 
> onClipEvent (load) {
>        loadMovieNum("state_layer_0.swf",1);
> }   onClipEvent(mouseDown) {
>    _level1.ElementSelected = function(lid,sid,ev){
>             trace("The Layer id is : " + lid);
>             trace("The Shape id is : " + sid);
>             trace("The event was : " + ev);
>    }
>        _level1.ElementSelected(LayerId,ShapeId,Event, Name)
> }
> 
> Thanks,
> Geoff
> 
> Yewondwossen Assefa wrote:
> 
>> The way to do it is to use at a layer level a metadata called 
>> SWFDUMPATTRIBUTES. The value used for this metadata are the names of 
>> the attributes you want to export to the swf file. Please refer to 
>> section "How to configure the map file to export attributes"  and 
>> "Events and Highlights" in the document 
>> http://www2.dmsolutions.ca/mapserver/dl/FlashMapserverUserDoc.html
>>
>>  Once the attributes are exported to the swf file, when the user 
>> clicks on these objects, there is a mouse event which is triggered and 
>> makes an Action Script call to: _root.ElementSelecetd(LayerId, 
>> ShapeId, Event). The Flash application who want to receive these 
>> events should define the function ElementSelected and use the 
>> information receive to do actions like retrieving the attribute values 
>> from the specific SWF for the specified shape and display it.
>>
>>
>> Later,
>>
>> Geoffrey Rowland wrote:
>>
>>> I was playing around with this a bit the other day.  Is there a way 
>>> to identify features in the swf file?  for example if I am displaying 
>>> a county layer (from a shapefile), and I want to get the names of the 
>>> counties....is that possible using the swf output?
>>>
>>> Thanks,
>>> Geoff
>>>
>>>
>>> William A. Bronsema, C.E.T. wrote:
>>>
>>>> Lars-Göran,
>>>>
>>>> It is fairly easy to view the SWF output using actionscript.  Set 
>>>> the outputformat in the map file to the following:
>>>>
>>>>   OUTPUTFORMAT
>>>>     NAME swf
>>>>     MIMETYPE "application/x-shockwave-flash"
>>>>     DRIVER swf
>>>>     IMAGEMODE PC256
>>>>
>>>>     # the following line is used to output all layers in one swf
>>>>     FORMATOPTION "OUTPUT_MOVIE=SINGLE"
>>>>
>>>>     # the following line is used to output all layers individually
>>>>     #FORMATOPTION "OUTPUT_MOVIE=MULTIPLE"
>>>>   END
>>>>
>>>>
>>>> After mapserver has generated the temp swf file(s) you can use the 
>>>> "loadMovie" actionscript function to load the swf file into a 
>>>> pre-existing container.  For example, create a new swf file with a 
>>>> movie clip called "clip1" and add the following line in actionscript:
>>>>
>>>> loadMovie ( "http://url/to/swf/mymap.swf", "clip1" );
>>>>
>>>> I use PHP and php_mapscript to help manage the files on the fly and 
>>>> Flash to manage my actionscript.
>>>>
>>>> I hope this quick overview helps.
>>>>
>>>> Regards,
>>>> Bill
>>>>
>>>> Lars-goran Edholm wrote:
>>>>
>>>>> Hi!
>>>>> Does anybody have an example of using Mapserver with swf vector 
>>>>> output.
>>>>> How do i use the swf-actionscript file to view the layers?
>>>>>
>>>>>
>>>>>  Mvh
>>>>> Lars-Göran Edholm    tel 026/24 14 36
>>>>> 1:e byggnadsinspektör
>>>>> Bygg- och miljökontoret
>>>>> 811 80 Sandviken
>>>>> lars-goran.edholm at sandviken.se
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Mapserver-users mailing list
>>>>> Mapserver-users at lists.gis.umn.edu
>>>>> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>>>>
>>>>
>>>>
>>>
>>
>>
> 


-- 
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: assefa at dmsolutions.ca
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------






More information about the mapserver-users mailing list