# AS2 - need help controlling movieclip from the main timeline

**URL:** <https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435>\
**Category:** flash\
**Created:** [June 26, 2008, 4:29am UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435 "2008-06-26T04:29:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thejoeknows\_com](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thejoeknows\_com](https://forum.kirupa.com/u/thejoeknows_com)\
**Post date:** [June 26, 2008, 4:29am UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/1 "2008-06-26T04:29:21Z")

</div>

this ex. .fla controls the mc from itself but i would like to control it from the main timeline, ive tried a number of things but cant seam to get it to work

the .fla is [here.](http://www.actionscript.org/resources/downloadattachment.php?aId=30833231cd794e9ae27d43fdfadb152a&articleId=648)

and the code is here if you dont dl the .fla:

```auto

onClipEvent (load)
{
    var speed = new Number(0);
    _root.createEmptyMovieClip("drawing", 1);
    this.swapDepths(_root.drawing);
    _root.clearBtn.swapDepths(this);
    hi = Math.sin(_rotation * 1.745329E-002) * 10;
    ip = Math.cos(_rotation * 1.745329E-002) * 10;
    iks = _x - ip;
    ips = _y - hi;
    iks2 = _x + ip;
    ips2 = _y + hi;
}
onClipEvent (enterFrame)
{
    if (Key.isDown(38) & !Key.isDown(17))
    {
        speed = speed + 1.500000E+000;
    } // end if
    if (Key.isDown(40) & !Key.isDown(17))
    {
        speed = speed - 7.500000E-001;
    } // end if
    if (Key.isDown(17))
    {
        speed = speed - speed / 10;
        if (Key.isDown(39))
        {
            setProperty("", _rotation, _rotation + speed / 2);
        } // end if
        if (Key.isDown(37))
        {
            setProperty("", _rotation, _rotation - speed / 2);
        } // end if
    } // end if
    if (Key.isDown(39))
    {
        if (speed < 5 && speed >= 0)
        {
            setProperty("", _rotation, _rotation + 2 * speed);
        }
        else if (speed < 0)
        {
            setProperty("", _rotation, _rotation + 7.500000E+000 * speed / 15);
        }
        else
        {
            setProperty("", _rotation, _rotation + 7.500000E+000);
        } // end else if
        speed = speed * 9.500000E-001;
    } // end if
    if (Key.isDown(37))
    {
        if (speed < 5 && speed >= 0)
        {
            setProperty("", _rotation, _rotation - 2 * speed);
        }
        else if (speed < 0)
        {
            setProperty("", _rotation, _rotation - 7.500000E+000 * speed / 15);
        }
        else
        {
            setProperty("", _rotation, _rotation - 7.500000E+000);
        } // end else if
        speed = speed * 9.500000E-001;
    } // end if
    if (Math.abs(speed) > 20)
    {
        speed = 20;
    } // end if
    if (speed < -10)
    {
        speed = -10;
    } // end if
    speed = speed * 9.800000E-001;
    g = Math.sin(_rotation * 1.745329E-002) * speed;
    m = Math.cos(_rotation * 1.745329E-002) * -speed;
    setProperty("", _x, _x + g);
    setProperty("", _y, _y + m);
    hi = Math.sin(_rotation * 1.745329E-002) * 10;
    ip = Math.cos(_rotation * 1.745329E-002) * 10;
    _root.k1 = hi;
    _root.k2 = ip;
    if (Key.isDown(17))
    {
        _root.drawing.lineStyle(3, 14540253, 100);
    }
    else
    {
        _root.drawing.lineStyle(3, 15658734, 100);
    } // end else if
    _root.drawing.moveTo(iks, ips);
    _root.drawing.lineTo(_x - ip, _y - hi);
    _root.drawing.moveTo(iks2, ips2);
    _root.drawing.lineTo(_x + ip, _y + hi);
    iks = _x - ip;
    ips = _y - hi;
    iks2 = _x + ip;
    ips2 = _y + hi;
}

```

thank you  
-joey

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 26, 2008, 4:54am UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/2 "2008-06-26T04:54:14Z")

</div>

var ad:MovieClip=instancenameofsomecliponroot;  
ad.onLoad=function()  
{

}  
ad.onEnterFrame=function()  
{

}

/// This would be the basic structure

---

<div class="post-metadata">

**Author:** ![thejoeknows\_com](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thejoeknows\_com](https://forum.kirupa.com/u/thejoeknows_com)\
**Post date:** [June 26, 2008, 5:13am UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/3 "2008-06-26T05:13:20Z")

</div>

the car is only rotating, its lots the majority of its functions, not sure why

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 26, 2008, 5:32am UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/4 "2008-06-26T05:32:19Z")

</div>

// try this way

var ad:MovieClip=instancenameofsomecliponroot;  
ad.speed = new Number(0);  
\_root.createEmptyMovieClip(“drawing”, 1);  
ad.swapDepths(\_root.drawing);  
\_root.clearBtn.swapDepths(ad);  
hi = Math.sin(\_rotation \* 1.745329E-002) \* 10;  
ip = Math.cos(\_rotation \* 1.745329E-002) \* 10;  
iks = \_x - ip;  
ips = \_y - hi;  
iks2 = \_x + ip;  
ips2 = \_y + hi;  
//-----------------------  
ad.onEnterFrame=function()  
{  
// other code  
}

---

<div class="post-metadata">

**Author:** ![thejoeknows\_com](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thejoeknows\_com](https://forum.kirupa.com/u/thejoeknows_com)\
**Post date:** [June 26, 2008, 5:26pm UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/5 "2008-06-26T17:26:09Z")

</div>

hm its still acting how it was before

---

<div class="post-metadata">

**Author:** ![nebula\_228](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@nebula\_228](https://forum.kirupa.com/u/nebula_228)\
**Post date:** [July 9, 2008, 11:40pm UTC](https://forum.kirupa.com/t/as2-need-help-controlling-movieclip-from-the-main-timeline/264435/6 "2008-07-09T23:40:53Z")

</div>

what does 1.745329E-002 correspond to?
