I'm fairly inexperienced so please bear with me.

I am using FlourineFX, my goal is to retrieve data from an amf server.

I've got a windows form with a button. The code for a button creates an instance of an object:

private void btnGo_Click(object sender, EventArgs e)
{
ArrayList args = new ArrayList { val1, val2, val3, val4 };
AmfConnect VidData = new AmfConnect(args);
}


//The AmfConnect class is as follows:
public class AmfConnect
{
public  AmfConnect(ArrayList  args)
{

	ServerConnect(args);
					  
}
private void ServerConnect(ArrayList  args)

	 //get args from string array
	string server = args[0].ToString();
	string command = args[1].ToString();
	string file = args[2].ToString();

	// Create NetConnection client
	NetConnection connection;
	connection = new NetConnection();
	connection.ObjectEncoding = ObjectEncoding.AMF3;

	connection.Connect(server);
													 
	connection.Call(command, new AmfResult(),new object[] { file, 103207, true, null, 1.859671316E9 });]
			
}

My issue is with connection.Call. While stepping through the code, I realized that "new AmfResult()", which is where the resultant is determined, was not being processed/instantiated until after VidData was instantiated and any other code in the _Click function has been processed, keeping me from getting the resultant I need. I'm at a loss, any help would be appreciated.

Recommended Answers

All 3 Replies

I don't understand what you are asking. Could you explain your situation a little more?

I don't understand what you are asking. Could you explain your situation a little more?

Say I have a btnGo. When I click Go, I want it to create an instance of AmfConnect. Inside AmfConnect, an instance of AmfResult is created (as part of a set of parameters), which collects amf information from the amf server. After clicking the Go button, I want a message box to pop up showing the information that was collected. But, what is happening is the code is not creating an instance of AmfResult before the message box is processed. In fact, any code that is in the same function as the AmfConnect instantiation is processed, then it goes back to the AmfConnect class and instantiates AmfResult, which promply looses it's value. To get around this I created a static class/global variable. This works, but only for one set of data. I need to be able to handle the return of one or multiple sets. Say I use a string array with a set of 4 parameters to use when creating an instance of AmfConnect, and I use a foreach loop. What happens is it instantiates AmfConnect 4 times, then instantiates AmfResult and returns only one set of data.

Can you post the code where you have used the static member? I do not have this library installed so I can't help write the code but I think you want to do something like this:

private void btnGo_Click(object sender, EventArgs e)
{
ArrayList args = new ArrayList { val1, val2, val3, val4 };
AmfConnect VidData = new AmfConnect(args);
}


//The AmfConnect class is as follows:
public class AmfConnect
{
public  AmfConnect(ArrayList  args)
{

	ServerConnect(args);
					  
}
private AmfResult ServerConnect(ArrayList  args)

	 //get args from string array
	string server = args[0].ToString();
	string command = args[1].ToString();
	string file = args[2].ToString();

	// Create NetConnection client
	NetConnection connection;
	connection = new NetConnection();
	connection.ObjectEncoding = ObjectEncoding.AMF3;

	connection.Connect(server);
         AmfResult() result = new AmfResult();
	connection.Call(command, result, new object[] { file, 103207, true, null, 1.859671316E9 });]
	return result;			
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.