WHAT'S NEW?
Loading...

Simple Component Alert As3

Simple Component Alert As3
Simple Component Alert As3

/**class ini bersifat opensource tidak untuk diperjual belikan,
*walaupun demikian kami menghargai jika anda menghargai sumbernya
*------------Ricko Nada www.pustakaflash.com----------------------*
//AlertManager.as
/*import com.PustakaFlash.AlertManager;
bnttes.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");
 // End your custom code

 var message:AlertManager = new AlertManager(this,stage.stageWidth,stage.stageHeight);
 message.alert("Upss Hai Ricko LOrep ipsum bla bla blabla bla.........",300,150,new Point(125,100));
 // Same results as:;
 // tes.alert("This is a test message!", 300, 200, new Point(125,100));
}*/
package com.PustakaFlash
{
 import flash.display.DisplayObjectContainer;
 import flash.display.MovieClip;
 import flash.geom.Point;
 import flash.display.Sprite;
 import flash.text.TextField;
 import flash.events.Event;
 import flash.display.Stage;
 import com.PustakaFlash.WindowAlert;
/*
**####################################
** @author Ricko www.pustakaflash.com
**####################################
*/
 public class AlertManager extends MovieClip
 {
  private var w:Array;
  private var df:DisplayObjectContainer;
  private var i:AlertIcon; 
  private var pW:int;
  private var pH:int;


  public function AlertManager(defaultWindowContainer:DisplayObjectContainer, parentWidth:int, parentHeight:int)
  {
   trace(": AdvAlertManager instance created.");


   df = defaultWindowContainer;
   pW=parentWidth;
   pH=parentHeight;

  }

  public function alert(text:String, width:int, height:int, position:Point = null):void
  {
   trace("Message: " + text);
   trace("Message: " + width);
   i= new AlertIcon();
   var contoh:WindowAlert= new WindowAlert(df,text,width,height,position,i,pW,pH);
   
  }
  

 }
}
//WindowAlert.as
package com.PustakaFlash
{
 import flash.display.*;
 import flash.text.*;
 import flash.events.*;
 import flash.geom.Matrix;
 import flash.geom.Point;
 import flash.filters.*;

/*
**####################################
** @author Ricko www.pustakaflash.com
**####################################
*/
 public class WindowAlert
 {
  private var tg:int;
  private var tf:TextField;
  private var h:TextField;
  private var m:Sprite;
  private var bi:Sprite;
  private var button:Sprite;
  private var i;
  private var df;
  private var n:Boolean;
  private var bl;
  private var sd;
  private var gl;
  private var lb:TextField;

  public function WindowAlert(defaultContainer,text:String,width:int,height:int,position:Point,_i,parentWidth:int,parentHeight:int)
  {
   // constructor code
   bl = new BlurFilter();
   sd = new DropShadowFilter();
   sd.distance = 10;
   sd.color = 0x000000;
   sd.blurX = 10;
   sd.blurY = 10;
   sd.quality = 3;
   gl = new GlowFilter();
   gl.color = 0xFFFF00;
   trace(parentWidth);
   i = _i;
   df = defaultContainer;
   trace(position);
   tg = height;
   tf = new TextField  ;
   h = new TextField  ;
   lb = new TextField  ;
   tf.autoSize = TextFieldAutoSize.LEFT;
   tf.multiline=true;
   tf.wordWrap = true;
   tf.width=width-i.width-50;
   h.htmlText = "<FONT COLOR='#ffffff'><b>Alert...!!</b></FONT>";
   lb.htmlText = "<FONT COLOR='#ffffff'><b>OK</b></FONT>";
   h.x = 15;
   h.y = 15;
   _i.x = h.x;
   _i.y = h.y + 25; 
   tf.htmlText = "<P ALIGN='justify'><FONT COLOR='#ffffff'><b>Pesan :   </b><i>" + text+'</i></FONT></P>';
   tf.x = _i.x + _i.width+20;
   tf.y = 50;
   var a:Array = [0.8,0.3];
   var b:Array = [136,255];
   var c:Array = [0x0033cc,0xffffff];
   var d:* = new Matrix  ;
   new Matrix ().createGradientBox(100,150,150,50,50);
   bi = new Sprite();
   m = new Sprite();
   bi.graphics.lineStyle(1, 0xFF0000, 1);
   bi.graphics.beginFill(0x000000,1);
   bi.graphics.drawRect(0-parentWidth, 0-parentHeight, 4*parentWidth, 4*parentHeight);
   bi.graphics.endFill();
   bi.alpha=.7;
   bl.quality = 3;
   bl.blurX = 10;
   bl.blurY = 10;
   bi.filters = [bl];
   m.graphics.clear();
   m.graphics.beginGradientFill(GradientType.LINEAR,c,a,b,d);
   m.graphics.drawRoundRect(0,0,width,tg,25,25);
   m.graphics.endFill();
   m.graphics.lineStyle(5,0x000000,100);
   m.graphics.drawRoundRect(0,0,width,tg,25,25);
   m.graphics.lineStyle(2,0xFFFFFF,100);
   m.graphics.moveTo(5,h.y + 20);
   m.graphics.lineTo(295,h.y + 20);
   m.graphics.moveTo(5,h.y + 25);
   m.graphics.lineTo(295,h.y + 25);
   m.x = position.x;
   m.y = position.y;
   m.filters = [sd];
   button = new Sprite;
   button.graphics.lineStyle(1,0xFFFFFFF,1);
   button.graphics.beginFill(0x000000,1);
   button.graphics.drawRoundRect(((width - 50) / 2),tg - 50,50,20,5,5);
   button.graphics.endFill();
   lb.x=((width - 50) / 2)+10;
   lb.y=tg - 50;
   button.buttonMode = true;
   button.mouseChildren=false;
   n=true;
   tampil();   
 }
  private function tampil()
  {   
   df.addChild(bi);
   df.addChild(m);
   m.addChild(h);
   m.addChild(tf);
   m.addChild(i);
   m.addChild(button);
   button.addChild(lb);   
   i.filter=[sd];
   button.addEventListener(MouseEvent.CLICK,hilang);
   button.addEventListener(MouseEvent.MOUSE_OVER,dekati);
   button.addEventListener(MouseEvent.MOUSE_OUT,jauhi);
      
  }
  private function dekati(event:MouseEvent=null)
  {   
  button.filters = [gl];
  }
  private function jauhi(event:MouseEvent=null)
  {   
  button.filters = undefined;
  }


  private function hilang(event:MouseEvent=null):void
  {
   df.removeChild(bi);
   df.removeChild(m);
  }


 }

}