The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 13 of 13

Thread: dynamic textfield alpha problem

  1. #1

    dynamic textfield alpha problem

    Hi,
    I created a textfield dynamically through actionscript 3.0 code. The bizarre things is, is that when I call my textfield (it's var is pmlabel), I am able to use other properties properly, but not alpha. For example:

    pmlable.visible = false;

    That works and makes the textfield invisible. Another example:

    pmlabel.text = "Something";

    That works and fills the textfield with the word Something. But when I try this:

    pmlabel.alpha = 0.5;

    Nothing appears to change. I have run a trace statement like this before and after the statement as follows:

    trace(pmlable.alpha);
    pmlabel.alpha = 0.5;
    trace(pmlable.alpha);

    output is:
    1
    0.5

    Why won't it actually fade my textfield? Thanks.

    icekube12jr

  2. #2
    I'm not exactly sure, but my guess would be that it is not a movieclip and and text in the textbox is not rasterized yet.

    A more technical answer should follow mine shortly.

  3. #3
    is the font embedded?

  4. #4
    I've found that the text needs to be embedded in a dynamic text field in order to use the alpha channel. Why does it need to be embedded. It's just another way to add too much to the filesize for no real gain.

  5. #5
    Quote Originally Posted by fishbulb View Post
    I'm not exactly sure, but my guess would be that it is not a movieclip and and text in the textbox is not rasterized yet.

    A more technical answer should follow mine shortly.
    That sounds about right to me, you couldn't fade a text box out in time line animation unless the textbox is contained within a movie clip. Perhaps try loading it into a movieclip first then setting the alpha on that?

    Dave

  6. #6
    devonair is correct. The font must be embedded in order for the alpha property to work. it will not matter if you place the text inside another container object. Embedding a font stores its vector information, which is used for this type of action.

    Things like rotating your text will also not work unless it is embedded.

    You can limit the characters that are embedded to help keep the file size down. Also, fonts can very quite a bit in file size. The more complicated the font, the more "vector" information it needs. So choose a small font if you can.

    If you have a bunch of dynamic text fields in your project that you need this for, I would suggest creating a shared font object and then use it for all of your text fields. This will allow you to embed the font once, rather than for each text field individually.

    ~squirt

  7. #7

    Thanks for the replies

    Thank you all very much for the replies. And quickly too. I have yet to try the suggestions but they sound very intelligent to me. I'll give them a shot.

    icekube12jr

  8. #8
    Awesome, you were correct. Fonts need to be embedded. It took me awhile to figure out how to do it dynamically cause there isn't really any proper documentation about this. I was helped by this link:

    http://www.nivas.hr/blog/2007/06/06/...flash-cs3-ide/

  9. #9

    A method that works with out embeds

    I am not sure if this is quite what you are looking for but here is a solution I found for adjusting alpha on a TextField object.

    PHP Code:
    // this is obviously not php code. I thought it would help for legibility
    // create an empty sprite
    var rect:Sprite = new Sprite();
    rect.blendMode BlendMode.LAYER;

    addChild(rect);

    var 
    txtField:TextField = new TextField();
    txtField.txtColor 0x000000;
    txtField.alpha .5;
    txtField.appendText("SOME TEXT");

    rect.addChild(txtField); 
    the key is to set the blendMode property on the sprite to LAYER.

    Hope this helps!
    Last edited by darwinkid; November 5th, 2007 at 07:42 PM.

  10. #10
    Interesting Is there a way to dynamically declare which characters to embed so the whole font file isnt embeded?

  11. #11
    I haven't tried. With the code above I am not explicitly embedding any fonts.

    Quote Originally Posted by kingscooty View Post
    Interesting Is there a way to dynamically declare which characters to embed so the whole font file isnt embeded?

  12. #12

    great sollution

    thank you for this great sollution darwin
    beats dynamicly embedding fonts!

    if you get errors using this method which look like this:

    1120: Access of undefined property BlendMode.

    you probably forgot to import the class:

    import flash.display.BlendMode;

    cheers!

  13. #13
    Quote Originally Posted by devonair View Post
    is the font embedded?
    Ding ding ding. Non-embedded fonts cause all kinds of nutty problems. Exporting without embedding fonts should really throw a warning or something.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012