Scrolling MC Problem, From Parent SWF

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.


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

any1? :frowning:

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.

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 :frowning:

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.

Can you attach you files digital?