Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#2336 closed enhancement (fixed)

Instances do not have instance names associated

Reported by: assefa Owned by: assefa
Priority: normal Milestone: 5.4 release
Component: Output-SWF Version: unspecified
Severity: normal Keywords:
Cc: sscott@…, dmorissette, dringuet@…

Description

Elements are created a s Butoon instances, but there is no name associated with the instances.

Change History (25)

comment:1 by sscottlocinc, 16 years ago

Cc: sscott@… added

comment:2 by sscottlocinc, 16 years ago

Here is a link to the discussion I began about this stuff on the ming list-server ( someone has provided advice ).

https://sourceforge.net/mailarchive/forum.php?thread_name=46FC3121.3010303%40locationinc.com&forum_name=ming-users

I am not a c developer, but I would like to help any way I can. Let me know how I can help. Shannon

comment:3 by assefa, 16 years ago

from what I can see, It should be possible to do something like this to set the instance name. Did a quick test with 0.2.a and it seems to do the trick.

oDisplay = SWFMovie_add(GetCurrentMovie(map, image), oButton);

SWFDisplayItem_setName(oDisplay, "button1");

Do you know if the instance name need to be anything special or should it be unique ?

comment:4 by sscottlocinc, 16 years ago

The instance name does not need to be anything specific ( instance1, instance2 - or button1, button2 would work ). They do need to be unique though.

comment:5 by dmorissette, 16 years ago

Cc: dmorissette added
Owner: changed from mapserverbugs to assefa

comment:6 by assefa, 16 years ago

Status: newassigned

Add unique instance names to buttons (r6912). If possible, please give it a try and let me know.

comment:7 by sscottlocinc, 16 years ago

When I try to compile, I a series of warnings then an error: ... mapswf.c:3037: warning: passing arg 2 of `SWFMovie_add' from incompatible pointer type mapswf.c:3047: warning: passing arg 2 of `SWFMovie_add' from incompatible pointer type mapswf.c:3053: warning: passing arg 2 of `SWFMovie_add' from incompatible pointer type mapswf.c: In function `msDrawVectorLayerAsRasterSWF': mapswf.c:3211: warning: passing arg 2 of `SWFMovie_add' from incompatible pointer type make: * [mapswf.o] Error 1

Perhaps I'm doing something wrong, could I please get a copy of the code you compiled ( mapswf.c )? I am not a c developer, so I apologize if I am not making much sense. Thank you for your help. Shannon

comment:8 by sscottlocinc, 16 years ago

I meant to also write: When I change these lines:

oDisplay = SWFMovie_add(GetCurrentMovie(map, image), oButton); SWFDisplayItem_setName(oDisplay, "poly"+nShapeIndex);

back to this line:

SWFMovie_add(GetCurrentMovie(map, image), oButton);

I get the same warnings, but everything finishes ok, and works great. Shannon

comment:9 by assefa, 16 years ago

Shannon,

which lines are giving the warnings and errors ? Is it the SWFMovie_add function and/or SWFDisplayItem_setName (we seem to have a diffrent source code so I could not quickly see the code line refered in the outpout you sent in your previous message like line 3037, 3047 ...). What version of ming are you using ? I will try to upgrade my version of ming to 0.4 and see what are the diffreneces.

comment:10 by sscottlocinc, 16 years ago

It appears to be the line: oDisplay = SWFMovie_add(GetCurrentMovie(map, image), oButton);

It works fine like this: SWFMovie_add(GetCurrentMovie(map, image), oButton);

I have been trying to make the change to the end of the msDrawShadeSymbolSWF function. Is there a better location in the code? Here is a code snip from mapswf.c where I have been making my changes:

if (size == 0) {

if (nLayerIndex < 0
nShapeIndex < 0)

{

oShape = DrawShapeFilledPolygon(p, psFillColor, psOutlineColor,

width);

SWFMovie_add(GetCurrentMovie(map, image), oShape);

} else {

oButton = DrawButtonFilledPolygon(p, psFillColor, psOutlineColor,

&sColorHighlightObj, nLayerIndex, nShapeIndex, width);

SWFMovie_add(GetCurrentMovie(map, image), oButton);

oDisplay = SWFMovie_add(GetCurrentMovie(map, image), oButton); SWFDisplayItem_setName(oDisplay, "poly"+nShapeIndex);

}

return;

}

I was using ming 0.3.0, but I downgraded to 0.2.a when I got your earlier message with success using 0.2.a. Also, I am using mapserver 4.10.2, and I just realized mapserver 5 is out. Please let me know if you feel I need to upgrade. RedHat Linux ES 3.0

Thanks again.

comment:11 by assefa, 16 years ago

Is it an issue for you to upgrade to 5.0 ? If not I would suggest upgrading. New enhancements will likly be only available in 5.x releases (please see http://trac.osgeo.org/mapserver/browser/branches/branch-5-0/mapserver/MIGRATION_GUIDE.TXT for some hints).

The changes you are doing msDrawShadeSymbolSWF would allow polygon features to have instances names. Same kind of changes need to be done in function msDrawMarkerSymbolSWF for symbols and msDrawLineSymbolSWF for lines (see mapswf.c in the 5.x svn).

As I mentionned I will try to upgarde to 0.4 in the coming days. I am working on Windows and ming does not provide a ms windows makefiles. I had to do it locally for 0.2 but I had few issues with 0.3. I will probabaly engage the ming communinty on this.

comment:12 by sscottlocinc, 16 years ago

I'm not sure what the issue is, but I was able to compile mapserver 5 from the stable distribution. When I try the nightly-tarball, I get the following error:

./libmapserver.a(mapsymbol.o)(.text+0x2db): In function `msFreeSymbol': : undefined reference to `msFreeSymbolCacheAGG' collect2: ld returned 1 exit status make: * [shp2img] Error 1

I'm sorry to keep this going. Do you know what I need to compile the nightly-tarball source? Thank you for your efforts. Shannon

comment:13 by dringuet, 16 years ago

Cc: dringuet@… added

in reply to:  12 comment:14 by dmorissette, 16 years ago

Shannon, the build issue has been fixed this morning in SVN r6918. You can either patch the code yourself (#ifdef around the msFreeSymbolCacheAGG call in mapsymbol.c), or wait for tomorrow's nightly build which will include the fix.

comment:15 by sscottlocinc, 16 years ago

I got everything to compile. Then I used a decompiler on the swf layer output to create an fla. I opened the fla in Flash and the polygons show up as buttons with instance names ( Thank You ). The strange part now is that when I try to change the color of one polygon to its highlight color - all the polygons change color. I am using this actionscript:

var colorful=new color(this.clip.button1); colorful.setRGB(0x000000);

I get identical beavior ( all polygons change color ) without button1:

var colorful=new color(this.clip); colorful.setRGB(0x000000);

I have also noticed that when I use:

typeof(this.clip.button1);

it says it is a MovieClip - not a button.

Please let me know if you feel this content is no longer appropriate for this thread. Thank you again. Shannon

comment:16 by assefa, 16 years ago

Not sure wht the type is not a button. It uses the function newSWFButton to create it. Could you maybe try the ming mailing list on this ?

comment:17 by pianosnake, 16 years ago

The reason to have names for the buttons is so that the loader swf can reference them with Action Script and change their color, position, etc... This could be done even without having names, because at runtime the Flash player assigns to each movie clip a name if it does not have one. These are called 'instance1', 'instance2', 'instance3' etc... These can be referenced by Action Script.

Unfortunately, the buttons in the SWF output from MapServer can't be referenced by ActionScript at all. Neither with the 'instance1' syntax, nor with the new 'button212', 'button213', etc names that are assigned to the buttons with this fix. I am not sure why this is.

I've created a few Ming movies to test this. Make a simple movie in MING with two buttons. Don't give them names. Then create a Flash movie with two buttons named thebtn, and one called loadming, a blank movie on the stage called swfContainer, and this actionscript which will load ming_output.swf.

var mcLoader:MovieClipLoader = new MovieClipLoader();

thebtn.onRelease = function() {

for (var mcname in swfContainer) {

trace(mcname); if (mcname == "instance2") {

_root.swfContainer[mcname]._x += 10;

}

}

}; loadming.onRelease = function(){ mcLoader.loadClip("ming_output.swf", swfContainer); }

If you load any Ming swf with this script, you'll be able to move 10 pixels to the right anything in that swf called instance2. If you load a MapServer swf you won't be able to do this. _root.swfContainer.instance1 will return a reference to the parent _root.swfContainer

in reply to:  17 comment:18 by pianosnake, 16 years ago

An ZIP file with MING output, non-ming swf, and loader. http://www.actionscript.org/forums/attachment.php3?attachmentid=26800&d=1207686770

comment:19 by dmorissette, 16 years ago

Assefa, what's the status of this ticket, can it be closed?

Ticket #2691 seems to suggest that the button ids are working (except for the fact that there is no way to determine the id which is the topic of #2691).

comment:20 by assefa, 16 years ago

From my understand, It seems to work as indicated in #2691 and the buttons can be accessed using Actionscript. But It does not seem to work for some people and I am not sure what the reason is. I have not investigated further. I will rather leave it open for now and if I have more info close it with appropriate comments.

comment:21 by dmorissette, 16 years ago

Milestone: 5.2 release5.4 release

comment:22 by dmorissette, 16 years ago

I did a web search and it is possible (though I don't understand why) that each button needs to be embedded into its own little clip for the names to work... see this question:

http://osdir.com/ml/web.ming.general/2003-12/msg00032.html

... and the proposed fix:

http://osdir.com/ml/web.ming.general/2003-12/msg00051.html

But before we try try to change MapServer to do that, I wonder if this could be an issue that is fixed in the latest libming 0.4.0rc1 (July 5th 2008).

pianosnake and sscottlocinc: Which version of libming are you using? Could you retest with the latest version?

comment:23 by dmorissette, 16 years ago

Resolution: fixed
Status: assignedclosed

okay, I think I've got a fix that works, committed to SVN trunk in r7842. Now every button is embedded in its own little 1 frame movie clip an we set the name on the clip itself as was suggested in the thread that I found in the last comment above.

I tested with the loader.swf from comment:18 and that works... now if you use MapServer to generate a point symbol with a button named "button214" (not button212 contrary to what the loader's interface suggests) and copy the clip under the name ming_output.swf in the loader.swf's working directory then it will load the MapServer clip and button214 will be shifted by 10 pixels the same way that the non-ming SWF does in the test.

I'm not setup to test with my own ActionScript, but I am confident that this will fix the issues that were reported.

comment:24 by dmorissette, 16 years ago

For the record I was using ming 0.4.0rc1 for my tests.

comment:25 by pianosnake, 16 years ago

I just tested on ming 0.2 with the new mapswf.c and I can now target movie clips with ActionScript from a loader movie. I tried changing colors, moving the clips, rotating and scaling them. All operations worked. Thanks to everyone who worked on this!

Note: See TracTickets for help on using tickets.