Question : How do I deactivate a Flash button once it is pressed - make it unclickable?

Hello

I have a Flash button HELP that works by opening a help box called service_mc.help_btn

But if clicked twice it will open the box twice. And I can only get rid of one box. How do I restrict the button to one click and then only have it active again once the box is closed.

http://alt.coxnewsweb.com/palmbeachpost/multimedia/pbstyle_fall08/PalmBeachStyle_1.html

See the entire code below.

Thanks
S
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
stop();
myBook._visible = true;
 
 
var zoomRatios = [2,3,4,5];
var zoomed = false;
var zoomCount = 0;
 
navbar_mc.index_btn.onPress = gotoPage;
navbar_mc.next_btn.onPress = nextPage;
navbar_mc.prev_btn.onPress = prevPage;
 
 
zoom_mc.zoom_in_btn.onPress = openZoom;
zoom_mc.zoom_out_btn.onPress = closeZoom;
zoom_mc.zoom_out_btn._visible = false;
 
service_mc.help_btn.onPress = openInfoWindow;
service_mc.print_left_btn.onPress = printLeftPage;
service_mc.print_right_btn.onPress = printRightPage;
 
myBook.onPageLoad = function( pageURL, pageNumber ){
if( pageNumber == 0 )this.flipCorner("top-right");
}
 
myBook.onStartFlip = function(i) {
	if (i == undefined) {
		return;
	}
	myBook.flipOnClickProp = true;
	showHint();
};
myBook.onFlipBack = function() {
	myBook.flipOnClickProp = false;
	hideHint();
};
myBook.onClick = function(i, page, isCorner) {
	hideHint();
};
myBook.onPutPage = function() {
	myBook.flipOnClickProp = false;
	var res = "";
	if (this.leftPageNumber && this.rightPageNumber) {
		res = this.leftPageNumber+" / "+this.rightPageNumber;
	} else if (this.rightPageNumber == 0) {
		res = this.rightPageNumber;
	} else if (this.leftPageNumber && !this.rightPageNumber) {
		res = this.leftPageNumber;
	}
	navbar_mc.current_page_txt.text = res;
};
 
function sendData(){
       	var sender:LoadVars = new LoadVars();
		//sender.sendAndLoad("http://ad.doubleclick.net/clk;201954821;9066607;j?",sender,"GET");
		
}
 
function nextPage() {
      if( zoomed )return;
      myBook.flipForward();
      //sendData ("http://ad.doubleclick.net/clk;201954821;9066607;j?");
}
function prevPage() {
      if( zoomed )return;      
      myBook.flipBack();
      //sendData ("http://ad.doubleclick.net/clk;201954819;9066607;q?");
}
function gotoPage() {
      if( zoomed )return;      
      myBook.flipGotoPage( 0 );
      //sendData ("http://ad.doubleclick.net/clk;201954818;9066607;p?");
}
 
function startZoomingMode() {
	zoomed = !zoomed;
	if (zoomed) {
		Mouse.hide();
		myBook.enabledProp = false;
		_root.attachMovie("ZoomPointer", "zoom_pointer_mc", 100);
		zoom_pointer_mc._x = _xmouse;
		zoom_pointer_mc._y = _ymouse;
		zoom_pointer_mc.onMouseMove = function() {
			this._x = _xmouse;
			this._y = _ymouse;
		};
	} else {
		Mouse.show();
		myBook.enabledProp = true;
		zoom_pointer_mc.removeMovieClip();
	}
}
function openInfoWindow() {
	myBook.enabledProp = false;
	_root.attachMovie("InfoWindow", "info_mc", _root.getNextHighestDepth());
	info_mc._x = Stage.width/2-info_mc._width/2;
	info_mc._y = Stage.height/2-info_mc._height/2;
	info_mc.close_btn.onRelease = closeInfoWindow;
}
function closeInfoWindow() {
	myBook.enabledProp = true;
	info_mc.removeMovieClip();
}
 
function printLeftPage() {
	print_box.printIt(myBook.leftPageNumber, myBook);
}
function printRightPage() {
	print_box.printIt(myBook.rightPageNumber, myBook);
}
 
/*function showHint() {
	_root.attachMovie("Hint", "hint_mc", 215);
	hint_mc._x = _xmouse;
	hint_mc._y = _ymouse;
	if( (hint_mc._y + hint_mc._height) > Stage.height )hint_mc._y -= ((hint_mc._y + hint_mc._height)-Stage.height + 10);
	if( (hint_mc._x + hint_mc._width) > Stage.width )hint_mc._x -= ((hint_mc._x + hint_mc._width)-Stage.width + 10);
 
	hint_mc.onMouseMove = moveHint;
	Mouse.hide();
}
function moveHint(){
	this._x = _xmouse;
	this._y = _ymouse;
	
	if( (this._y + this._height) > Stage.height )this._y -= ((this._y + this._height)-Stage.height + 10);
	if( (this._x + this._width) > Stage.width )this._x -= ((this._x + this._width)-Stage.width + 10);
};	
 
function hideHint() {
	hint_mc.onMouseMove = undefined;
	hint_mc.removeMovieClip();
	Mouse.show();
}*/
 
function openZoom(){
	myBook.enabledProp = false;
	var ratio = zoomRatios[zoomCount++];
	if( zoomRatios[zoomCount+1] == undefined )
		zoom_mc.zoom_in_btn._visible = false;
	else
		zoom_mc.zoom_in_btn._visible = true;
		
	if(!zoomed)	{
		ow = myBook._bookWidth;
		oh = myBook._bookHeight;
		drawZoomMask();	
		cx = myBook._x;
		cy = myBook._y;
	}
	
	myBook.setSize(ow * ratio, oh * ratio);
	
	var left = cx-myBook._bookWidth/2 + ow/2;
	var top = cy-myBook._bookHeight/2 + oh/2;
	var right = cx+myBook._bookWidth/2 - ow/2;
	var bottom = cy+myBook._bookHeight/2 - oh/2;
	
	mask_mc.onMouseDown = function(){myBook.startDrag(false, left, top, right,bottom);};
	mask_mc.onMouseUp = function(){myBook.stopDrag();};	
	mask_mc.onRollOver = function(){};
	
	zoomed = true;
	zoom_mc.zoom_out_btn._visible = true;
}
 
function closeZoom(){
	if(!zoomed)return;
	if(zoomCount > 1){
		zoomCount-=2;
		openZoom();
		return;
	}
	
	myBook.enabledProp = true;
	myBook.setSize(ow, oh);
	myBook._x = cx;
	myBook._y = cy;
	myBook.setMask(null);
	mask_mc.removeMovieClip();
	myBook.stopDrag();
	mask_mc.onMouseDown = undefined;
	mask_mc.onMouseUp = undefined;
	zoomed = false;
	zoomCount = 0;
	zoom_mc.zoom_out_btn._visible = false;
	zoom_mc.zoom_in_btn._visible = true;
}
 
 
function drawZoomMask(){
	var cx = myBook._x;
	var cy = myBook._y;
	
	var x0 = cx - ow/2;
	var y0 = cy - oh/2;
	var x1 = cx + ow/2;
	var y1 = cy + oh/2;
 
	_root.createEmptyMovieClip( "mask_mc", 2000 );
	mask_mc.lineStyle();
	mask_mc.beginFill( 0, 100 );
	mask_mc.moveTo( x0, y0 );
	mask_mc.lineTo( x1, y0 );
	mask_mc.lineTo( x1, y1 );	
	mask_mc.lineTo( x0, y1 );	
	mask_mc.lineTo( x0, y0 );	
	mask_mc.endFill();
	
	myBook.setMask( mask_mc);
}
Open in New Window Select All

Answer : How do I deactivate a Flash button once it is pressed - make it unclickable?

A co worker came up with a elegant solution. Thanks Dennis!

Here is the new code to make the click once and then reset to 0

var clk = 0;

function openInfoWindow() {
      clk = clk+1;
      trace("clk="+clk);
      myBook.enabledProp = false;
      if (clk==1) {
            _root.attachMovie("InfoWindow","info_mc",_root.getNextHighestDepth());
      }
      info_mc._x = Stage.width/2-info_mc._width/2;
      info_mc._y = Stage.height/2-info_mc._height/2;
      info_mc.close_btn.onRelease = closeInfoWindow;
}
function closeInfoWindow() {
      clk = 0;
      myBook.enabledProp = true;
      info_mc.removeMovieClip();
}


Thanks
S

Random Solutions  
 
programming4us programming4us