Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Hi, This article written by Steven looks just like what you are looking for... http://www.stevensacks.net/2008/07/02/parsing-xhtml-with-e4x-in-as3/ To keep your formatting, you can use css - the TextField in Flash supports a subset of css that allows you to apply bold, colours and link formatting... Not sure if you are searching for EX4 or E4X! HTH Glen Jonathan Wing wrote: Hi, I'm new to this group, so forgive me if I'm going about asking this the wrong way. Is there a practical way to search old questions? Anyway, I'm using the Gaia Framework and I'm trying to parse basic tags such as h1 and a in flash via an XHTML file. Steven over at the Gaia forum suggests I make use of EX4, but I've spent two days searching google and reading up on it and I'm honestly confused where to start. To show you what I mean, view the source on this page Steven created: http://stevensacks.net/clients/hello/press.html#/agency/press Note how those columns are set using HTML tags, and pulled into flash from that XHTML file. How do I maintain the formatting such as bold and also the links, just the way he has done (strictly in terms of functionality)? Thank you! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com mailto:jw...@cramcrew.com www.cramcrew.com http://www.cramcrew.com/ One Student At A Time The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ___ 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] Parsing HTML tags within flash from an XHTML file?
Well, I have actually searched over and over and I have read and re-read Steven's article as well, but I can't seem to get it just right. I think the problem is, Steven's article is written to an audience of more experienced AS coders (at least it seems so), and I'm pretty new to AS, so I don't get the context. The article does not state exactly *where* to put such code in my files, just that I need to do it. So I took some guesses and tried multiple ways, yet still to no avail. Yet I didn't want to bother him, as I've already asked him so many noob questions! Mostly what I'm concerned about are parsing the h1 and a tags. Do you have any suggestions as to how and where I can implement Steven's points in his article? Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Thursday, May 21, 2009 3:21 AM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Hi, This article written by Steven looks just like what you are looking for... http://www.stevensacks.net/2008/07/02/parsing-xhtml-with-e4x-in-as3/ To keep your formatting, you can use css - the TextField in Flash supports a subset of css that allows you to apply bold, colours and link formatting... Not sure if you are searching for EX4 or E4X! HTH Glen Jonathan Wing wrote: Hi, I'm new to this group, so forgive me if I'm going about asking this the wrong way. Is there a practical way to search old questions? Anyway, I'm using the Gaia Framework and I'm trying to parse basic tags such as h1 and a in flash via an XHTML file. Steven over at the Gaia forum suggests I make use of EX4, but I've spent two days searching google and reading up on it and I'm honestly confused where to start. To show you what I mean, view the source on this page Steven created: http://stevensacks.net/clients/hello/press.html#/agency/press Note how those columns are set using HTML tags, and pulled into flash from that XHTML file. How do I maintain the formatting such as bold and also the links, just the way he has done (strictly in terms of functionality)? Thank you! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com mailto:jw...@cramcrew.com www.cramcrew.com http://www.cramcrew.com/ One Student At A Time The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ___ 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 The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
If it's truly XHTML, you can in theory parse it as XML - but if it's not, meaning they mixed case and didn't close tags, then you're out of luck. First things first, do you know how to load in XML? Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 11:08 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I have actually searched over and over and I have read and re-read Steven's article as well, but I can't seem to get it just right. I think the problem is, Steven's article is written to an audience of more experienced AS coders (at least it seems so), and I'm pretty new to AS, so I don't get the context. The article does not state exactly *where* to put such code in my files, just that I need to do it. So I took some guesses and tried multiple ways, yet still to no avail. Yet I didn't want to bother him, as I've already asked him so many noob questions! Mostly what I'm concerned about are parsing the h1 and a tags. Do you have any suggestions as to how and where I can implement Steven's points in his article? Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Thursday, May 21, 2009 3:21 AM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Hi, This article written by Steven looks just like what you are looking for... http://www.stevensacks.net/2008/07/02/parsing-xhtml-with-e4x-in-as3/ To keep your formatting, you can use css - the TextField in Flash supports a subset of css that allows you to apply bold, colours and link formatting... Not sure if you are searching for EX4 or E4X! HTH Glen Jonathan Wing wrote: Hi, I'm new to this group, so forgive me if I'm going about asking this the wrong way. Is there a practical way to search old questions? Anyway, I'm using the Gaia Framework and I'm trying to parse basic tags such as h1 and a in flash via an XHTML file. Steven over at the Gaia forum suggests I make use of EX4, but I've spent two days searching google and reading up on it and I'm honestly confused where to start. To show you what I mean, view the source on this page Steven created: http://stevensacks.net/clients/hello/press.html#/agency/press Note how those columns are set using HTML tags, and pulled into flash from that XHTML file. How do I maintain the formatting such as bold and also the links, just the way he has done (strictly in terms of functionality)? Thank you! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com mailto:jw...@cramcrew.com www.cramcrew.com http://www.cramcrew.com/ One Student At A Time The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ___ 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 The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Well, I think I know how to import XML. var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, getXML); loader.load(new URLRequest(http://xmlfeedURL;)); function getXML(event:Event):void { var xmlData:XML = new XML(event.target.data); trace(xmlData); } At least, that is the code I picked up while doing research, though I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now, minus the irrelevant code: package pages { import flash.xml.*; import flash.text.TextField; XML.ignoreWhitespace = false; XML.prettyPrinting = false; public class HomePage extends AbstractPage { public var dynamic_text:TextField; override public function transitionIn():void { super.transitionIn(); TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); dynamic_text.text = this.copy.intro; } [there's a lot more code, but I'm only focusing on the relevant parts from the XHTML page] } } So what it does is pull info from this content in my XHTML page: div id=copy p id=introLorem ipsum/p /div And places that Lorem ipsum in my corresponding MC with an instance name of dynamic_text. But then, if I want to do something like: div id=copy p id=introh1Lorem ipsum/h1 a href=page.swfClick here/a to learn more. /p/div It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Now, Steven's suggestions in his article seem helpful, but since I am pretty new to this sort of code, I am still unsure as to where things should go, and how to make it work for h1 and a tags. I'm not planning to use many other tags, as I am trying to keep things simple. Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, May 21, 2009 10:13 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? If it's truly XHTML, you can in theory parse it as XML - but if it's not, meaning they mixed case and didn't close tags, then you're out of luck. First things first, do you know how to load in XML? Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 11:08 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I have actually searched over and over and I have read and re-read Steven's article as well, but I can't seem to get it just right. I think the problem is, Steven's article is written to an audience of more experienced AS coders (at least it seems so), and I'm pretty new to AS, so I don't get the context. The article does not state exactly *where* to put such code in my files, just that I need to do it. So I took some guesses and tried multiple ways, yet still to no avail. Yet I didn't want to bother him, as I've already asked him so many noob questions! Mostly what I'm concerned about are parsing the h1 and a tags. Do you have any suggestions as to how and where I can implement Steven's points in his article? Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Thursday, May 21, 2009 3:21 AM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Hi, This article written by Steven looks just like what you are looking for... http://www.stevensacks.net/2008/07/02/parsing-xhtml-with-e4x-in-as3/ To keep your formatting, you can use css - the TextField in Flash supports a subset of css that allows you to apply bold, colours and link formatting... Not sure if you are searching for EX4 or E4X! HTH Glen Jonathan Wing wrote: Hi, I'm new to this group, so forgive me if I'm going about asking this the wrong way. Is there a practical way to search old questions? Anyway, I'm using the Gaia
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Well, part of your question is a Gaia framework question which is off-topic for this forum. I don't know much about that framework other than it's purpose and creator. As for your question about the tags parsing: It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Two issues: 1) Flash only has a limited set of tags it supports in HTML for text. Tags like div and h1 I don't believe are one of them. You could read the XHTML in as a string (not XML right away) and use a Regular Expression to remove those tags from the text and insert something else if you like, however: 2) The entire XHTML should be treated as XML, so that means tags like p will be treated as an XML node, not a new HTML text paragraph. So you may have to use some Regular Expressions to at least add a ![CDATA[ before and ]] to wrap around the text you want to read in the HTML so it escapes the characters. THEN convert the string to XML once it's clean. In short, what you're asking to do is pretty challenging. Flash isn't really set up to read and render HTML pages. It's mean to take the place of them. :) Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 1:14 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I think I know how to import XML. var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, getXML); loader.load(new URLRequest(http://xmlfeedURL;)); function getXML(event:Event):void { var xmlData:XML = new XML(event.target.data); trace(xmlData); } At least, that is the code I picked up while doing research, though I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now, minus the irrelevant code: package pages { import flash.xml.*; import flash.text.TextField; XML.ignoreWhitespace = false; XML.prettyPrinting = false; public class HomePage extends AbstractPage { public var dynamic_text:TextField; override public function transitionIn():void { super.transitionIn(); TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); dynamic_text.text = this.copy.intro; } [there's a lot more code, but I'm only focusing on the relevant parts from the XHTML page] } } So what it does is pull info from this content in my XHTML page: div id=copy p id=introLorem ipsum/p /div And places that Lorem ipsum in my corresponding MC with an instance name of dynamic_text. But then, if I want to do something like: div id=copy p id=introh1Lorem ipsum/h1 a href=page.swfClick here/a to learn more. /p/div It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Now, Steven's suggestions in his article seem helpful, but since I am pretty new to this sort of code, I am still unsure as to where things should go, and how to make it work for h1 and a tags. I'm not planning to use many other tags, as I am trying to keep things simple. Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, May 21, 2009 10:13 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? If it's truly XHTML, you can in theory parse it as XML - but if it's not, meaning they mixed case and didn't close tags, then you're out of luck. First things first, do you know how to load in XML? Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 11:08 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I have actually searched over and over and I have read and re-read Steven's
Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Hi, Once you have loaded your XML and put it into your dynamic text field, you can set the styleSheet property to that of a loaded a valid css file... http://snipplr.com/view/4452/as3-load-external-txt-and-css/ Load your style sheet first, then apply it to your text field after you set the content with your XML... Hope this helps a bit. Glen Jonathan Wing wrote: Well, I think I know how to import XML. var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, getXML); loader.load(new URLRequest(http://xmlfeedURL;)); function getXML(event:Event):void { var xmlData:XML = new XML(event.target.data); trace(xmlData); } At least, that is the code I picked up while doing research, though I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now, minus the irrelevant code: package pages { import flash.xml.*; import flash.text.TextField; XML.ignoreWhitespace = false; XML.prettyPrinting = false; public class HomePage extends AbstractPage { public var dynamic_text:TextField; override public function transitionIn():void { super.transitionIn(); TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); dynamic_text.text = this.copy.intro; } [there's a lot more code, but I'm only focusing on the relevant parts from the XHTML page] } } So what it does is pull info from this content in my XHTML page: div id=copy p id=introLorem ipsum/p /div And places that Lorem ipsum in my corresponding MC with an instance name of dynamic_text. But then, if I want to do something like: div id=copy p id=introh1Lorem ipsum/h1 a href=page.swfClick here/a to learn more. /p/div It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Now, Steven's suggestions in his article seem helpful, but since I am pretty new to this sort of code, I am still unsure as to where things should go, and how to make it work for h1 and a tags. I'm not planning to use many other tags, as I am trying to keep things simple. Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, May 21, 2009 10:13 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? If it's truly XHTML, you can in theory parse it as XML - but if it's not, meaning they mixed case and didn't close tags, then you're out of luck. First things first, do you know how to load in XML? Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 11:08 AM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I have actually searched over and over and I have read and re-read Steven's article as well, but I can't seem to get it just right. I think the problem is, Steven's article is written to an audience of more experienced AS coders (at least it seems so), and I'm pretty new to AS, so I don't get the context. The article does not state exactly *where* to put such code in my files, just that I need to do it. So I took some guesses and tried multiple ways, yet still to no avail. Yet I didn't want to bother him, as I've already asked him so many noob questions! Mostly what I'm concerned about are parsing the h1 and a tags. Do you have any suggestions as to how and where I can implement Steven's points in his article? Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Thursday, May 21, 2009 3:21 AM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Hi, This article written by Steven looks just like what you are looking for... http://www.stevensacks.net/2008/07/02/parsing-xhtml-with-e4x-in-as3/ To keep your formatting, you can use css - the TextField in Flash supports a subset of css
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Jason, The funny thing is, Steven said that my question was a bit off-topic for the Gaia forum, and recommended I try this place. ;) I know it's possible as I've seen it done, for example, on Steven's page here: http://stevensacks.net/clients/hello/press.html#/agency/press (if you look at the code, it's pretty straightforward HTML tags, without CDATA around them) And also: http://flashden.net/item/elite-html-content-page-with-scroller/full_scre en_preview/27908 (but that is using AS2, and I'm coding the site in AS3). If I may explain, basically all I'm trying to do is create SEO-friendly XHTML pages on which the written content for each page is stored and that is where I will pull the content from. On occasion, I will need to provide links to other pages. If anyone knows of a better way of doing this, I'm all ears! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, May 21, 2009 12:29 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, part of your question is a Gaia framework question which is off-topic for this forum. I don't know much about that framework other than it's purpose and creator. As for your question about the tags parsing: It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Two issues: 1) Flash only has a limited set of tags it supports in HTML for text. Tags like div and h1 I don't believe are one of them. You could read the XHTML in as a string (not XML right away) and use a Regular Expression to remove those tags from the text and insert something else if you like, however: 2) The entire XHTML should be treated as XML, so that means tags like p will be treated as an XML node, not a new HTML text paragraph. So you may have to use some Regular Expressions to at least add a ![CDATA[ before and ]] to wrap around the text you want to read in the HTML so it escapes the characters. THEN convert the string to XML once it's clean. In short, what you're asking to do is pretty challenging. Flash isn't really set up to read and render HTML pages. It's mean to take the place of them. :) Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 1:14 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I think I know how to import XML. var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, getXML); loader.load(new URLRequest(http://xmlfeedURL;)); function getXML(event:Event):void { var xmlData:XML = new XML(event.target.data); trace(xmlData); } At least, that is the code I picked up while doing research, though I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now, minus the irrelevant code: package pages { import flash.xml.*; import flash.text.TextField; XML.ignoreWhitespace = false; XML.prettyPrinting = false; public class HomePage extends AbstractPage { public var dynamic_text:TextField; override public function transitionIn():void { super.transitionIn(); TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); dynamic_text.text = this.copy.intro; } [there's a lot more code, but I'm only focusing on the relevant parts from the XHTML page] } } So what it does is pull info from this content in my XHTML page: div id=copy p id=introLorem ipsum/p /div And places that Lorem ipsum in my corresponding MC with an instance name of dynamic_text. But then, if I want to do something like: div id=copy p id=introh1Lorem ipsum/h1 a href=page.swfClick here/a to learn more. /p/div It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Now, Steven's suggestions in his article seem helpful, but since I am pretty new to this sort of code, I am still unsure as to where things should go, and how to make it work for h1 and a tags. I'm not planning to use many other tags
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
The funny thing is, Steven said that my question was a bit off-topic for the Gaia forum, and recommended I try this place. ;) I was talking about your doing this in Gaia part and I'm sure Steven was talking about the parsing XHTML part. This is what promoted me: I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now For that, the Gaia forum is more approprite. You're talking about two problems - 1) How to load and parse XHTML amd 2) how to use that data, once loaded as XML, into Gaia. #1 is for here. #2 is for the Gaia forum. Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 1:49 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Jason, The funny thing is, Steven said that my question was a bit off-topic for the Gaia forum, and recommended I try this place. ;) I know it's possible as I've seen it done, for example, on Steven's page here: http://stevensacks.net/clients/hello/press.html#/agency/press (if you look at the code, it's pretty straightforward HTML tags, without CDATA around them) And also: http://flashden.net/item/elite-html-content-page-with-scroller/full_scre en_preview/27908 (but that is using AS2, and I'm coding the site in AS3). If I may explain, basically all I'm trying to do is create SEO-friendly XHTML pages on which the written content for each page is stored and that is where I will pull the content from. On occasion, I will need to provide links to other pages. If anyone knows of a better way of doing this, I'm all ears! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, May 21, 2009 12:29 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, part of your question is a Gaia framework question which is off-topic for this forum. I don't know much about that framework other than it's purpose and creator. As for your question about the tags parsing: It will not parse the HTML tags; it will treat them like a regular string of text, even though my text box has render text as HTML selected. Two issues: 1) Flash only has a limited set of tags it supports in HTML for text. Tags like div and h1 I don't believe are one of them. You could read the XHTML in as a string (not XML right away) and use a Regular Expression to remove those tags from the text and insert something else if you like, however: 2) The entire XHTML should be treated as XML, so that means tags like p will be treated as an XML node, not a new HTML text paragraph. So you may have to use some Regular Expressions to at least add a ![CDATA[ before and ]] to wrap around the text you want to read in the HTML so it escapes the characters. THEN convert the string to XML once it's clean. In short, what you're asking to do is pretty challenging. Flash isn't really set up to read and render HTML pages. It's mean to take the place of them. :) Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Jonathan Wing Sent: Thursday, May 21, 2009 1:14 PM To: Flash Coders List Subject: RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Well, I think I know how to import XML. var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, getXML); loader.load(new URLRequest(http://xmlfeedURL;)); function getXML(event:Event):void { var xmlData:XML = new XML(event.target.data); trace(xmlData); } At least, that is the code I picked up while doing research, though I'm not entirely sure how to use any of that to apply to what I'm doing in the Gaia Framework. This is what I have now, minus the irrelevant code: package pages { import flash.xml.*; import flash.text.TextField; XML.ignoreWhitespace = false; XML.prettyPrinting = false; public class HomePage extends AbstractPage { public var dynamic_text:TextField; override
Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
http://www.gaiaflashframework.com/index.php/topic,1847.msg7817.html#msg7817 Just so everyone is familiar with the context here, the above is the thread on the forum about this. The question is about how to use E4X to parse XHTML. I provide a code example of how easy it is to do this, but Jonathan's question is more of a general one about how to use E4X to parse nodes. Flash doesn't support div in its htmlText, so that's why you use E4X to grab the node content like var value:XML = XMLList(copy.innerHTML)[0]; var body:XML = value.div.(@id == body)[0]; I believe the challenge for Jonathan is what the above lines of code mean and how they work. value is the XHTML. value.div returns an XMLList of all div nodes on the first level within the XHTML. value.div.(@id == body) means give me an XMLList of the div nodes that have an attribute id=body. valid.div.(@id == body)[0] means give me the first XML node in that XMLList. This is how E4X works. A lesson on E4X is out of scope of my forum. However, there are lots of resources out there for E4X in AS3. I highly recommend Colin Moock's Essential Actionscript 3.0 book, which is how I learned it. That and the internet. And Jason, you do not need to complicate things with RegEx. E4X does enough. XHTML is technically XML and can be parsed the same using E4X. Also, while Flash doesn't SEEM to support newer HTML tags like strong and em for b and i, it actually DOES if you write css to do it. strong { font-family: FFScala-Bold; display: inline; } em { font-family: FFScala-Italic; display: inline; } In this case, I am using a bold and italic font to show them, and by defining the node types in css (and setting them to display: inline), it works like a champ! Here's a detailed code sample: http://www.gaiaflashframework.com/wiki/index.php?title=Runtime_Font_Loading#StyleSheet_Example Now, I can keep my valid XHTML and use it directly in Flash. It's really straightforward. The challenge is learning how to parse the nodes using E4X, which, once you get your head around it (and it took me a lot of experimenting to learn how awesome and powerful E4X is and how to leverage it), you can do stuff like this easily. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Thanks Steven! That clears a few things up, and like you suggest, I will experiment with it until I get it just right. The only reason I've been so anxious is that I'm working on a deadline; so, for the time being, may I simply ask you this? What is the best (and most SEO-friendly) way of presenting links within the copy content? Should I be doing this within the XHTML using a tags to other swf files, or is there a better method? I guess that is the only thing I'm getting hung up on, as my pages will occasionally have links within the body paragraphs. Okay, so I figured out one thing that helps, which is to set my text fields to htmlText (it was only text before). That helps a lot, and it appears that the links are showing up and they function--sorta. They actually want to open a new page, even if a swf, and even if the target is set to _self. Really, all I want to do (on my deadline) is have links from one swf to another in the website, but have it all be SEO-friendly. Should be pretty simple, right? I bet I'm making it more complicated for myself than it probably needs to be. ;) My I present my own guess, and you could tell me if I'm wrong? I'm guessing it has something to do with the following, which I found in the Gaia demo site (I'm pasting only what I assume is the relevant code): public var textContent:TextField; var myStyleSheet = new StyleSheet as StyleSheet; var myURL:String; var mySection:XMLList; myURL = Gaia.api.getCurrentBranch(); myStyleSheet = IStyleSheet(Gaia.api.getPage(index).assets.xmlCss).style; textContent.styleSheet = myStyleSheet for each ( var u:XML in mySection) { if (myURL == u...@url) { textContent.htmlText = u.copy; } Could I use this in tandem with my Gaia-produced XHTML pages? I do not see where the actual copy node is included in the instance from the demo site's XML, but only the url part. How is the rest of the text being included? Sorry to be impatient! I just did not expect this specific aspect of development to feel like starting from scratch! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks Sent: Thursday, May 21, 2009 1:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? http://www.gaiaflashframework.com/index.php/topic,1847.msg7817.html#msg7 817 Just so everyone is familiar with the context here, the above is the thread on the forum about this. The question is about how to use E4X to parse XHTML. I provide a code example of how easy it is to do this, but Jonathan's question is more of a general one about how to use E4X to parse nodes. Flash doesn't support div in its htmlText, so that's why you use E4X to grab the node content like var value:XML = XMLList(copy.innerHTML)[0]; var body:XML = value.div.(@id == body)[0]; I believe the challenge for Jonathan is what the above lines of code mean and how they work. value is the XHTML. value.div returns an XMLList of all div nodes on the first level within the XHTML. value.div.(@id == body) means give me an XMLList of the div nodes that have an attribute id=body. valid.div.(@id == body)[0] means give me the first XML node in that XMLList. This is how E4X works. A lesson on E4X is out of scope of my forum. However, there are lots of resources out there for E4X in AS3. I highly recommend Colin Moock's Essential Actionscript 3.0 book, which is how I learned it. That and the internet. And Jason, you do not need to complicate things with RegEx. E4X does enough. XHTML is technically XML and can be parsed the same using E4X. Also, while Flash doesn't SEEM to support newer HTML tags like strong and em for b and i, it actually DOES if you write css to do it. strong { font-family: FFScala-Bold; display: inline; } em { font-family: FFScala-Italic; display: inline; } In this case, I am using a bold and italic font to show them, and by defining the node types in css (and setting them to display: inline), it works like a champ! Here's a detailed code sample: http://www.gaiaflashframework.com/wiki/index.php?title=Runtime_Font_Load ing#StyleSheet_Example Now, I can keep my valid XHTML and use it directly in Flash. It's really straightforward. The challenge is learning how to parse the nodes using E4X, which, once you get your head around it (and it took me a lot of experimenting to learn how awesome and powerful E4X is and how to leverage it), you can do stuff like this easily. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Do you mean you want to have links in your a tags that call Gaia.api.goto()? You can do that, but obviously, those links wouldn't work in the XHTML. After thinking about it a bit, I think what might work is this a href=contact.htmlGo to contact page/a With that being the link to the SEO XHTML page that is generated for that page. In your parsing code, you would change the href to call an actionscript method that would take page.html and convert it to var href:String = a...@href; href = href.substr(0, href.length - 4); var internalTitle:String = href.toUpperCase(); Gaia.api.goto(Pages[internalTitle]); That is just an example, but basically you're converting contact.html to CONTACT and, there should be a public static const in Pages called CONTACT which has the branch for that title. Does this make sense? (this part of the question is definitely appropriate for the Gaia forum, too) On May 21, 2009, at 12:29 PM, Jonathan Wing wrote: Thanks Steven! That clears a few things up, and like you suggest, I will experiment with it until I get it just right. The only reason I've been so anxious is that I'm working on a deadline; so, for the time being, may I simply ask you this? What is the best (and most SEO-friendly) way of presenting links within the copy content? Should I be doing this within the XHTML using a tags to other swf files, or is there a better method? I guess that is the only thing I'm getting hung up on, as my pages will occasionally have links within the body paragraphs. Okay, so I figured out one thing that helps, which is to set my text fields to htmlText (it was only text before). That helps a lot, and it appears that the links are showing up and they function--sorta. They actually want to open a new page, even if a swf, and even if the target is set to _self. Really, all I want to do (on my deadline) is have links from one swf to another in the website, but have it all be SEO-friendly. Should be pretty simple, right? I bet I'm making it more complicated for myself than it probably needs to be. ;) My I present my own guess, and you could tell me if I'm wrong? I'm guessing it has something to do with the following, which I found in the Gaia demo site (I'm pasting only what I assume is the relevant code): public var textContent:TextField; var myStyleSheet = new StyleSheet as StyleSheet; var myURL:String; var mySection:XMLList; myURL = Gaia.api.getCurrentBranch(); myStyleSheet = IStyleSheet(Gaia.api.getPage(index).assets.xmlCss).style; textContent.styleSheet = myStyleSheet for each ( var u:XML in mySection) { if (myURL == u...@url) { textContent.htmlText = u.copy; } Could I use this in tandem with my Gaia-produced XHTML pages? I do not see where the actual copy node is included in the instance from the demo site's XML, but only the url part. How is the rest of the text being included? Sorry to be impatient! I just did not expect this specific aspect of development to feel like starting from scratch! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks Sent: Thursday, May 21, 2009 1:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? http://www.gaiaflashframework.com/index.php/topic,1847.msg7817.html#msg7 817 Just so everyone is familiar with the context here, the above is the thread on the forum about this. The question is about how to use E4X to parse XHTML. I provide a code example of how easy it is to do this, but Jonathan's question is more of a general one about how to use E4X to parse nodes. Flash doesn't support div in its htmlText, so that's why you use E4X to grab the node content like var value:XML = XMLList(copy.innerHTML)[0]; var body:XML = value.div.(@id == body)[0]; I believe the challenge for Jonathan is what the above lines of code mean and how they work. value is the XHTML. value.div returns an XMLList of all div nodes on the first level within the XHTML. value.div.(@id == body) means give me an XMLList of the div nodes that have an attribute id=body. valid.div.(@id == body)[0] means give me the first XML node in that XMLList. This is how E4X works. A lesson on E4X is out of scope of my forum. However, there are lots of resources out there for E4X in AS3. I highly recommend Colin Moock's Essential Actionscript 3.0 book, which is how I learned it. That and the internet. And Jason, you do not need to complicate things with RegEx. E4X does enough. XHTML is technically XML and can be parsed the same using E4X. Also, while Flash doesn't SEEM to support
RE: [Flashcoders] Parsing HTML tags within flash from an XHTML file?
Steven, It does make sense for the most part, except that I'm not sure if I'm placing it in the right place. I have it in my HomePage.as file (just using this page as an example, as I assumed that was what you might have meant when you said parsing code), and I guess I need to define a or put it in the right place? Because right now, it gives me an error #1120: Access of undefined property a. This is how I put it in my code (minus some of the extra stuff): public class HomePage extends AbstractPage { public var dynamic_text:TextField; public function HomePage() { super(); alpha = 0; } override public function transitionIn():void { super.transitionIn(); TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); var href:String = a...@href; href = href.substr(0, href.length - 4); var internalTitle:String = href.toUpperCase(); Gaia.api.goto(Pages[internalTitle]); dynamic_text.htmlText = this.copy.intro; } } Sorry to paste it directly into my code like that; it's just that I can only guess where it might go... Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com www.cramcrew.com One Student At A Time -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks Sent: Thursday, May 21, 2009 2:57 PM To: Flash Coders List Subject: Re: [Flashcoders] Parsing HTML tags within flash from an XHTML file? Do you mean you want to have links in your a tags that call Gaia.api.goto()? You can do that, but obviously, those links wouldn't work in the XHTML. After thinking about it a bit, I think what might work is this a href=contact.htmlGo to contact page/a With that being the link to the SEO XHTML page that is generated for that page. In your parsing code, you would change the href to call an actionscript method that would take page.html and convert it to var href:String = a...@href; href = href.substr(0, href.length - 4); var internalTitle:String = href.toUpperCase(); Gaia.api.goto(Pages[internalTitle]); That is just an example, but basically you're converting contact.html to CONTACT and, there should be a public static const in Pages called CONTACT which has the branch for that title. Does this make sense? (this part of the question is definitely appropriate for the Gaia forum, too) On May 21, 2009, at 12:29 PM, Jonathan Wing wrote: Thanks Steven! That clears a few things up, and like you suggest, I will experiment with it until I get it just right. The only reason I've been so anxious is that I'm working on a deadline; so, for the time being, may I simply ask you this? What is the best (and most SEO-friendly) way of presenting links within the copy content? Should I be doing this within the XHTML using a tags to other swf files, or is there a better method? I guess that is the only thing I'm getting hung up on, as my pages will occasionally have links within the body paragraphs. Okay, so I figured out one thing that helps, which is to set my text fields to htmlText (it was only text before). That helps a lot, and it appears that the links are showing up and they function--sorta. They actually want to open a new page, even if a swf, and even if the target is set to _self. Really, all I want to do (on my deadline) is have links from one swf to another in the website, but have it all be SEO-friendly. Should be pretty simple, right? I bet I'm making it more complicated for myself than it probably needs to be. ;) My I present my own guess, and you could tell me if I'm wrong? I'm guessing it has something to do with the following, which I found in the Gaia demo site (I'm pasting only what I assume is the relevant code): public var textContent:TextField; var myStyleSheet = new StyleSheet as StyleSheet; var myURL:String; var mySection:XMLList; myURL = Gaia.api.getCurrentBranch(); myStyleSheet = IStyleSheet(Gaia.api.getPage(index).assets.xmlCss).style; textContent.styleSheet = myStyleSheet for each ( var u:XML in mySection) { if (myURL == u...@url) { textContent.htmlText = u.copy; } Could I use this in tandem with my Gaia-produced XHTML pages? I do not see where the actual copy node is included in the instance from the demo site's XML, but only the url part. How is the rest of the text being included? Sorry to be impatient! I just
[Flashcoders] Parsing HTML tags within flash from an XHTML file?
Hi, I'm new to this group, so forgive me if I'm going about asking this the wrong way. Is there a practical way to search old questions? Anyway, I'm using the Gaia Framework and I'm trying to parse basic tags such as h1 and a in flash via an XHTML file. Steven over at the Gaia forum suggests I make use of EX4, but I've spent two days searching google and reading up on it and I'm honestly confused where to start. To show you what I mean, view the source on this page Steven created: http://stevensacks.net/clients/hello/press.html#/agency/press Note how those columns are set using HTML tags, and pulled into flash from that XHTML file. How do I maintain the formatting such as bold and also the links, just the way he has done (strictly in terms of functionality)? Thank you! Thanks, Jonathan Wing Graphic Designer Cram Crew, Inc. mobile: (713) 298-2738 office: (713) 464-CRAM (2726) email: jw...@cramcrew.com mailto:jw...@cramcrew.com www.cramcrew.com http://www.cramcrew.com/ One Student At A Time The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, business-confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders