• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6709
  • Last Modified:

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();
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...";
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"];
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" />

Open in new window

  • 2
  • 2
2 Solutions
Have you tried making the path in your actionscript relative?


I'm assuming the flash file and aspx pages are all in the same directory
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"]
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.
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"]':

I apologize as there is no "Requesting" event.  Ignore that part of my above post.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now