views:

31

answers:

4

I have a parent and 2 children. I am trying to pass data from child1 to child2 but keep getting an error message: 1061: Call to a possibly undefined method through a reference with a static type.

In child1 I have the following code:

[Bindable]
public var TestVar:String='sometext';

In child2 I am trying to get the value of TestVar and then use it as a value to search a mysql database via php.:

  var newTestVar:String = child1.TestVar;
  if(newTestVar != null){
    getResult.token = someService.get_filtered_Paged(newTestVar);
  }

  else{
    getSecResult.token = someService.get_paged(); 
  }
A: 

change public var TestVar:String='sometext'; to public static var TestVar:String='sometext'; You are getting this error because you are trying to access the variable: TestVar in a static context when you have not marked it static.

ape
thanks. that didn't seem to work. I am still getting the same error message.
ginius
A: 

@ape is right, you should make is Static or use MVC to inject the property.

Avi Tzurel
A: 

You're getting this error because you declared child1 as a superclass of whatever child1 actually is. It's only natural that TestVar is not defined there. To top it off that superclass is not dynamic so you'd need to access that field with:

child1["TestVar"];

That will not generate a compile error, and should have no problem accessing the field at runtime if the instance held by child1 is the right one.

bug-a-lot
A: 

Let's say you defined TestVar in MyClass1. Cast child1 to that type:

var newTestVar:String = MyClass1(child1).TestVar;

If this does not help, please post bigger part of your code.

Maxim Kachurovskiy