Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1053507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:15:51+00:00 2026-05-16T17:15:51+00:00

I have a SWF that can be hosted in several different places on the

  • 0

I have a SWF that can be hosted in several different places on the web (including facebook.com). How can I determine which page is hosting my SWF from within Actionscript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:15:52+00:00Added an answer on May 16, 2026 at 5:15 pm

    There isn’t an bulletproof method for what you want.

    The most usual and simpler approachs are:

    1) Use ExternalInterface.call to call javascript an return the localtion.

    Something like:

    var location:String = ExternalInterface.call('window.location.href');
    

    2) Pass a flashvar to your swf in the HTML embed code.

    Pros:

    Both are quite easy to implement

    Cons:

    Not always possible / available.

    When your swf is embedded as a third party widget, it’s quite likely that it will not be granted access to javascript. In fact, by default, your swf will not have access to JS, unless the embedding code explicitly sets allowscriptaccess to “*” (everyone).

    In the flashvars case, that data has to be passed by the embed code, obviously. But you typically don’t control this code, so it might work in some cases but not others.

    There’s a third way (there could be others) that is rather hackish and more involved, but I actually used it once and worked fine. The basic idea is this. Instead of serving your swf directly, have the embed code load a page that you can control server side. Let’s call this yoursite.com/loader.php. This script grabs the http referrer and passes it to your swf (caveat: yes, http referrer is not mandatory and could be absent in the request or be spoofed; in a normal scenario, this is not an actual problem as most browsers do send this data).

    Now, this is the tricky part. You have to somehow write that data into your swf. There are options to compile swf on the fly, server-side. You could also try and parse the swf format (it’s fairly documented). But this seemed ovekill for I was trying to do (I mean, overkill for the server).

    So I decided to have a simple loader.swf that loaded the actual swf. This loader.swf had a string variable (let’s call it referrer) with some placeholder data that was 1) easy to find, 2) very unikely to happen randomly in the binary, and 3) large enough to hold a url (I mean a big string like “$BEGIN_PLACEHOLDER$0123456789$END_PLACEHOLDER$”, where “0123456789” is just a filler that is repeated to make the placeholder big enough; I had a 1000 bytes string or something like that, just to be safe; this has to be one literal string in your actionscript code or it will be compiled to more than one constant and you will not be able to find it in the swf binary).

    The php script simply opened the loader with fopen, looked for the begin and end tokens and replaced the whole string with the referrer (if I recall correctly I added some character to pad this string). The script then returned the read swf with the referrer injected. At runtime, the effect of this is that in your loader swf, the referrer is just a normal compile-time variable. This loader swf then loaded the actual swf and passed the value of referrer through the querystring, so the app end up being called like this: yourdomain.com/app.swf?referrer=the_referrer_value. Then, in the app, the referrer was just a normal flashvar.

    Now, for this to work, the loader was exported as an “uncompressed” swf. If it’s compressed, you have to decompress first, etc, etc. Also, this is way I used a loader swf instead of doing this in the real app; the loader itself was tiny, so it dind’t matter it was not compressed, but the real app could not be uncompressed.

    It’s a bit involved and not the most elegant, but it wasn’t that hard to get the whole thing working and wasn’t too demanding on the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that can be reached using multiple paths: http://mydomain.com/portal1/movie.swf http://mydomain.com/portal2/movie.swf http://mydomain.com/portal1/substep/movie.swf
I have a swf template that can be used with different data input such
I have one main parent swf that loads several other swfs. If something happens
I have a AS3 swf [1] that is loading another AS2 swf [2] which
I have an ActionScript project with several classes that i compiled as an swf
I have an AS2 swf that is hosted by an AS3 swf and they
I have an SWF that pulls several fairly heavy .flv files into the media
I'd like to have placeholders in an .swf file that I can populate with
I have a swf that requires flash 9, and I'm trying to show content
I have a swf that loads images from my server and resizes them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.