A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Load Variables/Movies from other domain - SOLUTION

  1. #1
    Junior Member
    Join Date
    Dec 2001
    Posts
    26
    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

  2. #2
    Junior Member
    Join Date
    Apr 2001
    Posts
    18

    Thanx a lot...but does it work with Flash 4 ??

    Thanx a lot man, it seems to work well with Flash 5!!!!!

    But is this works with Flash 4 to ?

    Thanx again, you nearly saved my life!!!!

    Ejoe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center