<?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"
               width="399" height="200" minWidth="955" minHeight="600"
               viewSourceURL="/examples/tooltip/srcview/index.html">
    
    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";
        
        mx|ToolTip { 
            borderSkin:ClassReference("skin.ToolTipBorderExtended"); 
            color: #ffffff; 
            fontSize: 10; 
            fontWeight: "bold"; 
            shadowColor: #000000; 
            borderColor: #CE2929;  
            paddingBottom: 4; 
            paddingLeft: 4; 
            paddingRight: 4;  
            paddingTop: 4;     
        } 
        
    </fx:Style>
    
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.controls.ToolTip;
            import mx.managers.ToolTipManager;
            
            private var errorTip:ToolTip;
            
            [Bindable]public var minOrder:int = 10;
            
            protected function addToCart():void
            {
                if(validateMinOrder(minOrder))
                    Alert.show(ns.value.toString() + " Items Added to Cart"); 
            }
            
            protected function validateMinOrder(value:int):Boolean
            {
                if (errorTip)
                {
                    ToolTipManager.destroyToolTip(errorTip);
                    errorTip = null;
                }
                
                if(ns.value < value)
                {
                    errorTip =  ToolTipManager.createToolTip("Minimum order is " + this.minOrder + " units.", ns.x, ns.y-3, "errorTipLeft",ns) as ToolTip; 
                    errorTip.x -= errorTip.width + 10 ;
                    
                    return false;
                }
                else
                {
                    return true;
                }
            }
            
            
        ]]>
    </fx:Script>
    
    <s:NumericStepper id="ns" left="261" top="56" change="validateMinOrder(minOrder)" maximum="10000" minimum="1" stepSize="1" value="8"/>
    <s:Button left="262" top="104" label="Add to Cart" click="addToCart()"/>
    
</s:Application>