A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Javascript Into Flash

  1. #1
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6

    Javascript Into Flash

    I'm trying to get the enemydown league position javascript to work in flash.

    <script language="JavaScript" src="http://www.enemydown.co.uk/ed_clanrank.php?ladder=5&clan=6081"></script>

    I've got no idea , can someone help me please. x

  2. #2
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6
    anyone?

  3. #3
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6

  4. #4
    Member
    Join Date
    Mar 2004
    Posts
    135

    Re: Javascript Into Flash

    Originally posted by RossMcColl
    I'm trying to get the enemydown league position javascript to work in flash.

    <script language="JavaScript" src="http://www.enemydown.co.uk/ed_clanrank.php?ladder=5&clan=6081"></script>

    I've got no idea , can someone help me please. x
    Would you mind supplying the script so we can see what you are trying to run?

  5. #5
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6
    <script language="JavaScript" src="http://www.enemydown.co.uk/ed_clanrank.php?ladder=5&clan=6081"></script>

    Thats the script.

  6. #6
    Member
    Join Date
    Mar 2004
    Posts
    135
    That is not a script.

  7. #7
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6
    well it says javascript, and when you run it in html is provides a picture depending on where abouts the clan is in the league it changes the picture.

    All I want is for it to work in flash.

  8. #8
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The link is to a PHP script that generates some DHTML (the "javascript") that rewrites the part of your page it's pulled into. This approach will not work in Flash. However, it doesn't mean that you can't make it work, it will just take a bit more effort.

    What you have to do is load the result of calling the PHP script into Flash. Parse the "javascript" and pull out the image reference and then use loadMovie to pull that into a movieclip (assuming it's a JPEG file).

    Here's some code you can use to get the results of the script into a Flash variable where you can start playing with it. Just drop this code into frame 1 of the main timeline of a blank movie and run it to see the results.

    Code:
    LoadVars.prototype.decode = function(str) 
    {
    	
    	this.$pureloadvars = str;
    	var path = this.$pureloadvars;
    	path = path.split("&");
    
    	for (var i = 0; i<path.length; i++) {
    		path[i] = path[i].split("=");
    		this[path[i][0]] = {};
    		this[path[i][0]] = path[i][1];
    	}
    
    };
    
    
    obj = new LoadVars();
    obj.onLoad = function()	{ trace(obj.$pureloadvars); }
    obj.load("http://www.enemydown.co.uk/ed_clanrank.php?ladder=5&clan=6081");

  9. #9
    Member
    Join Date
    Mar 2004
    Posts
    135
    Very nice North. My hat goes off to you.

  10. #10
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    I can't take full credit, the code was shamelessly stolen from John Dowdell and I've found many other uses for it since. I've used it to load and parse HTML pages, load the results of CGI scripts (as I showed above), read local files and just about anything you can specify in a URL. It's a very handly little beast

  11. #11
    Junior Member
    Join Date
    Jan 2005
    Location
    Swindon, England
    Posts
    6
    If I ever see you, I'll buy you a big muffin.

    Cheers

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