AS 2 getTextFormat issue ... ?
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: getTextFormat issue ... ?

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309

    getTextFormat issue ... ?

    Hi, I've decided to try out tracing the fonts properties one by one till I find the ones I need but I am probably doing something wrong here because the trace doesn't seem to match the font that displays on screen. I've also tried using getNewTextFormat instead of getTextFormat but besides not really knowing the difference between them, the trace is almost the same and the text keeps being different on screen. What would the correct syntax be, please?

    Code:
    stop();
    
    var select:Number;
    
    var aFonts:Array = ["TR", "TB", "TI", "TBI", "CR", "CB", "CI", "CBI", "APR", "APB", "API", "APBI", "TMR", "TMB", "TMI", "TMBI", "VR", "VB", "VI", "VBI", "AR", "AB", "AI", "ABI"];
    select = Math.floor(Math.random() * aFonts.length);
    
    this.createTextField("my_txt", 1, 100, 100, 300, 100);
    my_txt.multiline = true;
    my_txt.wordWrap = true;
    var my_fmt:TextFormat = new TextFormat();
    my_fmt.font = aFonts[select];
    my_fmt.size = 24;
    my_fmt.bold = true;
    my_fmt.italic = true;
    my_fmt.color = 0x000033;
    my_txt.text = "This is a test.";
    my_txt.embedFonts = true;
    my_txt.antiAliasType = "advanced";
    my_txt.selectable = false;
    my_txt.setTextFormat(my_fmt);
    
    
    var my_fmt:TextFormat = my_txt.getTextFormat();
        for (var prop in my_fmt)
        {
            trace(prop + ": " + my_fmt[prop]);
        }
        
        trace("----------------------");

  2. #2
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309

    attaching prove


  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309

    No problem about that.... I'll solve it in time, but one last question, please

    I'm trying to loop a function as soon as the alpha from my text fades out completely, but I've read somewhere that alpha may not reach exactly 0 and don't know how to handle this problem.

    this is the function i have in the main timeline:

    Code:
    function attachClips():Void{
        attachMovie("independencia_mc","independencia",this.getNextHighestDepth(),{_x:200, _y:350});
    }
    
    
    attachClips();
    and this is in an attached clip that calls the fadeout function onSoundComplete:

    Code:
    fadeOutInd = function():Void{
        trace(ind._alpha);
        trace(ind);
        new Tween(ind, "_alpha", None.easeNone, ind._alpha, 0, 2, true);
        if(ind._alpha == 0){
        ind.removeTextField();
        _parent.attachClips();
        }
    }

    but it doesn't work and I don't remember, or don't know how to get the alpha's trace in the conditional statement so I have no clue whether it reaches 0. A way to repeat this would be appreciated, the final objective is to have it run endlessly showing up on any spot on stage until the user clicks on the screen to close the window.



    Attachment 74849

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    There's an event fired when a tween completes - onMotionFinished. Is that what you need?

    Here's tut on tweens that shows using that function: http://www.republicofcode.com/tutori...enclasseasing/

    Use separate functions so you can reuse.

    Code:
    var tweenMain: Tween;
    
    tweenMain = new Tween(myObject, "_alpha", Elastic.easeOut, 100, 0, 1, true);
    
    tweenMain.onMotionFinished = fTweenMainComplete;
    
    fTweenMainComplete() {
    	trace("fTweenMainComplete()");
    }

  5. #5
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309
    Thank you so much again, Fruit.

    Now I just need to play around with the fonts, I guess. I did look at the links you sent before, but to be honest I haven't read them completely as I thought I couldn't see anything related to which fonts to use.

    Did you see my previous post with the pic? It traces italic sometimes and you can clearly see it isn't slanted at all.

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    894
    Hi Cap,

    Moot answered the last one, but anyway.
    The reason the font is not italic and it displays italic or vice versa is because the font that has been chosen from the array is not set to be italic in the library, and you have set it to be italic in the italic array. true/false

    Think about it Cap.

  7. #7
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309
    morning, Fruit. I am thinking about it. I thought I finally did assign italic, bold and both right in the library. All the fonts I am using are properly linked now (or that's what I thought) I am on my way to hand a resumée so I'll check when I get back home, but I believe my attached file should still be posted and I haven't changed anything about the fonts. Anyway, thanks for the reply.

  8. #8
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309
    Hi, sorry, Moot, I never saw your post... thanks. Yes it is. I actually had used onMotionFinished before, but I didn't remember. Thanks.

    Any ideas on the font issue? I'm pretty sure I have embedded them properly and I'm willing to test them one by one using the textGetFormat method, but Fruit says not all fonts can be embedded and even though he send me a couple of links, I haven't understood his reply this morning.

  9. #9
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    What are you trying to do exactly in your app?

    You're trying to assign a random font from a list of fonts?

    Make sure you're embedding the correct font.

  10. #10
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    309
    Hi,

    Yes, exactly. My mistake. I keep forgetting to link them properly besides not being sure which allow bold and italic.

Posting Permissions

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




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com