Dynamically size movieclip to adjust the width and height of the text string

Hello

I'm trying to size a movieclip dynamically to adapt to the size of the height of the strings a text and width (this text is inside the movieclip)

Here is my code so far...

var Font1_ = new Font1();

var Format2:TextFormat = new TextFormat();

Format2.size = 36;

Format2.align = TextFormatAlign.CENTER;

Format2.font = Font1_.fontName;

var MessageBox:MovieClip = new MessageBoxMC();

MessageBox.Text1.defaultTextFormat = Format2;

MessageBox.Text1.embedFonts = true;

MessageBox.Text1.antiAliasType = AntiAliasType.ADVANCED;

MessageBox.Text1.wordWrap = true;

MessageBox.Text1.width = 800;

MessageBox.Text1.height = 400;

MessageBox.Text1.textColor = 0xFFFFFF;

MessageBox.Text1.cacheAsBitmap = true;

MessageBox.Text1.mouseEnabled = false;

MessageBox.Text1.text is a String ("use the arrow keys to move");.

MessageBox.width = MessageBox.Text1.width;

MessageBox.height = MessageBox.Text1.height;

MessageBox.x = 400;

MessageBox.y = 200;

addChild (MessageBox);

This does not work for me... someone knows the best way to do it?

I want also the text is centered in the movieclip, with a border of 2-4 pixels

Also I'm not sure if I should use text.length? advice and comments was very well received.

Thanks in advance!

Essentially, you must check for a change in .textWidth or .textHeight, which are different from the .width and .height.

This code works for me (guess a box called bottom bg and an instance of inside a moveclip and an X fg foreground text and there delimits variable shift to say what distance you want from the text box and a textFrameNudge to provide a value to tweak).

     // Resize background box
     thisBox.bg.x = thisBox.fg.x - boundsOffsetX + textFrameNudge; // I'm using .4 as the tweak value for textFrameNudge
     thisBox.bg.y = thisBox.fg.y - boundsOffsetY;
     thisBox.bg.width = thisBox.fg.textWidth + boundsOffsetX*2 +textFrameNudge*thisBox.fg.getTextFormat().size;
     thisBox.bg.height = thisBox.fg.textHeight + boundsOffsetY*2;

Tags: Adobe Animate

Similar Questions

  • What is the size in width and height a logo must be set on?

    Hello

    I want to design a logo, but I don't know what size in width and height that I should put it. Is there a standard size? Also, what format should I deliver to my customer? PDF or JPG, or all of the above?

    Martin,

    The size and proportions of the logos vary a lot, no dimensions/dimensions standard.

    PDF should be one, maybe have them, but not JPEG: formats no dissipative PNG24 and TIFF would be preferable; for those, different sizes for different purposes would be normal.

  • How to configure the size of the symbol % (width and height)

    How to configure the size of the symbol % (width and height)

    shoud you have your symbol in % and also your image in % file, when you have changed both of the theme to % then your image will change as expected.

    and if you want to make your image immutable able and set the position that you need to change your % step also

    I made some photos to show you...

  • Apex 5 display image field, control width and height on the form page

    Hello everyone,

    I try to display the image from a blob directly column on the page, it does not work well, here's my question, how can control the width and height of the screen image field, because its changing dynamically the size of the screen according to the original dimensions, I want to set the dimensions.

    Any help will be appreciated.

    Concerning

    Anil

    set the width and height attributes in the attributes of the image html elements

    for example Width = "200" height = "100".

  • Customize the class Edittext with custom width and height

    I need a class of edittext customize where I can adjust the width and height, but I do not find such a custom class that extends the class EditField and the opportunity to set the width and height. I need to access the EditField methods also. Can we have such a class?

    I solved the problem by substituting the positioning method.

    UriField = new EditField ("", strUri, 2000, EditField.READONLY |) EditField.FIELD_LEFT | EditField.FIELD_VCENTER)
    {
    public void layout (int width, int height) {}
    Are police = getFont();
    int _fieldHeight = font.getHeight ();
    int _fieldWidth = 190;
    Super.Layout (Width, Height);
                    
    setExtent (_fieldWidth, _fieldHeight);

    }
    };

    Thank you all

  • What is the width and height?

    I got a memory to provide a logo to be printed on a baseball cap, the printers asked me to provide the logo with a dimension not exceeding 19.35 square cm.

    What would be the width and height for the jury of art in Illustrator?

    Any help will be greatly appreciated.

    Thank you.

    Thank you all for your comments, that's why I'm so confused by the request because I calculated what 4,4 cm which is really small. I'll get them to confirm the actual size, because it's a very loose way of telling me the obligation and can be interpreted in many ways.

    Thanks again, much appreciated.

  • How to resize an image using PIXELS to define the width and height?

    I need make my image a certain number of pixels wide and high.  When I resize image I can't change the area that shows the pixels of width and height, and when I drop down lists it does not give option pixels.  When I choose "points" and "Pica" they are obviously not other names for the pixels because the given number is not the number of pixels above.  I used to be able to do it EASILY in elements 2.0, my previous version of elements.  I am now using 8.0.

    In fact, I just realized that nothing that I in image resize will change the number of pixels at ALL in question.  Size and pixel per inch are locked permanently in relationship to each other.  I had to download a new version not long because my computer hard drive has failed, and I think they changed the things that work so not now, because I would have noticed it before now if it's that way when I downloaded originally from that.  I begin to fear that I'll have to kludge with the crop tool, even if the resizing of the image SHOULD be able to.

    Make sure resample is checked:

  • Image size default width and height units

    I am now using 2015 and when I open the tool to the size of the Image width and height units are default to inches I want to make Pixels. The size is set to Pixels and resolutions has Pixels/inch, but the width and height units always opens on the thumbs. I checked my preferences, units and leaders, units, the rules are Pixels is of Type Points. But the New Document preset resolutions column size and Point/Pica size and see nothing else to settle.

    What is a 'new' to be stuck with the thumbs everytime I open the size of the Image? It's a pain that I almost never work in inches.

    Then, with the size of the Image open, hold down the ALT key. Cancel button will be Reset.  Click on that and the dialog box will go to the default values. See if that fixes it.

  • How to get the width and height of Flex Mobile view?

    Hello

    The following instructions can get the width and height of the current Flex app:

    var request: UIComponent = FlexGlobals.topLevelApplication as UIComponent;

    trace (application. Width);

    trace (application. Height);

    But I don't know how to get the width and height of mobile display Flex current (i.e. the content size excludes bar action and the Navigation bar). Why the "this.width" always returns 0?

    Thank you!

    Looks like you're running in this bug: https://bugs.adobe.com/jira/browse/SDK-30070

  • Get the width and height of the image

    Hi scripters

    I try to get the width and height of my image file. Here is my code

    myPicFile = File("c:\\ar.eps");

    h = myPicFile.height;

    w = myPicFile.width;

    Alert (h)

    Copy the following code generates error

    ---------------------------
    Script alert
    ---------------------------
    undefined
    ---------------------------
    Ok
    ---------------------------

    How can I get the height and the width of my image? is there another method?

    Thanks in advance

    concerning

    a you are the

    Dear Arul,

    Here, my code is in InDesign. I don't know that we get the size of the Image directly. ?

    Throught InDesign [you using the InDesign Script then] Script here I pasted the code below...

    = Image height / width =.

    myDoc var = app.activeDocument;

    myPicFile = file ("E:\\HariharaSudhan\\Blue hills.jpg");

    App.place (file (myPicFile);

    = Then u please select the Image file in InDesign and then you run the script = / /.

    mySel var = app.selection [0];

    var limit = mySel.geometricBounds;

    var height = related [2] - bound [0];
    var width = Bound [3] - bound [1];

    Alert ("Image Height:" + height + ""+"Image width:" + width);

    = End: getting the Image height / width =.

    Please let me know if you have any questions.

    Thank you & best regards

    Thierry T.R.Harihara

  • How to know the width and height of SWFLoader

    I am loading an image file with UrlLoader and SWFLoader and I need to know the width and height of the image size
    ----
    var tmp_swf:SWFLoader = new SWFLoader();
    tmp_swf. Load (a_file_urlloader. Data);
    window_tw.addChildAt (tmp_swf, 0);
    ----

    I tried:
    window_tw.getChildAt (0). Width.ToString ();
    and
    window_tw.tmp_swf. Width;
    but both return 0.

    Any ideas or am I just dumb?

    Quote:
    Posted by: SujitG
    Hello

    Try SWFLoader.content.width. You can find more details on ownership of content at the ADDRESS below.

    http://livedocs.Adobe.com/Flex/3/langref/MX/controls/SWFLoader.HTML#content

    I hope this helps.

    Yep, works after SWFLoader is COMPLETE. Thank you

  • How to get the property of the image on the width and height?

    Hi, all, I import image from the outside with the following method, but how to get the w3c_main.png on the width and height property? I will appreciate for your answer.

    var mcLoader = new MovieClipLoader()
    mcLoader.loadClip (" http://www.w3.org/Icons/w3c_main.png", image);

    or an image. LoadMovie (" http://www.w3.org/Icons/w3c_main.png")

    in the first case use the method onLoadInit() to a listener for your mcl before trying to access your target movieclip laborious and _height properties.

    in the second, use the preloader code to ensure your png loading is completed before attempting to access the _width and _height of your target movieclip properties image.

  • website valid W3C, initially no error reported by the developer toolbar. But by right clicking (giving the menu validation), the toolbar reports two errors: width and height. Despite the fact that each page is posted! The forum for the toolbar, this i

    website valid W3C, initially no error reported by the developer toolbar. But by right clicking (giving the menu validation), the toolbar reports two errors: width and height. Despite the fact that each page is posted! The forum for the toolbar, it's supposed to be a browser error. So, how can it be fixed? I use FF 3.6.6

    This has happened

    Each time Firefox opened

    is after upgrade to 3.5?

    http://chrispederick.com/forums/viewtopic.php?PID=8239#p8239

    You create a new profile and install only the extension Web Developer, as recommended Chris?

  • Cannot change PopUp LOV width and height in version 4.2.5.00.08. I change the values of 450 400 in the Popup list template values (Section of the window), but my function genList0_f07_$ _row (), retains the same settings. Is this a bug?

    Hello

    I use APEX 4.2.5.00.08 to my app.

    I have a region of reports, where I display a column set. A column is the column attribute "display as" the value 'Popup LOV (LOV based query).

    I press the button to retrieve the LOV, I get a popup of 450 x 400 pixels.

    I go to the side of the model and navigate to "Popup list of values of model", where I can see in the section 'Window' attributes 'Width' and 'Height' value 450 and 400. I edit them and save them and there is nothing going on. I'm sure that the template belongs to my selected theme.

    I saw in the HTML source code that is the called function:

    <!--


    function genList0_f07_$ _row)
    {
    w = open ("wwv_flow_utilities.gen_popup_list" +)
    « ? p_filter ="+
    "& p_name = ' + escape ('f07') +.
    ' & p_element_index = ' + escape ('0') +.
    ' & p_elem_id = ' + escape ('f07_0000').
    ' & p_form_index = ' + escape ('0') +.
    ' & p_max_elements = ' + escape ("") +.
    ' & p_escape_html = ' + escape ("") +.
    ' & p_ok_to_query = ' + escape ('YES').
    ' & p_flow_id = ' + escape ('114') +.
    ' & p_page_id = ' + escape ('100201') +.
    ' & p_session_id = ' + escape ('16021544706004').
    ' & p_eval_value = ' + escape ("") +.
    ' & p_translation = ' + escape ('NO') +.
    ' & p_lov = ' +.
    ' & p_lov_checksum = ' +.
    ' & p_item_id = ' + escape('-683997768') +.
    ' & p_column_id = ' + escape ('25022622060292812'),
    "winLov,"
    "Scrollbars = 1, resizable = 1, width =400, height =450"); "
    If (w.opener is nothing)
    w.opener = auto;
    w.Focus ();
    }
    ->

    I see that the values has not changed. I also connected and disconnected. I am inclined to believe that it is a bug of the APEX.

    The only solution I think is to replace this function, which is NOT ideal.

    Thank you

    Digital

    The parameters are generated only, nothing you can do about it because it does not use the model for these properties of the couple. Other things work fine for example the names of button or title window etc. I guess that, Yes, it is a bug. It's still there in the apex 5 too, I checked. The default values of the template do not match, the value in the generated code is always 400/450. So I guess it's pretty much a wait on 5.1.

    Here's a fun hack to make it work well on your page (works in apex 5 too, because the code is always the same). Put this in the execute on loading of the page section:

    (function(){
      var _open = window.open;
      window.open = function(){
        if ( arguments[1] === "winLov" ) {
          arguments[2] = "Scrollbars=1,resizable=1,width=500,height=700";
        };
        return _open.apply(window, arguments);
      };
    })();
    

    Change the settings to your liking. This will replace the existing window.open call, which is what the popup lov use and replace it with our own code. It does not interfere with other things. As the name of the new window is always "winLov" for the popup lov, it is the argument that is checked.

    During the call to window.open to open a new window with the name "winLov", parameters are replaced with your own version of it. The window is called as usual, using the stored reference.

    Edit:

    Yes, do not use the trick of resizing. My hack can be a bit tedious, but it's much less invasive for the end user (see open, bam, resize. "Even gets funky on multiple monitors). Also, this thing in the popup lov template will affect each lov popup that you use in the application, which is much less interesting than my specific page code.

    Edit2:

    I did a little digging in the source code, and I don't know why it does not work. Popup lovs are actually equipped to deal with it. My guess is that the parameters are recovered only after that the lists were generated, causing the package variables global to use their default values instead of model parameters.

  • How to change the width and height of the title?

    Program: First Pro CC

    Recently I create da title for my video. I noticed that when I had looked at the preview of the title and the video, the title is so blurry. My settings at first:

    SAve.PNG

    How am I able to change the width and height parameters (to make the title more high definition) , without having to create another title in replacement from that Fuzzy? I don't ask if I have to create another title and insert it in the video, and then having to erase those blurry I had to replace. How are you able to change settings of the original title, without having to make a new title? Should I go to the 'Properties' tab when there is nothing at all (as in there is no option to change the w + h title quality) to change the current settings of the title?

Maybe you are looking for