Select to view content in your preferred language

Creating sequential text symbols using Flex

717
5
02-14-2011 08:44 AM
JayGregory
New Contributor III
Hi all
What I thought would be a simple problem is turning out not to be.  I'm interested in creating different text symbols for a point layer, each text representing the order of a stop on a network.  At first I used the following actionscript code:
var stopNum:TextSymbol = new TextSymbol(null, null, 0x000000, false,0x000000,false,0x000000,"middle",0,0,0);
var stopFormat:TextFormat = new TextFormat();
stopFormat.size="15";
stopFormat.font="Verdana";
stopFormat.bold="true";
stopNum.textFormat=stopFormat;
for (var i:int=0; i<=stopSet.features.length; i++){
        stopNum.text=i.toString();
stopSet.features.symbol = stopNum as Symbol;
stopLayer.add(stopSet.features);
}   

However, this sets all the symbols to the be the highest number.  So I guess a GraphicsLayer can only have one symbol unless I use a unique renderer.  My question is how would I create a unique renderer based on the stopSet.features.symbol.text attribute?  I've looked through some examples but am stumped. 

Would I need to create an array, populating it with each text symbol up to the maximum number of stops I would expect.  How would I then reference in ActionScript how to choose the correct symbol in each array without having a different line for say 1 through 100?

Any assistance here would be helpful, as I am pretty new to this API.
Thanks!

Jay
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Jay,

   Take a look at my route widget. It does similar to what you are looking for. You can find your answer in the source code that is included and have an example would be a lot easier than trying to explain it.

http://www.arcgis.com/home/item.html?id=992b1f691f44489aa4dcbafe2db66700
0 Kudos
JayGregory
New Contributor III
Robert, thanks very much for your post - sorry I didn't have a chance to respond earlier.  Being new to ActionScript, the Flex API and this stuff in general, I was hoping you could give me a hint of where to look in your widget to find the code I'm looking for (e.g. which mxml files, which functions or graphics layers).  I took a look around but nothing jumped out at me (probably due to inexperience) so was hoping for a push in the right direction. 

Thanks!

Jay


Jay,

   Take a look at my route widget. It does similar to what you are looking for. You can find your answer in the source code that is included and have an example would be a lot easier than trying to explain it.

http://www.arcgis.com/home/item.html?id=992b1f691f44489aa4dcbafe2db66700
0 Kudos
JayGregory
New Contributor III
Sorry - let me be more specific.  I took a look at your code, the promoteStop function as well as the graphicsLayer declarations, and I still couldn't figure it out.  You specified a composite symbol, but otherwise don't make a unique value renderer (that I could see) to display different numbers for each stop on the same graphics layer.  Is there something else I'm missing?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jay

    I just add a number during the loop in one place and I handle it very differently in other places but this is the simplest.

var rsNum:int = 1;
var textSym:TextSymbol = new TextSymbol(rsNum.toString());
rsNum++;
0 Kudos
JayGregory
New Contributor III
Thank you so much - I was able to get it working correctly with your assistance. 

Jay

    I just add a number during the loop in one place and I handle it very differently in other places but this is the simplest.

var rsNum:int = 1;
var textSym:TextSymbol = new TextSymbol(rsNum.toString());
rsNum++;
0 Kudos