# Calling method problem

**URL:** <https://forum.kirupa.com/t/calling-method-problem/228268>\
**Category:** Uncategorized\
**Created:** [June 6, 2007, 4:25pm UTC](https://forum.kirupa.com/t/calling-method-problem/228268 "2007-06-06T16:25:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebacuello](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sebacuello](https://forum.kirupa.com/u/sebacuello)\
**Post date:** [June 6, 2007, 4:25pm UTC](https://forum.kirupa.com/t/calling-method-problem/228268/1 "2007-06-06T16:25:39Z")

</div>

hi  
i have this class “ff” with a method “mouseScroll” defined public. and other class “marker” in the same pakage. i need to call the method “mouseScroll” to be executed in an instance of “ff” from within “marker”. but the compiler says that there is no such property or method.  
this is my code for ff.as:

```auto
  	import flash.events.Event;
	import flash.geom.Rectangle;
	

	public class ff extends myMC {
		
		public function ff() {
			var aaa="si";
			y=92;
			x=50;
			var window:Rectangle = new Rectangle(0, 1, 600, 419);
			this.scrollRect = window;

			mouseScroll(true);
		}
		var randomnum=function(n:Number){
		return Math.round(Math.random()*n);
		};
		public function mouseScroll(active:Boolean) {
			var posfactor = -(fot1.width-600)/600;
			var endval = 0;
			if (active) {
				addEventListener(Event.ENTER_FRAME, handlerEnterFrame);
				function handlerEnterFrame(event:Event) {

					if ((mouseY>0) && (mouseY<430) && (mouseX>0) && (mouseX<600)) {

						endval = Math.floor(mouseX);

					}
					var fot2prevx = fot2.x;

					fot2.x = easeInOut(fot2.x, endval*posfactor);

					var movin = fot2prevx-fot2.x;

					if ((movin == 0) && (randomnum(15) == 5)) {
						fot1.x=fot2prevx+(randomnum(100)-randomnum(100));
						fot1.y=fot2.y+(randomnum(100)-randomnum(100));
					} else {

						fot1.x = easeInOut(fot1.x, (endval*posfactor)+(randomnum(movin*10)-randomnum(movin*10)));
						fot1.y=fot2.y-5;
					}
				}
			} else {
				removeEventListener(Event.ENTER_FRAME,handlerEnter Frame);
			}

		}
		function easeInOut(b:Number, c:Number):Number {
			return Math.floor(b +( c - b) / 20);
		}

	}
} 

```

marker.as

```auto
  	package {

	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;

	import flash.events.MouseEvent;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.events.EventDispatcher;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	

	public class marker extends myMC {
		
		var action:Event=new Event("action");
		public function marker(ix:Number,iy:Number) {
			x=ix;
			y=iy;

			dispatcher.addEventListener("action", actionHandler);
			addEventListener(MouseEvent.CLICK, clickHandler);
			addEventListener(Event.ADDED_TO_STAGE, handleraddedts);

		}
		function handleraddedts(event:Event) {

		}
		function clickHandler(event:MouseEvent):void {
			//trace(event.target.parent.parent.name);
			cliked=event.currentTarget.name;
			dispatcher.dispatchEvent(action);

		}
		override function actionHandler(event:Event):void {
			if (cliked==this.name) {
				removeEventListener(MouseEvent.CLICK, clickHandler);
var myTween:Tween = new Tween(this.getChildByName("box"), "width", Elastic.easeOut, this.getChildByName("box").width, 450, 3, true);
var myTween2:Tween = new Tween(this.getChildByName("box"), "height", Elastic.easeOut, this.getChildByName("box").width, 300, 3, true);
				//trace(parent);
				//parent.parent.mouseScroll.call(this,true);
			} else {

 var myTween3:Tween = new Tween(this.getChildByName("box"), "width", Elastic.easeOut, this.getChildByName("box").width, 5, 3, true);
var myTween4:Tween = new Tween(this.getChildByName("box"), "height", Elastic.easeOut, this.getChildByName("box").width, 5, 3, true);
				addEventListener(MouseEvent.CLICK, clickHandler);
			}
		}
	}

}

```

and myMC.as

```auto
  	package {

	
	import flash.display.MovieClip;

	
	import flash.events.Event;

	import flash.events.EventDispatcher;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;

	public class myMC extends MovieClip {
		
		public static var dispatcher:EventDispatcher = new EventDispatcher();
		public static var cliked:String = new String();

		public function myMC() {
			dispatcher.addEventListener("action", actionHandler);
		}
		function actionHandler(event:Event):void {

			
		}
	}

}

```

they are intialized in the fla in this way:

```auto
  	var main:ff=new ff();
addChild(main);
var markers:myMC=new myMC();
main.addChild(markers);
var mrk1:marker=new marker(125,0);
var mrk2:marker=new marker(299,0);
var mrk3:marker=new marker(425,0);
var mrk4:marker=new marker(622,0);

//trace(this.ff);
markers.addChild(mrk1);
markers.addChild(mrk2);
markers.addChild(mrk3);
markers.addChild(mrk4);

markers.addEventListener(Event.ENTER_FRAME, handlerEnterFrame);

function handlerEnterFrame(event:Event) {
	markers.x=markers.x+((main.fot2.x-markers.x)/8);
	var c:Number=new Number();
	for (c=1; c<markers.numChildren; c+=1) {

		markers.getChildAt(c).x=markers.getChildAt(c-1).x+markers.getChildAt(c-1).width+10;
	}

} 

```

in advance thanks  
lseba
