(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-18-24 01:34 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Java script problem New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Sukotto

Mini Octorok


 





Since: 10-09-06
From: New Orleans

Last post: 6409 days
Last view: 6409 days
Posted on 10-30-06 11:07 AM Link | Quote
Having a problem with a slider object i'm creating.


function slider(){

this.max=100;
this.min=0;
this.multiplyer=1;
this.relativePosition=this.max*this.multiplyer;
this.oldMouseX;
this.oldMouseY;
this.knobTrack = document.createElement('div');
this.knob = document.createElement('div');
this.knobTrack.appendChild(this.knob);
document.body.appendChild(this.knobTrack);

this.percent = document.createElement('div');
}

slider.prototype.max;
slider.prototype.min;
slider.prototype.multiplyer;
slider.prototype.relativePosition;
slider.prototype.oldMouseX;
slider.prototype.oldMouseY;
slider.prototype.knobTrack;
slider.prototype.knob;

slider.prototype.renderSlider = function(){

this.knobTrack.style.fontSize="10px";
this.knobTrack.style.height="10px";
this.knobTrack.style.width="122px";
this.knobTrack.style.position="absolute";
this.knobTrack.style.border="1px solid #000000";
this.knobTrack.style.backgroundColor="CCCCCC";

this.knob.style.fontSize="10px";
this.knob.style.height="10px";
this.knob.style.width="20px";
this.knob.style.position="relative";
this.knob.style.backgroundColor="#CCCCCC";
this.knob.style.borderLeft="2px solid #EEEEEE";
this.knob.style.borderTop="2px solid #EEEEEE";
this.knob.style.borderRight="2px solid #444444";
this.knob.style.borderBottom="2px solid #444444";
//this.knob.onmouseout=this.makeUnDraggable;
this.knob.onmouseup=this.makeUnDraggable;
this.knob.onmousedown=this.makeDraggable;
}

slider.prototype.makeDraggable = function(){
this.oldMouseX=event.clientX;
//alert("entered makeDraggable");
this.knob.onmouseup=this.makeUnDraggable;
this.knob.onmouseout=this.makeUnDraggable;
this.knob.onmousemove=this.moveSlider;
}

slider.prototype.makeUnDraggable = function(){
//alert("Entereing makeundraggable");
this.knob.onmousemove = null;
this.knob.onmouseup = null;
}

slider.prototype.moveSlider = function(){
this.knob.style.position = "relative";
this.relativePosition=event.srcElement.offsetLeft+event.clientX-this.oldMouseX;
this.oldMouseX=event.clientX;
stat= this.knob.className + " width: " + this.knob.clientWidth;
stat= stat + "; Mouse location: " + event.clientX;
window.status=stat;
if (this.relativePosition >= this.max*this.multiplyer){
this.relativePosition = this.max*this.multiplyer;
}
else if (this.relativePosition <= this.min){
this.relativePosition = this.min;
}

this.knob.style.left=this.relativePosition;
this.percent.innerHTML = this.relativePosition/this.multiplyer + "%";
}



i get an error on slider.prototype.makeUnDraggable that says this.knob is not an object is not found or null.

any help is greatly appreciated.
rubixcuber

Mole








Since: 09-08-06
From: St. Louis, MO

Last post: 6407 days
Last view: 6407 days
Posted on 10-31-06 12:14 PM Link | Quote
My guess is that the makeUnDraggable function is getting called before the slider function and thus is trying to access an object before it gets initialized with the "this.knob = document.createElement('div');" line. You could try making sure that makeUnDraggable isn't called before slider or add a check for knob being null and calll createElement it if it is. The first one is the more correct solution though. The null check is more of a hack. If you just check for null you'll probably want to change slider to only call createElement if knob is null.

Hope that helps some.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Java script problem |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.004 seconds; used 356.98 kB (max 420.65 kB)