Select to view content in your preferred language

Adding Tooltip with FeatureSet loop only displaying last tooltip in loop

487
3
Jump to solution
12-17-2012 11:02 AM
eddiequinlan
Deactivated User
Crazy!!!

I have the following basic loop shown below, which loops thru the featureSet adding the graphic and tooltip.  I currently use the same loop in other areas of my application with no problems.  This loop correctly adds my graphic to the graphic layer, but will only add the last tooltip variable in the loop as a tooltip to all the graphics in the loop.

AQ.where = SrchString;
       
Sub_QueryTask.execute(AQ, new AsyncResponder(subResult, subFault));
       
function subResult(featureSet:FeatureSet, token:Object = null ):void{
      if (featureSet.features.length > 0){
for each (var myGraphic:Graphic in featureSet.features){      
    
             //myGraphic.autoMoveToTop=true;
var RandomColor:uint = 0xffffff * Math.random();
var RandomFill:SimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, RandomColor, 0.5); 
             myGraphic.symbol = RandomFill;
Sub_Gra_Layer.toolTip = myGraphic.attributes.PATSUB_SUB_KEY;
Sub_Gra_Layer.add(myGraphic);

             trace(Sub_Gra_Layer.toolTip.toString());
      }

While debugging, I can see the correct tooltip values being looped thru but only the last one gets displayed on the map.
The only difference from this loop vs others in my app, is that I'm binding the Sub_Gra_Layer to a graphics layer in the parent app.  It doesn't appear to be a problem, because the graphics are being added correctly and one tooltip is being added; Therefore, I'm assumning the binding is ok.  I've also replaced the Sub_Gra_Layer variable with the main app graphic layer......

FlexGlobals.topLevelApplication.myGraphicsLayer

Any Ideas????????
thanx,
Eddie
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
Set the graphic's tooltip, not the layer's tooltip

myGraphic.toolTip = myGraphic.attributes.PATSUB_SUB_KEY;
Sub_Gra_Layer.add(myGraphic);

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
Set the graphic's tooltip, not the layer's tooltip

myGraphic.toolTip = myGraphic.attributes.PATSUB_SUB_KEY;
Sub_Gra_Layer.add(myGraphic);
0 Kudos
eddiequinlan
Deactivated User
Doh!!!!!

I feel like such an idiot.  I knew it was something simple I was overlooking. 
Thanks Ken for the extra set of eyes!

Sincerely,
Eddie Q.
0 Kudos
KenBuja
MVP Esteemed Contributor
Glad to help! Don't forget to mark the question as answered.
0 Kudos