A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Which website

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Location
    Scotland
    Posts
    5

    Which website

    Is there a way of determining which web host the movie is running on or passing a variable into the code.

    The problem I have is that I need to call a different URL depending if I make the call from a development website.

  2. #2
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    Sorry but I don't really understand what you want to do.

    Do you want to call a different URL if the file is on a different domain?
    e.g.:

    www.myfirst.domain.com/flash.swf -- call www.an.url.com
    www.mysecond.domain.com/flash.swf -- call www.other.url.com

    Then you could simply change the source code and upload two different movies. One movie with the first URL to one domain and a movie with the second URL to the other domain.

    If you don't want to have two different versions you could build a small loader that reads a textfile on the server that contains the URL to be called.

    Tell me if you need additional help.

    Greetings,
    leifi

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Location
    Scotland
    Posts
    5
    Quote Originally Posted by leifi
    Sorry but I don't really understand what you want to do.

    Do you want to call a different URL if the file is on a different domain?
    e.g.:

    www.myfirst.domain.com/flash.swf -- call www.an.url.com
    www.mysecond.domain.com/flash.swf -- call www.other.url.com
    yes - this would work - I don't want to have 2 sets of code ....
    Quote Originally Posted by leifi

    If you don't want to have two different versions you could build a small loader that reads a textfile on the server that contains the URL to be called.

    Tell me if you need additional help.
    This was one of my first thoughts - though I could not see how to do it.

    I had a quick look through the language help and couldn't see how to read a variable from a file - is it possible to ask you to post a code fragment to do this?

    Alternately is there a way of connecting to a MYSQL database and reading data from a table?



    Sincere thanks

  4. #4
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    I've made a small class that you can easily implement into your flash movie. But you need to export to flash 9. Let me know if you want a flash 8 solution.

    Code:
    // Only availible in flash 9 / as3
    
    
    class FileLoader extends Object
    {
    	private var loader:URLLoader;
    	
    	function FileLoader()
    	{
    		this.loader = new URLLoader;
    		this.loader.addEventListener(Event.COMPLETE, loaderComplete);
    		this.loader.addEventListener(IOErrorEvent.IO_ERROR, loaderError);	
    	}
    	
    	function load(path:String):void
    	{
    		var request = new URLRequest(path);
    		this.loader.load(request);
    	}
    	
    	function loaderComplete(event:Event):void
    	{
    		// here you have to change the code...
    		// this.loader.data is the loaded string
    	}
    		
    	function loaderError(event:Event):void
    	{
    		// an error occured...
    	}
    	
    	
    }
    Your starting script has to look like this:
    Code:
    var loader = new FileLoader;
    loader.load("http://yourdomain.com/file.txt");
    And the file has to contain the url:
    Code:
    http://www.an.url.com/

    Let me know if it works!

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