Replace that with:

formatter.italic = !currentFormat.italic;

The conditionals aren't necessary in that situation. :)

On Thu, Apr 3, 2008 at 1:21 PM, Stuart (FunkDaWeb) <[EMAIL PROTECTED]> wrote:
> YAY! It works! Thank you! :o)
>
>  Wont work with embedFonts = true thought! :o(
>
>  Onwards and upwards!
>
>  Thanks for your help!
>
>  SM
>
>
>   ----- Original Message -----
>   From: jonathan howe
>   To: Flash Coders List
>   Sent: Thursday, April 03, 2008 6:53 PM
>   Subject: Re: [Flashcoders] Reading properties of a textbox [AS3]
>
>
>   Okay, but in the simple example, you are using it for both:
>
>   Okay, but formatter should not be treated as a property of _selectedBox.
>   _selectedBox has no property named formatter.
>
>   This is the offending line:
>
>   if (_selectedBox.formatter.italic == false)
>
>   You already have set formatter to the value of _selectedBox.getTextFormat();
>   Thus your conditional should read:
>
>   if (formatter.italic == false)
>
>   To simplify it to keeping formatter separate from the current format, let's
>   rewrite:
>
>   var currentFormat:TextFormat = _selectedBox.getTextFormat();
>   var formatter:TextFormat = new TextFormat();
>
>     if (currentFormat.italic == false)
>     {
>      formatter.italic = true;
>     }
>     else
>     {
>      formatter.italic = false;
>     }
>
>    _selectedBox.setTextFormat(formatter);
>
>
>   -jonathan
>
>
>   On Thu, Apr 3, 2008 at 1:19 PM, Stuart (FunkDaWeb) <[EMAIL PROTECTED]>
>   wrote:
>
>   > formatter is a blank variable and has nothing to do with reading the text
>   > propperties its used for setting them! I need to figure out how to tell 
> if a
>   > text field is set to italic or not! once i can do this i can fix the if
>   > statement!
>   >
>   > do you have any idea how to do this?
>   >
>   >
>   >
>   > 
> --------------------------------------------------------------------------------
>   >
>   >
>   > FUI - New code is this....
>   >
>   > var formatter:TextFormat = _selectedBox.getTextFormat();
>   >
>   >    if (_selectedBox.formatter.italic == false)
>   >    {
>   >    formatter.italic = true;
>   >   }
>   >   else
>   >   {
>   >    formatter.italic = false;
>   >   }
>   >
>   >  _selectedBox.setTextFormat(formatter);
>   >   ----- Original Message -----
>   >  From: jonathan howe
>   >  To: Flash Coders List
>   >   Sent: Thursday, April 03, 2008 5:53 PM
>   >  Subject: Re: [Flashcoders] Reading properties of a textbox [AS3]
>   >
>   >
>   >  Hi, Stuart,
>   >
>   >  Based on the error message sounds like maybe you are trying to access
>   >  _selectedBox.formatter or something else invalid. Can you repaste your
>   > new
>   >  code after the change?
>   >
>   >  -jonathan
>   >
>   >
>   >  On Thu, Apr 3, 2008 at 11:15 AM, Stuart (FunkDaWeb) <[EMAIL PROTECTED]
>   > >
>   >  wrote:
>   >
>   >  > thanks Jonathan for some reason i get this error when i change to your
>   >  > code...
>   >  >
>   >  > ReferenceError: Error #1069: Property formatter not found on
>   >  > flash.text.TextField and there is no default value.
>   >  >   ----- Original Message -----
>   >  >  From: jonathan howe
>   >  >  To: Flash Coders List
>   >  >  Sent: Thursday, April 03, 2008 4:04 PM
>   >  >  Subject: Re: [Flashcoders] Reading properties of a textbox [AS3]
>   >  >
>   >  >
>   >  >  var formatter:TextFormat = _selectedBox.getTextFormat();
>   >  >
>   >  >  On Thu, Apr 3, 2008 at 10:43 AM, Stuart (FunkDaWeb) <
>   > [EMAIL PROTECTED]
>   >  > >
>   >  >  wrote:
>   >  >
>   >  >  > Hi all im tring to write a button that changes the format of a
>   > textbox
>   >  >  > from normal to italic and back again. I have written the below code
>   > but
>   >  > i
>   >  >  > cannot seam to get it to work!
>   >  >  >
>   >  >  > var formatter:TextFormat = new TextFormat();
>   >  >  >
>   >  >  >   if (formatter.italic == false)
>   >  >  >   {
>   >  >  >    formatter.italic = true;
>   >  >  >   }
>   >  >  >   else
>   >  >  >   {
>   >  >  >    formatter.italic = false;
>   >  >  >   }
>   >  >  >
>   >  >  >   _selectedBox.setTextFormat(formatter);
>   >  >  >
>   >  >  > So my question is how do i read the properties of a textbox in order
>   > to
>   >  >  > create an if statment to change the properties?
>   >  >  >
>   >  >  > SM
>   >  >  > _______________________________________________
>   >  >  > Flashcoders mailing list
>   >  >  > Flashcoders@chattyfig.figleaf.com
>   >  >  > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>   >  >  >
>   >  >
>   >  >
>   >  >
>   >  >  --
>   >  >  -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME
>   > 04101
>   >  >  _______________________________________________
>   >  >  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
>   >  >
>   >
>   >
>   >
>   >  --
>   >  -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
>   >  _______________________________________________
>   >  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
>   >
>
>
>
>   --
>   -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
>   _______________________________________________
>   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
>



-- 
Cory Petosky : Lead Developer : PUNY
1618 Central Ave NE Suite 130
Minneapolis, MN 55413
Office: 612.216.3924
Mobile: 240.422.9652
Fax: 612.605.9216
http://www.punyentertainment.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to