Re: [Flashcoders] Template w/ XML?
- Original Message From: Jared jared.stan...@gmail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Fri, April 30, 2010 6:16:37 PM Subject: Re: [Flashcoders] Template w/ XML? Try root.loaderinfo.parameters.varname That got me on the right track. I have one little wrinkle to work out of this first attempt. Here's my code: package { imports here class suchandsuch extends MovieClip { var pageDetails:String = new String(); var urlXMLLoader:URLLoader; function suchandsuch() { XMLLoader(); Text(); } function XMLLoader() { var urlXMLRequest:URLRequest = new URLRequest('pageDetails.xml'); urlXMLLoader = new URLLoader(); urlXMLLoader.addEventListener(Event.COMPLETE, completeXMLListener); urlXMLLoader.load(urlXMLRequest); } function completeXMLListener(e:Event):void { var xmlData:XML = XML (e.target.data); pageDetails = xmlData.DETAILS.toString(); } function Text() { more stuff here myText.htmlText = pageDetails; myText.htmlText += Lorem ipsum dolor sitipsum, convallis consequat orci.br /br /; more stuff Now, if I put a trace under this line: myText.htmlText = pageDetails; I get : [object textField] which is what I want. But it doesn't print anything to screen. If I put the following trace under this line: pageDetails = xmlData.DETAILS.toString(); trace(pageDetails); it traces out what I want. No errors. Please advise. TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Template w/ XML?
You're setting the text in the text field before the handler (completeXMLListener) even runs. Also - Text is a bad name for a function, it's common practice for method names to be underlined, and also use non-reserved words. Text is a reserved word in Actionscript. Also - it's also common practice to capitalize class names. Lastly, you should declare your methods as public, private or protected, and specify return types. In this case, I would make them all private. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Singleton Sent: Tuesday, May 04, 2010 8:30 AM To: Flash Coders List Subject: Re: [Flashcoders] Template w/ XML? - Original Message From: Jared jared.stan...@gmail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Fri, April 30, 2010 6:16:37 PM Subject: Re: [Flashcoders] Template w/ XML? Try root.loaderinfo.parameters.varname That got me on the right track. I have one little wrinkle to work out of this first attempt. Here's my code: package { imports here class suchandsuch extends MovieClip { var pageDetails:String = new String(); var urlXMLLoader:URLLoader; function suchandsuch() { XMLLoader(); Text(); } function XMLLoader() { var urlXMLRequest:URLRequest = new URLRequest('pageDetails.xml'); urlXMLLoader = new URLLoader(); urlXMLLoader.addEventListener(Event.COMPLETE, completeXMLListener); urlXMLLoader.load(urlXMLRequest); } function completeXMLListener(e:Event):void { var xmlData:XML = XML (e.target.data); pageDetails = xmlData.DETAILS.toString(); } function Text() { more stuff here myText.htmlText = pageDetails; myText.htmlText += Lorem ipsum dolor sitipsum, convallis consequat orci.br /br /; more stuff Now, if I put a trace under this line: myText.htmlText = pageDetails; I get : [object textField] which is what I want. But it doesn't print anything to screen. If I put the following trace under this line: pageDetails = xmlData.DETAILS.toString(); trace(pageDetails); it traces out what I want. No errors. Please advise. TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Template w/ XML?
- Original Message From: Merrill, Jason jason.merr...@bankofamerica.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tue, May 4, 2010 10:27:57 AM Subject: RE: [Flashcoders] Template w/ XML? You're setting the text in the text field before the handler (completeXMLListener) even runs. That did it! Thanks for the other (bonus?) advise, too! John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Template w/ XML?
On Fri, Apr 30, 2010 at 5:11 PM, John Singleton johnsingleton...@yahoo.comwrote: Right. But that wasn't my question. What I'd like to know is if it's possible to alter how a swf is displayed dependent on variable information. For example: 1) visitor surfs to xyz.php 2) php script calls the template with the swf and feeds it the variable page='xyz'. 3) the template swf renders data based on that. Is that possible? If it is, then I'm sure E4X is the way to go. And if it is possible, can one alter the guts of the page such that one can build tables, include pics, etc? TIA, John Have you tried using FlashVars? http://kb2.adobe.com/cps/164/tn_16417.html http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html For the second part of your question, have you looked into Flash Remoting? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Template w/ XML?
Hi; I've built a template for a Web site that I'd like to use for all pages, but be able to change the content of each page. Now, if I were programming in, say, PHP, I could write a script that could determine which page is being called and then from there call data pertinent only to that page and insert it into the template. I imagine I can do the same thing in AS3, perhaps even in a swf, that would then call data out of, say, an XML file, but how? Any tutorials on this? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Template w/ XML?
hi john xml is the de-facto way of externalising data for flash (there are others but xml is the best imo) and as3 implements e4x (as2 was much more clunky for this) i'd recommend picking up essential actionscript 3 by colin moock ( http://www.amazon.co.uk/Essential-ActionScript-3-0-Colin-Moock/dp/0596526946/ref=sr_1_1?ie=UTF8s=booksqid=1272638172sr=8-1) or friends of ed's foundation actionscript for flash and flex ( http://www.friendsofed.com/book.html?isbn=9781430219187) one of the friends of ed books and digging through that if you're not sure as there's a lot of information, from loading external data to accessing and manipulating that data once it's in flash, to take in the other option is to start digging through the flash help files although i think you'll find this tough going good luck allandt On 30 April 2010 14:17, John Singleton johnsingleton...@yahoo.com wrote: Hi; I've built a template for a Web site that I'd like to use for all pages, but be able to change the content of each page. Now, if I were programming in, say, PHP, I could write a script that could determine which page is being called and then from there call data pertinent only to that page and insert it into the template. I imagine I can do the same thing in AS3, perhaps even in a swf, that would then call data out of, say, an XML file, but how? Any tutorials on this? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Template w/ XML?
- Original Message From: allandt bik-elliott (thefieldcomic.com) alla...@gmail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Fri, April 30, 2010 10:36:24 AM Subject: Re: [Flashcoders] Template w/ XML? hi john xml is the de-facto way of externalising data for flash (there are others but xml is the best imo) and as3 implements e4x (as2 was much more clunky for this) Right. But that wasn't my question. What I'd like to know is if it's possible to alter how a swf is displayed dependent on variable information. For example: 1) visitor surfs to xyz.php 2) php script calls the template with the swf and feeds it the variable page='xyz'. 3) the template swf renders data based on that. Is that possible? If it is, then I'm sure E4X is the way to go. And if it is possible, can one alter the guts of the page such that one can build tables, include pics, etc? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Template w/ XML?
Try root.loaderinfo.parameters.varname Sent from my iPhone On Apr 30, 2010, at 9:11 AM, John Singleton johnsingleton...@yahoo.com wrote: - Original Message From: allandt bik-elliott (thefieldcomic.com) alla...@gmail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Fri, April 30, 2010 10:36:24 AM Subject: Re: [Flashcoders] Template w/ XML? hi john xml is the de-facto way of externalising data for flash (there are others but xml is the best imo) and as3 implements e4x (as2 was much more clunky for this) Right. But that wasn't my question. What I'd like to know is if it's possible to alter how a swf is displayed dependent on variable information. For example: 1) visitor surfs to xyz.php 2) php script calls the template with the swf and feeds it the variable page='xyz'. 3) the template swf renders data based on that. Is that possible? If it is, then I'm sure E4X is the way to go. And if it is possible, can one alter the guts of the page such that one can build tables, include pics, etc? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders