Hello everybody!
What I am trying to achieve is the following thing. I have a textbox and a control extender to the textbox. I have a property called - FadeAnimation which can be true or false. If it is true, the following thing should happen. When the user focuses the textbox, it should change the opacity of the textbox.
It always keeps giving me that the method is not supported at the setTimeout line. Any suggestions?
//run the onfocus function var focus =this.get_element(); var focusDelegate = Function.createDelegate(this,this._onfocus); $addHandler(focus,"onfocus", focusDelegate);this._onfocus(); }, _onfocus : function() {this._opacity(); },//Function to change the opacity _opacity : function() { var id =this.get_element(); var opacStart = 0; var opacEnd = 100; var millisec = 250; var speed = Math.round(millisec / 100);var timer = 0;if(opacStart > opacEnd){for( i = opacStart ; i >= opacEnd ; i--){setTimeout("this._changeOpac(" + i +")", (timer * speed));timer++;}}else if(opacStart < opacEnd){for(i = opacStart; i <= opacEnd; i++){setTimeout("this._changeOpac(" + i +")", (timer * speed));timer++;}} }, _changeOpac : function(opacity) { varobject =this.get_element().style;object.background ='#FFFF99';object.opacity = (opacity / 100);object.MozOpacity = (opacity / 100);object.KhtmlOpacity = (opacity / 100);object.filter ="alpha(opacity=" + opacity +")"; },// TODO: (Step 2) Add your property accessors here get_FadeAnimationProperty : function() {return this._FadeAnimationPropertyValue; }, set_FadeAnimationProperty : function(value) {this._FadeAnimationPropertyValue =value; }try window.setTimeout()
I'm not a Javascript guru by any means, but i think that your problem is that with this line
setTimeout("this._changeOpac(" + i +")", (timer * speed));
you lose, hmmm not sure if this is the right term to use, "context" of the object "this" as the event isn't raisedwithin
No comments:
Post a Comment