# Placing code on the Main Timeline

**URL:** https://forum.kirupa.com/t/placing-code-on-the-main-timeline/118191
**Category:** Uncategorized
**Created:** [August 3, 2004, 2:39pm UTC](https://forum.kirupa.com/t/placing-code-on-the-main-timeline/118191 "2004-08-03T14:39:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![flufilms](https://avatars.discourse-cdn.com/v4/letter/f/e56c9b/32.png) [@flufilms](https://forum.kirupa.com/u/flufilms)
#### Post date: [August 3, 2004, 2:39pm UTC](https://forum.kirupa.com/t/placing-code-on-the-main-timeline/118191/1 "2004-08-03T14:39:29Z")

</div>

I have been generosuly given this code…

main timeline -  
c = 0;  
on frame#1 of the clip to duplicate -  
function Select(d){  
if(!dragged){  
duplicateMovieClip(this,“clip”+d,d);  
dragged = true;  
startDrag(this);  
} else {  
startDrag(this);  
}  
if(Key.isDown(Key.DELETEKEY)){  
this.removeMovieClip();  
}  
};  
on the button inside the clip -  
on(press){  
Select(\_parent.c++);  
}

I know how to add code to frames, and to symbols - but how do you add the code at the start of the message to the ‘Main Timeline’??

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 3, 2004, 6:01pm UTC](https://forum.kirupa.com/t/placing-code-on-the-main-timeline/118191/2 "2004-08-03T18:01:03Z")

</div>

> [@flufilms](#):
>
> I have been generosuly given this code…
> 
> main timeline -  
> c = 0;  
> on frame#1 of the clip to duplicate -  
> function Select(d){  
> if(!dragged){  
> duplicateMovieClip(this,“clip”+d,d);  
> dragged = true;  
> startDrag(this);  
> } else {  
> startDrag(this);  
> }  
> if(Key.isDown(Key.DELETEKEY)){  
> this.removeMovieClip();  
> }  
> };  
> on the button inside the clip -  
> on(press){  
> Select(\_parent.c++);  
> }
> 
> I know how to add code to frames, and to symbols - but how do you add the code at the start of the message to the ‘Main Timeline’??

That looks like Jacks code to me.I`ve learn`t tons from him.  
The main timeline is the one which contains your other clips(\_root)  
So as soon as you open the file, click on the first frame and type c=0
