2

I'm trying to read some text from a website (external domain) and display that in my flash movie, is there a beginner friendly way of doing this ?

The text on the html page is placed in containers (I can change it if that makes things easier)

<div id="price1">200$</div>
<div id="price2">500$</div>
<div id="price3">600$</div>

How do I do this ?

I've been reading through the AS3 help pages (Using the ExternalInterface class) but couldn't find anything that suits my needs.

  • You want to load html file into swf object? or you want to pass variables to swf object ? – Ivan Chernykh Nov 17 '13 at 11:49
  • I want to show the content of these 3 div's as 3 separate texts in the SWF – Verena Kolb Nov 17 '13 at 12:01
  • your swf is placed on the same page? – Ivan Chernykh Nov 17 '13 at 12:02
  • No, the html file with the content is on external domain. As far as I understand using URLLoader + AllowScriptAccess = Always should work ? I just don't know how to code it together, or is there a simpler way ? – Verena Kolb Nov 17 '13 at 12:06
  • *By default, the calling SWF file and the URL you load must be in exactly the same domain* , from here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html – Ivan Chernykh Nov 17 '13 at 12:12
  • Thanks for reference. So is there no other way ? – Verena Kolb Nov 17 '13 at 12:29
  • 2
    IMHO one way might be to create something like proxy with some server side technology, ex PHP, so PHP might parse the page from where you need to grab data (that DIVs for for example) and Flash will call this PHP script with URLRequest and get well formated data from it. PHP can be anyware on your server, you just need to set crossdomain.xml and it would work for the Flash without problem. – gMirian Nov 17 '13 at 13:54
  • Well the problem is, this is going to be a banner, and i'll place it on some advertising network, the only thing I know is that allowscriptaccess will be set to always. So I really only have access to that html file where the text is fetched from. – Verena Kolb Nov 17 '13 at 16:20

1 Answers1

0

First off, sorry for not commenting - but my reputatnion is too low.

Loading separate document using URLLoader is possible only if domain you're loading from has crossdomain.xml file set with wildcard settings. Otherwise you'll get SecurityError trying to load anything from that url.

If this can be done, and you have page loaded to flash, and these divs have id's you can create a regular expression and search for them, or try to create XML object passing string loaded - it's unlikely to work, but you can always try. And with XML you can access nodes using E4X in AS3.

Szczups
  • 131
  • 4