Sending variables from as3 to and back

Posted on 2008-11-13
Last Modified: 2013-11-11
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 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:







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(;

	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=",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="" />


Open in new window

Question by:codan87
    LVL 9

    Accepted Solution

    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
    LVL 9

    Assisted Solution

    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"]

    Author Closing Comment

    Thank you! Using a relative path fixed the problem. Your tip on how to handle the data also decluttered my code a bit.

    Expert Comment

    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"]':


    Expert Comment

    I apologize as there is no "Requesting" event.  Ignore that part of my above post.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now