Copy link to clipboard
Copied
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.
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).
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
any help with this guys ??
seriously , need help ..
Copy link to clipboard
Copied
Sorry, huge wind storm took out my net for days, ugh..
So you're clearly getting both data to ASP, ASP is working with it fine, ASP sends something back and the SWF isn't accepting it.
Sounds like a MIME type issue. Are you actually sending HTML back? Despite that you are, try removing the contentType property from the URLRequest and in ASP.NET set that type to just text/plain and see if Flash accepts the data returned.
Play around with not specifying the MIME, or specify different types. It makes no real difference to flash if you're returning text, HTML, JSON, XML, etc.. When you get the returned data you just cast it however you need, e.g. completeHandler(e:Event):void{ var myXml:XML = XML(e.target.data);}. In that example I'd just transfer it with text/plain, no difference.
Copy link to clipboard
Copied
i figured out the problem ....
the problem is from the C# , would you please check the C# code for the outputStream ... this is not returning the complete file.
so , please would you mind checking the code , so that it returns the whole text from the file
and yes the changed the content-type to text/plain.
Copy link to clipboard
Copied
How big is the file? Do you really need it to stream async? I typically use small files and just:
using (StreamReader file = new StreamReader(path))
{
// get the whole file at once
String fileData = file.ReadToEnd();
// write it all at once
Response.OutputStream.Write(fileData, 0, fileData.Length);
}
Copy link to clipboard
Copied
i have 2 files , one file is 6KB and other file is 242KB ...
but the problem is same for both the files , the character is not being sent.
and would you please check your code , as it is throwing me an error at the response.outputstream.write(fileData, .... );
fileData is not an BYTE[]
Copy link to clipboard
Copied
thanks my friend,
i got that working.
appreciate your help.
Copy link to clipboard
Copied
Ah yes I see you were sending over Response.OutputStream.Write. At any rate, glad you got it all working. Please mark any helpful/correct answers so we can attend unanswered questions and good luck!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now