Ahh yes, I thought it would be simple to just stuff the old TextFormat in an 
attribute. I now save each node with an attribute for each TextFormat property.
All is good!

-Gerry

On Jan 12, 2011, at 3:17 PM, Merrill, Jason wrote:

> Take a peek at what the textformat property is asking for.  You're 
> essentially trying to set "[object Textformat]", which is a string.  You 
> can't create a textformat by saying, "[object TextFormat]" as TextFormat. 
> Plus, [object TextFormat] is now how you dynamically refer to classes, even 
> if that's what Flash spits out in the Output window. Nice try. :) 
> 
> As I posted earlier today in a separate thread, you can use 
> getDefinitionByName() to create instances of classes from Strings(like you 
> are trying to do with your XML), but a textFormat object also has specific 
> values (color, font, font size, etc) so you would want to set those as well - 
> say store those in XML.
> 
> I think a better approach is to store font colors, sizes, etc. in the XML, 
> and read those out and set those on a TextFormat object instance you create 
> with code, and apply to your textfield.
> 
> 
> 
> Jason Merrill
> Instructional Technology Architect
> Bank of America  Global Learning 
> 
> 
> 
> 
> 
> _______________________
> 
> 
> -----Original Message-----
> From: flashcoders-boun...@chattyfig.figleaf.com 
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Gerry
> Sent: Wednesday, January 12, 2011 2:54 PM
> To: Flashcoders@chattyfig.figleaf.com
> Subject: [Flashcoders] XML attribute issue
> 
> Hey all,
> I'm parsing this xml and can't get one attribute to work as a TextFormat.
> I have an app that saves XML of objects on the screen, each object has a 
> TextFormat attached to it so I save the XML node with attributes for x, y, 
> text  and Textformat. Below is what is returned to me when I load a 
> previously saved XML.
> 
> <TemplateXML>
>  <TextLayer xpos="83" ypos="39" label="Wowie" format="[object TextFormat]"/>
>  <TextLayer xpos="16" ypos="150" label="italic text" format="[object 
> TextFormat]"/>
>  <TextLayer xpos="88" ypos="250" label="My New Album Label" format="[object 
> TextFormat]"/>
>  <TextLayer xpos="250" ypos="148" label="Side A" format="[object 
> TextFormat]"/> </TemplateXML>
> 
> You can see the format attribute is saved as a TextFormat object but when I 
> parse it I get errors saying that it is an XMLList.
> 
> Here is the method to parse the XML:
> 
> var savedXML:XMLList = custXML.TemplateXML;
> 
>     for each(var lab:XML in savedXML.TextLayer){
>                var labelText:String = String(l...@label);
>                var x_pos:Number = l...@xpos;
>                var y_pos:Number = l...@ypos;
>                var savedFMT:TextFormat = l...@format as TextFormat;
>                trace("New Label:"+labelText+"\nx pos:"+x_pos+"\ny 
> pos:"+y_pos+"\nformat?"+savedFMT.font);//this throws errors
> 
>                recreateLayer(labelText,x_pos,y_pos,fmt);//this creates a new 
> MovieClip with a textField in it and positions it on the stage.
>        }
> 
> 
> Any tips would be helpful.
> 
> Thanks,
> 
> -Gerry_______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> ----------------------------------------------------------------------
> This message w/attachments (message) is intended solely for the use of the 
> intended recipient(s) and may contain information that is privileged, 
> confidential or proprietary. If you are not an intended recipient, please 
> notify the sender, and then please delete and destroy all copies and 
> attachments, and be advised that any review or dissemination of, or the 
> taking of any action in reliance on, the information contained in or attached 
> to this message is prohibited. 
> Unless specifically indicated, this message is not an offer to sell or a 
> solicitation of any investment products or other financial product or 
> service, an official confirmation of any transaction, or an official 
> statement of Sender. Subject to applicable law, Sender may intercept, 
> monitor, review and retain e-communications (EC) traveling through its 
> networks/systems and may produce any such EC to regulators, law enforcement, 
> in litigation and as required by law. 
> The laws of the country of each sender/recipient may impact the handling of 
> EC, and EC may be archived, supervised and produced in countries other than 
> the country in which you are located. This message cannot be guaranteed to be 
> secure or free of errors or viruses. 
> 
> References to "Sender" are references to any subsidiary of Bank of America 
> Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are 
> Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a 
> Condition to Any Banking Service or Activity * Are Not Insured by Any Federal 
> Government Agency. Attachments that are part of this EC may have additional 
> important disclosures and disclaimers, which you should read. This message is 
> subject to terms available at the following link: 
> http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you 
> consent to the foregoing.
> _______________________________________________
> 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

Reply via email to