A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How to detect when Flash is loaded from a local drive?

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    48

    How to detect when Flash is loaded from a local drive?

    Hello,

    Is there a script that checks if the flash is loaded from a local drive?

    Example: Keric opens a flash file. The script then checks if the file is being played from a local drive. If it's not, ads will be displayed.

    Something like a domain lock. Uhm, local drive lock? Heheh

    Is this possible?

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I honestly don't know, but what you can do, is to check what the URL of that flash file is, if it's opened locally, the URL will start with file:// but if it's online, then it will start with http://, so you can check if the URL contains that:

    Actionscript Code:
    currentURL = this._url;

    if(currentURL.indexOf("http://") != -1){
        // activate ads
    }

    If a word isn't found, then its position is -1, that's why we check if the position of that word is NOT EQUALS to -1

    Hope this works
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    Actionscript Code:
    import flash.external.*;

    var isAvailable:Boolean = ExternalInterface.available;
    var txt = this.createTextField("txt", 0, 10, 10, 50, 20);
    txt.autoSize = "left";

    if (isAvailable==false) {
        txt.text = "You are from local machine";
    }else{
        var url = this._url.split("/");
        var tmp:Array = new Array();
        for (var i = 0; i<url.length; i++) {
            if (url[i] != "") {
                tmp.push(url[i]);
            }
        }
        url = tmp;
        for (i=0; i<url.length; i++) {
            //txt.text += url[i];
        }
        if (url[0] == "http:" && (url[1] == "localhost"||url[1] == "127.0.0.1")) {
            url[1]="Local Server of";
            txt.text = "You are from "+url[1]+" Local Machine";
        } else if (url[0] == "file:" && url[1] != "localhost") {
            txt.text = "You are from "+url[1];
        }
        //txt.text =url[0]+ url[1];//(isAvailable);
    }



    marlopax
    Last edited by marlopax; 02-11-2012 at 02:59 PM.

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