# Write to a global variable when in specific frame

**URL:** <https://forum.kirupa.com/t/write-to-a-global-variable-when-in-specific-frame/280470>\
**Category:** flash\
**Created:** [January 28, 2009, 1:15am UTC](https://forum.kirupa.com/t/write-to-a-global-variable-when-in-specific-frame/280470 "2009-01-28T01:15:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattiasA](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@MattiasA](https://forum.kirupa.com/u/MattiasA)\
**Post date:** [January 28, 2009, 1:15am UTC](https://forum.kirupa.com/t/write-to-a-global-variable-when-in-specific-frame/280470/1 "2009-01-28T01:15:07Z")

</div>

Hi

This is what I need to do:

When the value of \_root.mc1.\_currentframe is 10 I want the value of \_root.mc2.\_currentframe to be written (sent or changed) to a variable which I can use in mc1. So I want to be able to use this variable in different clips but I do not want it to be changed until the playhead in mc1 is in frame 10. However I do want the variable to be valid even if the playhead is not in frame 10. This should be so simple. Anyone with an idea???

This is what I have in mc1:

```auto
on (press) {
   press = true;
   if (press == true) {
        _root.mc1.gotoAndPlay(myVar);
}

```

This is what I have in mc2:

```auto
onClipEvent (enterFrame) {
    if (_root.mc1._currentframe==10) {
//
//I have tried the following one at the time!
//
        _global.myVar;
        var myVar;
        myVar = _root.mc2._currentframe;
        _global.myVar:Number = _root.mc2._currentframe;
        set (_global.myVar, _root.mc2._currentframe);
        _global.myVar = _root.mc2._currentframe;
        }
}

```
