# Javascript and dhtml into flash

**URL:** https://forum.kirupa.com/t/javascript-and-dhtml-into-flash/102519
**Category:** Uncategorized
**Created:** [February 24, 2004, 6:17pm UTC](https://forum.kirupa.com/t/javascript-and-dhtml-into-flash/102519 "2004-02-24T18:17:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fumeng](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@fumeng](https://forum.kirupa.com/u/fumeng)
#### Post date: [February 24, 2004, 6:17pm UTC](https://forum.kirupa.com/t/javascript-and-dhtml-into-flash/102519/1 "2004-02-24T18:17:06Z")

</div>

hi |

i’m trying to translate some very cool experiments done in javascript and dhtml into flash.

a guy i work with put these together and although i’ve got a good basic knowledge of programming, his stuff is just beyond me and i’m looking for someone to help me understand his code and translate it to flash. i really want to learn from this.

the experiments can be found at:

[http://www.cowboyscripts.org/javascript/mousetrails.html](http://www.cowboyscripts.org/javascript/mousetrails.html)

he said that besides some code that’s specific to dhtml the code he has can be translated almost verbatim into flash.

i’m attaching my initial .fla with the code i brought over. i thought it might be a good place for me to start. it’s not much but i’m taking small steps.

you can view his javascript/dhtml code on the url listed above.

i’m really looking forward to working thru this and understanding it and hopefully learning a lot. that’s my end goal.

any help will be greatly appreciated. plus, i thought it might be fun for some people to check out what this guy is doing. he is a very talented developer.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 25, 2004, 4:03pm UTC](https://forum.kirupa.com/t/javascript-and-dhtml-into-flash/102519/2 "2004-02-25T16:03:59Z")

</div>

ok. i’m perusing the code and here’s what i don’t understand:

[AS]prevpos = eval("\_root.square"+(num-1)); // the square in front of him[/AS]  
when i read this i see this:

create a new variable (prevpos) which is the square in front of the one just created.  
[AS]posx += (prevpos.\_x-oldposx)/2; //move with delay, using the previous button[/AS]  
create a new variable (posx) that takes the x position of the square in front of him and subtracts oldposx…??

(which hasn’t been declared yet – this is where i’m lost because it’s not even declared 'til a few more lines down)

so this is where i stop and get stuck. any help explaining this?

thanks. fumeng.  
[AS]posy += (prevpos.\_y-oldposy)/2; //ditto[/AS]  
[AS]\_x = posx;[/AS]  
[AS]\_y = posy;[/AS]  
[AS]oldposx = posx; //saving new position[/AS]  
[AS]oldposy = posy; //ditto[/AS]
