# Scrolling MC Problem, From Parent SWF

**URL:** <https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235>\
**Category:** flash\
**Created:** [November 11, 2003, 8:48pm UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235 "2003-11-11T20:48:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 8:48pm UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/1 "2003-11-11T20:48:06Z")

</div>

I’m scrolling a movie clip from about.swf  
Now when about is loaded into my index.swf the scroller in about doesn’t work. I have a feeling I know the problem, because I am using \_global. Now I used this because when I started using FMX 2004 the actionscript I previously used didn’t work anymore. Not too sure why. But anyway here is my code.

```auto

onClipEvent (load) {
        _global.tarX = 719;
        _global.tarY = 91.0;
}
onClipEvent (enterFrame) {
        this._x += (tarX-_x)/3;
        this._y += (tarY-_y)/3;
		_root.scrollUp.onPress = function(){
			if(_global.tarY < 91){
	        	_global.tarY = _global.tarY + 25;
			}
		}		
		_root.scrollDown.onPress = function(){
			if(_global.tarY > -34){
				_global.tarY = _global.tarY - 24;
			}
		}
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 12, 2003, 5:09am UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/2 "2003-11-12T05:09:02Z")

</div>

any1? ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 12, 2003, 11:27am UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/3 "2003-11-12T11:27:37Z")

</div>

You’d have done it too if it hadn’t been for those meddling \_global kids …

try changing

```
    this._x += (tarX-_x)/3;
    this._y += (tarY-_y)/3;

```

to

```
    this._x += (_global.tarX-_x)/3;
    this._y += (_global.tarY-_y)/3;

```

regarding scoping:

Using \_global declares a global var which is accessible from anywhere in the movie using the syntax \_global.

Using unqualified declaration (e.g. cat=“tabby”) will declare the variable on the current timeline - \_root, \_level3.catHolder, etc and you will need to address it using either a relative or absolute path.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 13, 2003, 8:50pm UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/4 "2003-11-13T20:50:27Z")

</div>

hey thanks for your reply but you confused the f out of me right here: could you please explain more? sry i have been working very hard lately and it seems that my mind isn’t working the way it should be

> 

Using unqualified declaration (e.g. cat=“tabby”) will declare the variable on the current timeline - \_root, \_level3.catHolder, etc and you will need to address it using either a relative or absolute path.

thanks again  
Digi

edit: unfortunatly this didnt work ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 5:29pm UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/5 "2003-11-14T17:29:32Z")

</div>

I built a MC controlled by two buttons to test your code and couldn’t see a need to use \_global, but maybe I’m missing something.

As regards variable declaration:

If you declare a variable (or object) on a timeline without scoping it - e.g. howMany=78; then that variable is scoped to the timeline where it is declared - be that on the \_root, nested within a MC instance, or on a particular \_level.

If you wish to target that variable (or object) than you need to know the correct target path e.g. \_root, \_parent.MC1.MC2, \_level3.MC1.

On the other hand if you declare a variable using \_global then that variable is scoped to \_global and the only valid target path to it from anywhere in any movie clip (no matter how deeply nested) is \_global.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 5:34pm UTC](https://forum.kirupa.com/t/scrolling-mc-problem-from-parent-swf/35235/6 "2003-11-14T17:34:33Z")

</div>

Can you attach you files digital?
