binding with prototype

Discussion in 'JavaScript' started by Sleeping Troll, May 22, 2009.

  1. #1
    I am new to prototype, thought it would be easiest way to accomplish cross browser compatibility... but alas, syntax escapes me in binding! Heeeeres... my code!
    function OrbCreator(){
    	var b = new Element('img',{src: '../images/Orb.png', position: 'absolute', display: 'none', left: '10000px', top: '0px', width: '100px', height: '100px', zIndex: '0'});
    	$('container').insert(b);
    	this.set=setAttribute(b,);
    }
     
    function moveOrb(x,y,z){
    	left=x-Os;
    	top=y-Os;
    	zIndex=z;
    	height=Os;
    	width=Os;
    	opacity=1/z;
    	display='block';
    	[COLOR="Red"]this.set=display:display,left:left,top:top,width:width,height:height,zIndex:zIndex,opacity:opacity;[/COLOR]
    	if(renew=2){
    		this.set({src:"../images/NewImage.png"});
    	}
    	if($('message').getStyle('top')>0){
     		writeAttribute("message",{top: top++})
    	}
    }
    Code (markup):
    So slap me silly and call me names, but what am I doing wrong and please, very importantly... why is it wrong and what is right, why?
     
    Sleeping Troll, May 22, 2009 IP
  2. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Having a little success with this code:
    function OrbCreator(){
    	var b = new Element('img',{src: '../images/Orb.png', position: 'absolute', display: 'none', left: '10000px', top: '0px', width: '100px', height: '100px', zIndex: '0'});
    	$('container').insert(b);
    	this.img=b;
    	this.move=moveOrb;
    }
     
    function moveOrb(x,y,z){
    	Left=x-Os;
    	Top=y-Os;
    	ZIndex=z;
    	Height=Os;
    	Width=Os;
    	Opacity=1/z;
    	Display='block';
    	this.img.setAttribute(this.img,{display:Display,left:Left,top:Top,width:Width,height:Height,zIndex:ZIndex,opacity:Opacity});
    	if(renew=2){
    		this.img.setAttribute({src:"../images/NewImage.png"});
    	}
    	if($('message').getStyle('top')>0){
     		writeAttribute("message",{top: top++})
    	}
    }
    Code (markup):
    firebug error is "String contains an invalid character" code: "5
    [Break on this error] this.img.setAttribute(this.img,{display...:Height,zIndex:ZIndex,opacity:Opacity});"
     
    Sleeping Troll, May 22, 2009 IP