|
-
Posted this on were-here today, thought I'd post it here as well:
Here's a way to get around the security restrictions, imposed by Macromedia, of not being able to load SWFs and variables from other domains. By using the MSXML 3.0 ServerHTTP component, I'm able to make a request to a different domain by using an ASP script, which then feeds back the binary/text data back into Flash.
Then in Flash I simply use:
loadMovieNum("http://www.mysite.com/XMLFlashProxy.asp?url=http://www.othersite.com/movie.swf&contentType=application/x-shockwave-flash&dataType=binary", 0);
or for loadVariables()
loadVariablesNum ("http://www.mysite.com/XMLFlashProxy.asp?url=http://www.othersite.com/stockQuotes.txt&contentType=text/plain&dataType=text", 0);
dataType parameter MUST be "text" OR "binary".
Here's the ASP code:
-----------------------------------------
XMLHTTPObj.asp
-----------------------------------------
<%
Class XMLProxy
Dim strURL
Public Property Get URL()
URL = strURL
End Property
Public Property Let URL(mstrURL)
strURL = mstrURL
End Property
Public Property Get DataType()
DataType = strDataType
End Property
Public Property Let DataType(mstrDataType)
strDataType = mstrDataType
End Property
Public Function SendRequest()
On Error Resume Next
Dim objXML
Dim strReturnXML
Dim strStatus
Set objXML = CreateObject("Msxml2.serverXMLHTTP")
objXML.Open "GET", URL, False
objXML.Send
strStatus = objXML.status
If strDataType = "text" then
strReturnXML = objXML.responseText
Else
strReturnXML = objXML.responseBody
End If
If strStatus <> 200 then
SendRequest = null
Else
SendRequest = strReturnXML
End If
End Function
End Class
%>
-----------------------------------------
XMLFlashProxy.asp
-----------------------------------------
<% @Language = "VBScript" %>
<% Option Explicit %>
<!--#include file="./lib/XMLHTTPObj.asp"-->
<%
' ------------------------------------------------
' Declare Variables/Objects
' ------------------------------------------------
Dim objXML
Dim strResponse
Dim strContentType
Dim strDataType
' ------------------------------------------------
' Create Objects
' ------------------------------------------------
Set objXML = new XMLProxy
' ------------------------------------------------
' Assign Variables
' ------------------------------------------------
strContentType = Request.QueryString("contentType")
strDataType = Request.QueryString("dataType")
strURL = Request.QueryString("url")
objXML.URL = strURL
objXML.DataType = strDataType
strResponse = objXML.SendRequest()
If Not IsNull(strResponse) then
Response.ContentType = strContentType
If strDataType = "text" then
Response.Write strResponse
Else
Response.BinaryWrite strResponse
End If
End If
Set objXML = nothing
%>
You can download the zip here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|