[flexcoders] Re: Why cant I use mouseOver() in Image class, but using mx:Image tag, I can?

2009-02-20 Thread yossi.baram
Hi Nate,
Thanks, it works
But I have one problem,
How can I show seperate details for each of the images?
rememver I have one cell that includes several images side by side 
drawn from the loop bellow, and each one need to popup different data 
on a tooltip.


private var tooltipData:String;
override public function set data(value:Object):void {

if (value != null)
 {
removeAllChildren();
for (var i:int = 0; i  value.hair.length; i++){
var img:Image = new Image();  
img.source = value.hair[i].image;  
tooltipData = image -  +i; 
img.percentWidth=value.hair[i].width;   
img.maintainAspectRatio=false;
img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, 
tooltipDetailCreate);
addChild(img); 
} 
}
}

private function tooltipDetailCreate(event:ToolTipEvent):void { 
var tt:PanelToolTip  = new PanelToolTip(); 
tt.width  = 190; 
tt.height = 100;
tt.bodyText = tooltipData;  
event.toolTip = tt; 
} 


and my PanelToolTip:

?xml version=1.0 encoding=utf-8?
mx:Panel xmlns:mx=http://www.adobe.com/2006/mxml; 
implements=mx.core.IToolTip
width=200 alpha=.8 borderThickness=2 
backgroundColor=white 
dropShadowEnabled=true borderColor=black borderStyle=solid
shadowDistance=10 shadowDirection=right
mx:Script
![CDATA[
[Bindable]
public var bodyText:String = ;


public var _text:String;

public function get text():String {
return _text;
}
public function set text(value:String):void {
}
]]
/mx:Script

mx:Text text={bodyText} percentWidth=100/

/mx:Panel

The result I'm getting now is that I see a tooltip for each of the 
images but with the same data (tooltipData = the last iteration of the 
loop).
How can I set a different data for each of the images.

Thanks a lot for the help :)

Jo 
--- In flexcoders@yahoogroups.com, Nathaniel Skiba nate.sk...@... 
wrote:

 toolTipCreate is an event, so when using AS, you have to use the
 addEventListener function. The following should help:
 
 img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, myHandlerFunction);
 
 Just remember that you have to import ToolTipEvent, and
 myHandlerFunction has to be a function that takes one argument which 
is
 a ToolTipEvent.
 
 ~Nate





[flexcoders] Re: Why cant I use mouseOver() in Image class, but using mx:Image tag, I can?

2009-02-20 Thread yossi.baram
I think that I need to create a new panel for each image,
let say if I have 3 images in one cell and the event is fired, 
now I get one panel for all with the same data and its not good for 
me, i need 3 panels with different data, 
How do I do it??
Can it be done?

Thanks again

Jo

--- In flexcoders@yahoogroups.com, yossi.baram yossi.ba...@... 
wrote:

 Hi Nate,
 Thanks, it works
 But I have one problem,
 How can I show seperate details for each of the images?
 rememver I have one cell that includes several images side by side 
 drawn from the loop bellow, and each one need to popup different 
data 
 on a tooltip.
 
 
 private var tooltipData:String;
 override public function set data(value:Object):void {
   
 if (value != null)
  {
   removeAllChildren();
   for (var i:int = 0; i  value.hair.length; i++){
   var img:Image = new Image();  
   img.source = value.hair[i].image;  
   tooltipData = image -  +i; 
   img.percentWidth=value.hair[i].width;   

   img.maintainAspectRatio=false;
   img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, 
 tooltipDetailCreate);
   addChild(img); 
   } 
   }
 }
 
 private function tooltipDetailCreate(event:ToolTipEvent):void { 
   var tt:PanelToolTip  = new PanelToolTip(); 
   tt.width  = 190; 
   tt.height = 100;
   tt.bodyText = tooltipData;  
   event.toolTip = tt; 
 } 
 
 
 and my PanelToolTip:
 
 ?xml version=1.0 encoding=utf-8?
 mx:Panel xmlns:mx=http://www.adobe.com/2006/mxml; 
 implements=mx.core.IToolTip
   width=200 alpha=.8 borderThickness=2 
 backgroundColor=white 
   dropShadowEnabled=true borderColor=black 
borderStyle=solid
   shadowDistance=10 shadowDirection=right
   mx:Script
   ![CDATA[
   [Bindable]
   public var bodyText:String = ;
   
   
   public var _text:String;
   
   public function get text():String {
   return _text;
   }
   public function set text(value:String):void {
   }
   ]]
   /mx:Script
 
   mx:Text text={bodyText} percentWidth=100/
 
 /mx:Panel
 
 The result I'm getting now is that I see a tooltip for each of the 
 images but with the same data (tooltipData = the last iteration of 
the 
 loop).
 How can I set a different data for each of the images.
 
 Thanks a lot for the help :)
 
 Jo 
 --- In flexcoders@yahoogroups.com, Nathaniel Skiba nate.skiba@ 
 wrote:
 
  toolTipCreate is an event, so when using AS, you have to use the
  addEventListener function. The following should help:
  
  img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, 
myHandlerFunction);
  
  Just remember that you have to import ToolTipEvent, and
  myHandlerFunction has to be a function that takes one argument 
which 
 is
  a ToolTipEvent.
  
  ~Nate
 





[flexcoders] Re: Why cant I use mouseOver() in Image class, but using mx:Image tag, I can?

2009-02-20 Thread yossi.baram
well, i managed doing that :)
Using one panel, I use the currentTarget object of the evevnt allows 
me to retrieve the dataPorvider elements

private function tooltipDetailCreate(event:ToolTipEvent):void { 
var tt:PanelToolTip  = new PanelToolTip();
var innerImage:Object = event.currentTarget; 
tt.width  = 190; 
tt.height = 100; 
tt.bodyText = image source:  + innerImage.source; 
event.toolTip = tt; 
} 

It looks great.
Now I have (of course) one more question.
Every image need to have a unique Key/Value elements in a hashMap.
I know Java but rather new in Flex,
How can I set a hashMap into my ArrayCollection dp?
and what is the attribute I need to set in my panel in order to see 
it in my tooltip?

Thanks again

Jo

--- In flexcoders@yahoogroups.com, yossi.baram yossi.ba...@... 
wrote:

 I think that I need to create a new panel for each image,
 let say if I have 3 images in one cell and the event is fired, 
 now I get one panel for all with the same data and its not good for 
 me, i need 3 panels with different data, 
 How do I do it??
 Can it be done?
 
 Thanks again
 
 Jo
 
 --- In flexcoders@yahoogroups.com, yossi.baram yossi.baram@ 
 wrote:
 
  Hi Nate,
  Thanks, it works
  But I have one problem,
  How can I show seperate details for each of the images?
  rememver I have one cell that includes several images side by 
side 
  drawn from the loop bellow, and each one need to popup different 
 data 
  on a tooltip.
  
  
  private var tooltipData:String;
  override public function set data(value:Object):void {
  
  if (value != null)
   {
  removeAllChildren();
  for (var i:int = 0; i  value.hair.length; i++){
  var img:Image = new Image();  
  img.source = value.hair[i].image;  
  tooltipData = image -  +i; 
  img.percentWidth=value.hair[i].width;   
   
  img.maintainAspectRatio=false;
  img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, 
  tooltipDetailCreate);
  addChild(img); 
  } 
  }
  }
  
  private function tooltipDetailCreate(event:ToolTipEvent):void { 
  var tt:PanelToolTip  = new PanelToolTip(); 
  tt.width  = 190; 
  tt.height = 100;
  tt.bodyText = tooltipData;  
  event.toolTip = tt; 
  } 
  
  
  and my PanelToolTip:
  
  ?xml version=1.0 encoding=utf-8?
  mx:Panel xmlns:mx=http://www.adobe.com/2006/mxml; 
  implements=mx.core.IToolTip
  width=200 alpha=.8 borderThickness=2 
  backgroundColor=white 
  dropShadowEnabled=true borderColor=black 
 borderStyle=solid
  shadowDistance=10 shadowDirection=right
  mx:Script
  ![CDATA[
  [Bindable]
  public var bodyText:String = ;
  
  
  public var _text:String;
  
  public function get text():String {
  return _text;
  }
  public function set text(value:String):void {
  }
  ]]
  /mx:Script
  
  mx:Text text={bodyText} percentWidth=100/
  
  /mx:Panel
  
  The result I'm getting now is that I see a tooltip for each of 
the 
  images but with the same data (tooltipData = the last iteration 
of 
 the 
  loop).
  How can I set a different data for each of the images.
  
  Thanks a lot for the help :)
  
  Jo 
  --- In flexcoders@yahoogroups.com, Nathaniel Skiba nate.skiba@ 
  wrote:
  
   toolTipCreate is an event, so when using AS, you have to use the
   addEventListener function. The following should help:
   
   img.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, 
 myHandlerFunction);
   
   Just remember that you have to import ToolTipEvent, and
   myHandlerFunction has to be a function that takes one argument 
 which 
  is
   a ToolTipEvent.
   
   ~Nate
  
 





Re: [flexcoders] Re: Why cant I use mouseOver() in Image class, but using mx:Image tag, I can?

2009-02-20 Thread Nathaniel Skiba
Ah, so that's what you were wanting to do. AFAIK, the tool tip for the
class can't be substituted. What you should probably do instead is to
turn off the tooltips, use the mouse over (or roll over) event, and when
you detect mouse over, use the PopUpManager to show your custom component.

~Nate