# Load MC from library and apply script to MC dynamically

**URL:** <https://forum.kirupa.com/t/load-mc-from-library-and-apply-script-to-mc-dynamically/153826>\
**Category:** flash\
**Created:** [July 5, 2005, 2:52am UTC](https://forum.kirupa.com/t/load-mc-from-library-and-apply-script-to-mc-dynamically/153826 "2005-07-05T02:52:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chockybickyman](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@chockybickyman](https://forum.kirupa.com/u/chockybickyman)\
**Post date:** [July 5, 2005, 2:52am UTC](https://forum.kirupa.com/t/load-mc-from-library-and-apply-script-to-mc-dynamically/153826/1 "2005-07-05T02:52:32Z")

</div>

I have several swf movie files that load into levels within my folio, these levels being 2,3 and 4. I have a ball within the root file located currently in the library with an identifier name of \*\*“ball” \*\*that i want to dynamically load to level 5 and have the following script appied to it…

BALL FOLLOW CODE"  
**onClipEvent (load) {  
\_root.ball\_mc  
\_x = 0;  
\_y = 0;  
speed = 3;  
}  
onClipEvent (enterFrame) {  
\_root.ball\_mc  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;  
}**

So I’ve applied this script to an on clip event:

ATTACH MOVIE CODE:  
**\_root.attachMovie(“ball”, “ball\_mc”, 5);**

Q: Now how do I go about targeting this newly attached movie to the ball follow code above???

Any help would be great, cheers!!!
