<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
height="100%"
width="100%">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import script.ExtendToolTip;
[Bindable]
public var dp:ArrayCollection=new ArrayCollection();
[Bindable]
public var myArray:Array=[1, 2, 3, 4];
[Embed("//assets/images/ic_appo_cal.png")]
[Bindable]
public var patient_photo:Class;
private function createTip(tip:String):ExtendToolTip
{
var imageToolTip:ExtendToolTip=new ExtendToolTip();
//for embeded image
imageToolTip.ImageTip=imgPatient.source;
//for external image
//imageToolTip.ImageTip = "http://l.yimg.com/t/img/new_in_fp_logo.gif";
imageToolTip.TipText=tip;
return imageToolTip;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox height="100%" width="100%">
<mx:HBox height="50%" width="50%">
<s:Image id="imgPatient"
source="{patient_photo}" width="100" height="100"
toolTip="anna"
toolTipCreate="event.toolTip=this.createTip(event.currentTarget.toolTip)" />
<s:Label text="anna"/>
</mx:HBox>
</mx:VBox>
</s:Application>
===========================
ExtendToolTip.as
package script
{
import flash.display.Bitmap;
import mx.containers.*;
import mx.controls.Alert;
import mx.controls.Label;
import mx.core.*;
import spark.components.Image;
public class ExtendToolTip extends VBox implements IToolTip
{
private var image:Bitmap = new Bitmap();
private var lbl:Label;
private var imageHolder:Image;
private var tipText:String;
[Bindable]
public function set ImageTip(img:*):void{
if(img is Class){
imageHolder.source = img;
}
if(img is Object){
imageHolder.source = img;
}
if(img as String){
imageHolder.source=img;
}
}
[Bindable]
public function set TipText(txt:String):void{
lbl.text = txt;
}
public function get TipText():String{
return tipText;
}
public function ExtendToolTip()
{
mouseEnabled = false;
mouseChildren = false;
setStyle("percentWidth",50);
setStyle("percentHeight",50);
setStyle("paddingLeft",10);
setStyle("paddingRight",10);
setStyle("paddingTop",10);
setStyle("paddingBottom",10);
setStyle("backgroundAlpha",0.5);
setStyle("backgroundColor",0xffffff);
imageHolder = new Image();
lbl = new Label();
lbl.setStyle("color",0x0B0B61);
lbl.setStyle("fontWeight","bold");
lbl.setStyle("fontSize",18);
imageHolder.source = image;
addChild(imageHolder);
addChild(lbl);
}
public function get text():String
{
return null;
}
[Bindable]
public function set text(value:String):void {
tipText = value;
}
}
}
No comments:
Post a Comment