Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-22-2007, 03:27 PM   #1
Mulligan
Gullyman
 
Join Date: Feb 2007
Location: California USA
Posts: 8
Question Custom Dialog Component Problems

Hi-
I'm trying to write a dialog component.
So far I am able to draw the dialog window which comes up with
a title bar and is dragable when you click the title bar.
I add a Button which shows up fine with the caption text etcetera.
But when I mouse over, the hand cursor does not appear and when I click on it it does not respond.
Here is my code:
ActionScript Code:
private function MakeDialogItem(mc:MovieClip) {     //mc.myHitArea._yscale=30; mc.hitArea = mc.myHitArea;     mc.onPress = function():Void{         this._parent.xdif=this._parent.getX()-_root._xmouse;         this._parent.ydif=this._parent.getY()-_root._ymouse;         trace("this._parent.xdif= "+this._parent.xdif+"this._parent.ydif= "+this._parent.ydif);                 startDrag(mc);     }     mc.onRelease = function():Void{     stopDrag();     this._parent.createDialog();     //this._parent.arrange();     this._parent.setLocation(_root._xmouse+this._parent.xdif,_root._ymouse+this._parent.ydif);     }         mc.onRollOver = function() {         //this._parent.MakeToolTip(this);     };     mc.onRollOut = function() { //this["tooltip"].removeTextField(); }; //mc._alpha=20; this.onEnterFrame = Delegate.create(this,DrawDialogWindow(mc)); //this.DrawDialogWindow(mc); } //////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////// GETTERS AND SETTERS //////////////////////////////////////////////////////////////////////////////     public function setScale(newXS:Number,newYS:Number){         this.__xscale=newXS;         this.__yscale=newYS;         update();     }     public function getScaleX():Number {         //createListener();         return this.__xscale;     }     public function getScaleY():Number {         //createListener();         return this.__yscale;     }         public function setLocation(nX:Number, nY:Number):Void {       _xscale = __xscale;     _yscale = __yscale;             if(nX!=null){     this.__X = nX;     trace("Setting __X to "+this.__X);     }     if(nY!=null){     this.__Y = nY;     }     update();     arrange();     createDialog();   }     public function getX():Number {     return this.__X;     }     public function setX(newX:Number):Void {         //trace("Setting X: "+newX);         this.__X = newX;         update();         //arrange();     }     public function getY():Number {     return this.__Y;     }     public function setY(newY:Number):Void {         //trace("Setting Y: "+newY);         this.__Y = newY;         update();         //arrange();     }     public function getWidth():Number {     return this.__Width;     }     public function setWidth(newWidth:Number):Void {         //trace("Setting X: "+newX);         this.__Width = newWidth;         update();         //arrange();     }     public function getHeight():Number {     return this.__Height;     }     public function setHeight(newHeight:Number):Void {         //trace("Setting Y: "+newY);         this.__Height = newHeight;         update();         //arrange();     }       public function setSize(nW:Number, nH:Number):Void {     _xscale = 100;     _yscale = 100;     if(nW!=null){     __Width = nW;     }     if(nH!=null){     __Height = nH;     }     arrange();   }   public function setCaption(cap:String){     this.__caption=cap;     trace("Setting Caption to "+this.__caption);     //DrawDialogWindow();   }     public function getCaption():String{     return this.__caption;     //DrawDialogWindow();   }   public function setOKRoutine(routine:String,nP:String){     this.__okroutine=routine;     trace("this.__okroutine= "+this.__okroutine);     this.__okparam = nP;   } public function setOKCaption(okcap:String){   this.__okCaption=okcap; }   public function setTarget(nN:String){       this.__targetInstanceName=nN;         }   public function setFrameColor(nC:Number){       this.__framecolor=nC;       trace("Setting Frame Color to "+this.__framecolor);       createDialog();   }     public function setInsideColor(nC:Number){       this.__insidecolor=nC;       createDialog();   }     public function setCaptionColor(nC:Number){       this.__captioncolor=nC;       createDialog();   }   public function setTextInputParms(w:Number,num:Number):Void{     this.__hasTextInput=true;     this.__TIWidth=w;     this.__NumTexts=num;     createDialog();   } //////////////////////////////////////////////////////////////////////////////////////////////////////////// private function DrawDialogWindow(mc:MovieClip) { //mc.createEmptyMovieClip("DialogWindow", 2000); //createEmptyMovieClip(wclpname, 1499);     var insidex=mc._x+__framewidth;     var insidey=mc._y+__captionheight+__framewidth;     var insidex2 =insidex+ this.__Width-(2*__framewidth);     var insidey2 = insidey+this.__Height-(__captionheight+2*__framewidth);     var Left=mc._x;     var Top=mc._y;     var Width=this.__Width;     var Height=this.__Height;     var fc = this.__framecolor;     var ic = this.__insidecolor;     var txtfmt= new TextFormat();     txtfmt.size = 14;     //txtfmt.rightMargin = 20;     txtfmt.color = this.__captioncolor;     txtfmt.font = "Verdana";     var metrics = txtfmt.getTextExtent(this.getCaption());     var ttw=metrics.textFieldWidth+5;     var tth = metrics.textFieldHeight;        with (mc) {     beginFill(Number(fc), 100);     lineStyle( 2, 0x000000,100 );     moveTo(Left,Top);     lineTo(Left+Width,Top);     lineTo(Left+Width,Top+Height);     lineTo(Left,Top+Height);     lineTo(Left,Top);     endFill();     beginFill(Number(ic), 100);     lineStyle( 2, 0x000000,100 );     moveTo(insidex,insidey);     lineTo(insidex2,insidey);     lineTo(insidex2,insidey2);     lineTo(insidex,insidey2);     lineTo(insidex,insidey);     endFill();     }     mc.removeTextField("textname");     var lev =this.getNextDepth();     depthList.push({DEPTH:lev,TYPE:"T",NAME:"textname"});     mc.createTextField("textname",lev, Left+10,Top+5,ttw,tth);     mc["textname"].border=false;     mc["textname"].html= false;     //mc["textname"].size= 48;     //mc["textname"].textColor = 0xFFFFFF;     mc["textname"].text=this.getCaption();     mc["textname"].setTextFormat(txtfmt);     ////////////////////////////////////////////////////     //this.onEnterFrame = Delegate.create(this,PutUpButtons(mc,insidex,insidex2,insidey,insidey2));     //this.onEnterFrame = Delegate.create(this,PutUpTextFields(mc,insidex+20,insidey+20));     PutUpButtons(mc,insidex,insidex2,insidey,insidey2);     PutUpTextFields(mc,insidex+20,insidey+20); } private function PutUpButtons(mc:MovieClip,x1:Number,x2:Number,y1:Number,y2:Number){     if (this.__okroutine!=null){     if (this.__okroutine.length!=0) {         var lev =this.getNextDepth();         depthList.push({DEPTH:lev,TYPE:"M",NAME:"OKButton"});     this.__ok=mc.createClassObject(mx.controls.Button, "OKButton", lev);     mc["OKButton"]._x=x1+(x2-x1)/2-25;     mc["OKButton"]._y=y1+(y2-y1)-30;     mc["OKButton"].setSize(50,25);     //mc["OKButton"].setStyle("backgroundColor", 0xffffff);     mc["OKButton"].setStyle("themeColor",__insidecolor);     mc["OKButton"].label=this.__okCaption;     mc["OKButton"].setStyle("fontFamily", "Georgia");        mc["OKButton"].setStyle("fontSize", 12);        //  mc["OKButton"].setStyle("borderStyle", "inset");     mc["OKButton"].setEnabled(true); addEventsToButton(mc["OKButton"]); //this.onEnterFrame = Delegate.create(this,addEventsToButton(mc["OKButton"]));         }     } } private function addEventsToButton(mc:Button){     mc.onPress = function():Void{     trace("You pressed!!!");     //this._parent["tttxt"].removeTextField();     if (this._parent.__okroutine!="") {     trace("You pressed OK ROUTINE IS "+this._parent.__okroutine+" PARM IS "+this._parent.__okparam);     this._parent.DoOKRoutine();     //_root[routine](param);     }         };         mc.onRelease = function():Void{             this._parent["tttxt"].removeTextField();             //if(__releaseRoutine!=""){                 //this._parent.DoReleaseRoutine();             //}         }         mc.onReleaseOutside=mc.onRelease;         mc.onRollOver = function():Void{         //if(this._parent.__tooltip!="")         //this._parent.ShowToolTip(this._parent.__tooltip);            }            mc.onRollOut = function():Void{             this._parent["tttxt"].removeTextField();             //if(__rolloutRoutine!=""){                 //this._parent.DoRollOutRoutine();             //}         this._alpha = 0;                     }    }   private function DoOKRoutine():Void {     this._parent[this.__targetInstanceName][this.__okroutine](this.__okparam); } private function PutUpTextFields(mc:MovieClip,tx,ty){     if(__hasTextInput){         var iter;         var topY=ty;         for(iter=0;iter<this.__NumTexts;iter++){             ty=topY+iter*32;             var lev =this.getNextDepth();             depthList.push({DEPTH:lev,TYPE:"T",NAME:"textinput"+iter});         mc.createTextField("textinput"+iter,lev, tx,ty,this.__TIWidth,30);     mc["textinput"+iter].border=true;     mc["textinput"+iter].background=true;     mc["textinput"+iter].backgroundColor=0xFFFFFF;     mc["textinput"+iter].html= false;     mc["textinput"+iter].type="input";     }     }     delete this.onEnterFrame; }   ////////////////////////////////////////////////////////////////////////////////////   private function getNextDepth():Number{     this.depthcount++;     var depth:Number;     depth =Number(this.__base+this.depthcount);     depthList.push(depth);     return depth;   }          //////////////////////////////////////////////////////////////////////////////////// public function Disappear(){     var d;     for(d=0;d<depthList.length;d++){             var name=depthList[d].NAME;             if (name=="")             {                 continue;             }                  switch (depthList[d].TYPE ) {                      case "T": this.__DialogClip[name].removeTextField()break;                      case "M": this.__DialogClip[name].removeMovieClip()break;                     }     }     this.__DialogClip.removeMovieClip(); } }
The Part where I add the button is towards the end...
Does anyone know what I might be doing wrong?
Thanks for reading-Mulligan.

Last edited by Mulligan; 04-24-2007 at 03:55 AM. Reason: Updated code
Mulligan is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference Between Button Component and Creating a New Button Type omnivore ActionScript 2.0 1 04-17-2007 06:54 PM
Loading URL onto a button that is loaded through Loader component with XML amfx Components 0 04-09-2007 10:54 PM
What is the best method for a custom component norfy Components 0 10-15-2005 07:45 AM
Attaching a custom component Webgoblin ActionScript 2.0 1 01-17-2005 10:53 AM
Contacting A Authoring Time Component via its Custom UI.swf Prophet. Components 4 08-26-2004 05:18 PM


All times are GMT. The time now is 10:05 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.