Skip to main content
Participating Frequently
February 1, 2013
Answered

Problem WIth Dynamic URL from querystring in actionscript and returning XML from asp.net

  • February 1, 2013
  • 1 reply
  • 1818 views

hello friends,

i was trying to return the text  to SWF from asp.net through a URL.

if i pass the complete url to the URLRequest then it is working fine.

but if i try to use the querystring and do the concatenation and pass the text then i am getting a problem ...

its just not working ... i cant see any output at all.

lets say filename is someContent

Flash CODE :

var pa = MainMc.loaderInfo.parameters;

var path="http://localhost:51791/Home/GetSomeContent/?path="; // if i give the URL as
//"http://localhost:51791/Home/GetSomeContent/?path=contentName"

// then it is working absolutely fine, if i try to do the concatenation with the parameters then i am having the problem

if(pa.ttt != null && pa.ttt != "undefined")

{

    path = path + pa.ttt;   

}

var urlRequest:URLRequest = new URLRequest(path);

urlRequest.contentType = "text/html";

var urlLoader:URLLoader = new URLLoader();

urlLoader.addEventListener(Event.COMPLETE,completeHandlertext);

urlLoader.load(urlRequest);

HTML CODE:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="600" id="loader" align="middle">

                <param name="movie" value="/Files/SWF/main.swf?ttt=contentName" />

                <param name="quality" value="high" />

                <param name="bgcolor" value="#ffffff" />

                <param name="play" value="true" />

                <param name="loop" value="true" />

                <param name="wmode" value="window" />

                <param name="scale" value="showall" />

                <param name="menu" value="true" />

                <param name="devicefont" value="false" />

                <param name="salign" value="" />

                <param name="allowScriptAccess" value="sameDoloader" />

                <!--[if !IE]>-->

                <object type="application/x-shockwave-flash" data="/Files/SWF/main.swf?ttt=contentName" width="800" height="600">

                    <param name="movie" value="/Files/SWF/main.swf?ttt=contentName" />

                    <param name="quality" value="high" />

                    <param name="bgcolor" value="#ffffff" />

                    <param name="play" value="true" />

                    <param name="loop" value="true" />

                    <param name="wmode" value="window" />

                    <param name="scale" value="showall" />

                    <param name="menu" value="true" />

                    <param name="devicefont" value="false" />

                    <param name="salign" value="" />

                    <param name="allowScriptAccess" value="sameDoloader" />

                <!--<![endif]-->

                    <a href="http://www.adobe.com/go/getflash">

                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />

                    </a>

                <!--[if !IE]>-->

                </object>

                <!--<![endif]-->

            </object>

ASP.NET CODE :

Response.Buffer = false;

            Response.ContentType = "text/html";

            var path = Request.QueryString["path"];

            if(part!=null)part = part.Trim();

             if (string.IsNullOrEmpty(part))

                path = Server.MapPath(Url.Content("~/Files/" + path + "/xml/content.txt"));

         

            byte[] buffer = new byte[1 << 16];// 64kb

            int bytesRead = 0;

            using (var file = System.IO.File.OpenRead(path))

            {

                while ((bytesRead = file.Read(buffer, 0, buffer.Length)) != 0)

                {

                    Response.OutputStream.Write(buffer, 0, bytesRead);

                }

            }

            Response.Flush();

            Response.Close();

            //Response.End();

Would anyone please help me solving this problem . i dont want to create a new file everytime to get some content,

instead i want to use the same SWF for displaying dynamic based upon the URL.

please help me

thanks in advance.

This topic has been closed for replies.
Correct answer sinious

path += String(pa.ttt);

Many times objects don't type things properly. By forcing it to be a string like above it should behave properly. Otherwise the object 'pa' may not know the property 'ttt' is a String. Flash sometimes will give you valid issues for not being aware of that, like trying to add a number to a string, or add an object to a string (both not valid things to do in any strict environment).

1 reply

sinious
siniousCorrect answer
Legend
February 1, 2013

path += String(pa.ttt);

Many times objects don't type things properly. By forcing it to be a string like above it should behave properly. Otherwise the object 'pa' may not know the property 'ttt' is a String. Flash sometimes will give you valid issues for not being aware of that, like trying to add a number to a string, or add an object to a string (both not valid things to do in any strict environment).

Participating Frequently
February 1, 2013

i forgot to mention i am getting the proper value in the ASP.NET

i tried by adding the breakpoints in the ASP.NET and i was getting the value.

and i know the ASP.NET is returning the text .. but i dont know whats the problem with the Flash  .. whether it is accepting the text or not.

i could see that the text is being sent from the FIREBUG -> NET