Sending variables from as3 to asp.net and back

Hi there.

I have a flash movie sitting on an aspx page, and I want it to send variables from the movie to a different aspx page, and also read the variables coming back. The page it is communicating with is on the same domain.

When I play the movie in Adobe Flash CS3 it works perfectly.
When I play it on the final page, in a web browser (from server, not locally), the movie freezes between sending the data and receiving the new data.
When I try a third way, playing the movie from a locally stored simple html-page, it shows a warning right as it tries to make the connection. The movie also freezes when this warning is shown, so I assume this is why the movie freezes on the final page (though then no warning is shown).
Translated to english, the warning reads something like:

"Adobe Flash Player has stopped a potentially dangerous operation. The following file *filepath* is trying to communicate with this internetactivated location *domain*".

So my question of course how I make the movie work on the server.
I attach both the asp.net code and the as3 code.

About the flash movie.. I have to status textfields I use during debugging, called output and status. What this code is supposed to do is to send a variable from flash ("basilika"), and the aspx should return the variable tjosan, filled with #the_received_variable#.

AS3 code:
 
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.events.IOErrorEvent;
 
var myRequest:URLRequest;
var myVars:URLVariables;
var myLoader:URLLoader;
 
myVars = new URLVariables();
myRequest = new URLRequest();
myRequest.url='http://www.fragesporter.se/conny.aspx';
myRequest.method=URLRequestMethod.POST;
myRequest.data=myVars;
 
myLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.TEXT;
myLoader.addEventListener(Event.COMPLETE, completeHandler);
myLoader.addEventListener(IOErrorEvent.IO_ERROR, showError);
 
function completeHandler(event:Event):void {
	var newVars:URLVariables = new URLVariables(event.target.data);
 
	status.text = "waiting over!";
	output.text = newVars.tjosan;
 
}
function showError(e:IOErrorEvent) {
	trace("There was an error!");
}
 
nextButton.addEventListener(MouseEvent.CLICK, gotoGo);
function gotoGo(event:MouseEvent):void {
	status.text = "vänta...";
	requestVerification();
}
 
 
function requestVerification():void {
 
	output.text = "requesting";
 
	myVars.mode = "basilika";
	myRequest.url = myRequest.url + "?mode=" + myVars.mode;
	myLoader.load(myRequest);// this sends the variables and loads new data from Conny.aspx
 
}
 
 
 
ASP.NET code in Conny.aspx:
    protected void Page_Load(object sender, EventArgs e)
    {   
        String moj = Request.QueryString["mode"];
        Response.Write("tjosan="#"+moj+"#");
    }
 
 
The movie is integrated into a aspx-page with this code:
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="300" id="mainQuiz" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="allowFullScreen" value="false" />
	<param name="movie" value="mainQuiz.swf" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="mainQuiz.swf" loop="false" menu="false" quality="high" bgcolor="#ffffff" width="600" height="300" name="mainQuiz" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
	</object>

Open in new window

codan87Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amxCommented:
Have you tried making the path in your actionscript relative?

eg.
myRequest.url='conny.aspx';

I'm assuming the flash file and aspx pages are all in the same directory
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amxCommented:
I just noticed that your posting the data from flash but the aspx is expecting it as part of a querystring.

You can either change the flash file to send the data as a querystring or changes the aspx page to get you data like this:

 String moj = Request["mode"]
0
codan87Author Commented:
Thank you! Using a relative path fixed the problem. Your tip on how to handle the data also decluttered my code a bit.
0
Unzip_The_RipperCommented:
I would add to amx's comment above that you should also comment out any code that would attempt to run the video and comment out the eventListener for the "complete" event and the "Requesting" event.  

After commenting everything but the click handler out in flash, then put the following after your 'request["mode"]':

          response.write(moj)
          response.end
0
Unzip_The_RipperCommented:
I apologize as there is no "Requesting" event.  Ignore that part of my above post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.