# Easy code from a book. But does not work!

**URL:** <https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172>\
**Category:** flash\
**Created:** [April 2, 2006, 11:35pm UTC](https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172 "2006-04-02T23:35:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)\
**Post date:** [April 2, 2006, 11:35pm UTC](https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172/1 "2006-04-02T23:35:45Z")

</div>

Hey guys, I got this code straight out of a Flash Actionscript book but I can’t get it to work. The output panel does not show an error, but the code does not do what it should. It is a mouse trail

Any thoughts, would be appreciated

> onClipEvent(load){  
> //CREATE 10 CURSOR FOLLOWERS  
> for(var i=0;i\<10;i++){  
> \_root.attachMovie(“glitter”,“glitter”+i,i);  
> }  
> //START THE ARRAY  
> trail = new Array();  
> }  
> onClipEvent(enterFrame){  
> //MARK THE MOUSE LOCATION  
> cursorLoc = {x:\_root.\_xmouse, y:\_root.\_ymouse};  
> //ADD THE NEW LOCATION TO THE ARRAY  
> trail.push(cursorLoc);  
> //DELETE THE OLDEST LOCATION  
> if(trail.length \> 10) trail.shift();  
> //CHANGE THE POSITIONS OF ALL CURSOR FOLLOWERS  
> for(var i=0; i\<trail.length; i++) {  
> \_root[“cursor”+i].\_x = trail\*.x;  
> \_root[“cursor”+i].\_y = trail\*.y;  
> \_root[“cursor”+i].\_alpha = i\*10; //CHANGE BLEND TO  
> }  
> }

---

<div class="post-metadata">

**Author:** ![McGuffin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mcguffin/32/408_2.png) [@McGuffin](https://forum.kirupa.com/u/McGuffin)\
**Post date:** [April 2, 2006, 11:37pm UTC](https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172/2 "2006-04-02T23:37:48Z")

</div>

Looking over it very quickly, this IF statement is broken:

if(trail.length \> 10) trail.shift();

You need the curlies {}.

---

<div class="post-metadata">

**Author:** ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)\
**Post date:** [April 7, 2006, 6:05pm UTC](https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172/3 "2006-04-07T18:05:33Z")

</div>

Good eye but still no luck. Any thoughts?

---

<div class="post-metadata">

**Author:** ![SlowRoasted](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SlowRoasted](https://forum.kirupa.com/u/SlowRoasted)\
**Post date:** [April 7, 2006, 6:10pm UTC](https://forum.kirupa.com/t/easy-code-from-a-book-but-does-not-work/184172/4 "2006-04-07T18:10:21Z")

</div>

does it need brackets when its only one line? I know php doesn’t require it.
