• Actionscript 3: Retrieve text from other link?
    13 replies, posted
I'm creating a website for someone and he wants to just be able to type text and have it appear on his Flash-built website without updating the SWF. Is it possible to code a text box of some sort that retrieves the text from an html hosted on the same domain? Like say for example, he has "Hello, this is my website" in a file called "news.html". If possible, how would I code it to receive the text from news.html and put it into the SWF? Thanks in advance for any help.
Why bother with Flash in the first place
[QUOTE=turb_;24578766]Why bother with Flash in the first place[/QUOTE] Because I know how to design in Flash. I've been using it to make cartoons with for 6 years and last year I took a course at school all about basic Actionscript.
[QUOTE=BlueFlash;24579264]Because I know how to design in Flash. I've been using it to make cartoons with for 6 years and last year I took a course at school all about basic Actionscript.[/QUOTE] So you're making a Flash website that loads up HTML. Why not just use HTML in the first place.
Can't you just send the variables via a <param> tag?
[QUOTE=turb_;24579351]So you're making a Flash website that loads up HTML. Why not just use HTML in the first place.[/QUOTE] No, I want text in an html document to appear in the SWF so that the SWF doesn't need to be re-exported every time the guy wants to update the news section, since he doesn't own Flash.
Alright, it's a bit of a hack, but: In a "newstext.php" file: [php] <?php $text = "Hai guis look text lolz"; echo "returnText = $text"; ?> [/php] Then, in your AS3 document: [cpp] var myVars = new LoadVars(); myVars.load("http://path.com/file.php"); myVars.onLoad = function( success ){ if(success){ trace("variables loaded"); trace("The text is: " + myVars.returnText); } else { trace("Error loading page"); } } [/cpp]
lolwut snip
Whoops, ignore my post, that's for AS2.
[CODE] function htmlLoadComplete(e:Event):void{ textbox.htmlText = htmlLoader.data; } var htmlLoader:URLLoader = new URLLoader(); var htmlRequest:URLRequest = new URLRequest("test.html"); htmlLoader.load(htmlRequest); htmlLoader.addEventListener(Event.COMPLETE, htmlLoadComplete); [/CODE] Note: Flash doesn't support every tag, for a list of what's supported look at: [url]http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#htmlText[/url]
You should learn HTML + CSS. It's far better then using just flash for websites. Having flash read from HTML files to work is pretty much the wrong way to do it. I mean if it works and you're THAT good at flash that's cool, but I seriously recommend learning HTML + CSS if you wanna be a decent web developer.
How in gods name has no one told this guy that he should be loading an XML file and not trying to pull text off an HTML file? [editline]12:54PM[/editline] And to be totally blunt OP, if that's not something you knew already you really probably shouldn't be making websites with flash because you're not gig to know enough to optimize load times and set up deep linking and all that stuff that needs to be done to make flash websites not blow hard. Sorry if that sounds a bit harsh, but it's true.
This is a flash bashing party. Anyway, you have two options, using an xml list (which can be dynamically generated via PHP if you want) or you can use swf pass vars. I suggest the xml one.
[QUOTE=KmartSqrl;24621037]How in gods name has no one told this guy that he should be loading an XML file and not trying to pull text off an HTML file? [/QUOTE] Because you beat me too it.
Sorry, you need to Log In to post a reply to this thread.