Super noob question

I know nothing about css or dhtml.
Can some one write a page for me with an image that moves 10 pixels right every time you rollover it? I don’t care if it doesnt work in netscape.

Hrmm, this isn’t a super noob question :stuck_out_tongue:

Ok, I dabbled in DHTML a bit, but I super suck at it. I will give this a whirl anyway.

First we will have to do the CSS side. Since will will be dynamically positioning your object we will need to set the position to absolute, and apply any other CSS coding you need, but right now let’s just stick with what we need…

This goes between the HEAD tags.

<STYLE TYPE="text/css">
<!--
.jumpDiv {position: absolute;};
-->
</STYLE>

Right after that (still in between the HEAD tags) we need to do that Javascript side that allows us to adjust the position of the clip.

<SCRIPT LANGUAGE="JavaScript">
<!--
function bump(clipID, jump) {	
	document.all[clipID].style.pixelLeft += jump;
}
-->
</SCRIPT>

This in theory should check the document for your clipID target (I will explain this later) and set its pixels from the left distance to currentPosition+jump parameter (in this case will be 10)… I know you know AS so I know you know how that += stuff works and everything so this should be pretty easy for you to get.

Now we need to create the DIV tag…

<DIV ID="rollImg" onMouseOver="javascript:bump('rollImg', 10);" CLASS="jumpDiv"><IMG SRC="url"></DIV>

This sets the ID to “rollImg” so we can target it via our javascript. It sets the onMouseOver to call the function bump() and set the clipID to the target rollImg (the current div) and bump it to the right 10 pixels. Then it assigns the CSS Class to makes its position absolute (impotant for dynamic positioning).

I actually didn’t test this…lol. Please let me know if it works :slight_smile:

WHoo HOO! it works!! Thank you thank you thank you!!! This is wonderful… now I can make flash movies in javascript! … Not.

Thats awesome. Is that how people did things before flash? (j/k)

Wow, I had my fingers crossed, I was unable to test it right now so I wasn’t sure.

And DHTML is a pain, I regret ever trying to learn it :stuck_out_tongue: Although some things in it can be quite useful :slight_smile:

And yes actually, this was how people did things before flash :hangover:

i tried to put the code into a post, but it would let the { character through. its actually &#123 in the source when the html loads.

have you seen this lost, its awesome->>>

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=26715&perpage=15&pagenumber=2

I think the forum limits the coding you can use. Not sure though.

And yeah I saw that, I posted a reply in there for it. Ahmed is a really great scripter, especially server-side.

<script>document.write(’<STYLE>.jumpDiv '+String.fromCharCode(123)+‘position: absolute;};</STYLE>’);</script><DIV ID=“rollImg” onMouseOver=“document.all.rollImg.style.pixelLeft+=10;” CLASS=“jumpDiv”><IMG SRC=“avatar.php?userid=3825&dateline=1053153234”></DIV>

it works!!!.. in IE that is…

Hehe, cool :slight_smile: