Sizing movieclip to fit the dynamic Textfield

I'm adding text to a movieclip as you can see below. The text is alomost not visible because it's so small. If I don't scale the movieclip then the text becomes clipped. I basically want the movieclip to be a tight container (the same size as the textfield) for the Textfield. The below does not work. How can I do this?
for(var i:int = 0; i < group.length; i++)
       var t:TextField = new TextField();
       t.name=i.toString();
       t.text=group[i];
       var f:MovieClip = new MovieClip();
       f.addChild(t);
       f.width = t.textWidth;
       f.height = t.textHeight;
       f.y = 50*i;
       addChild(f);

In case anyone else is having this problem, by adding this
t.autoSize ="left";
it fixed it.

Similar Messages

  • Why can access the dynamic textField inside a Button?

    yep, I have another problem
    I create a button in the library, it has a background graphic
    on a layer and a textField, the textField has a instance name
    defined in the properties panels and some text. I manually place
    some instance of the button on stage, I give them different
    instance names and voilà a new problem arise
    when with actionscript I try to assign a new text to the
    textField inside a button it throws me error 1119. A quick look at
    the menu option debug ->list objects, shows me that the instance
    name of the textField inside the button it is not what I defined
    but it was replaced with some random name like "instance66"
    I did a test with a movieclip instead of a button and I can
    correctly access my textField with the instance name that I
    manually defined.
    Why that can be the same with the button? And if for some
    arcane reason cant be possible to access a manually defined
    instance inside a button WHY flash give me the possibility to give
    an instance name to a dynamic textField inside a button?

    Buttons simply do not have the same properties and methods
    that movieclips have. Anytime you want to create a button that has
    anything beyond the simple 3 states of activity, use a movieclip.
    I can't answer why flash allows you to give an instance name
    to the textfield, but in any case, it won't allow you to use
    it.

  • Dynamically size movieclip to fit text's string height and width

    Hello,
    I am trying to dynamically size a movieclip to fit the size of a text's string height 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 = String("Use the Arrow Buttons to move");
    MessageBox.width = MessageBox.Text1.width;
    MessageBox.height = MessageBox.Text1.height;
      MessageBox.x = 400;
      MessageBox.y = 200;
      addChild(MessageBox);
    this isn't working for me.. anyone know the best way to do this?
    I also want the text to be centered in the movieclip, with a border of around 2-4 pixels
    I am also not sure if i should be using text.length? any advice and input is greatly welcomed.
    thanks in advance!

    Essentially, you need to check for a change in .textWidth or .textHeight, which are different from .width and .height.
    This code works for me (assumes a background box called bg and a foreground text instance fg inside a moveclip and an X and Y bounds offset variable to say how far away you want the box from the text and a textFrameNudge to provide a tweak value).
         // 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;

  • How can i set the dynamic text box to show variable value?

    In AS2, I can make a dynamic text box set a var name, when i
    use button set/change the var value, this textbox can show the
    value also.
    but In AS3, dynamic text box can't add var name. than how can
    i do it now?

    Set an instance name for the dynamic textfield. Then, to
    populate the textfield with the value of a variable, use:
    textFieldInstanceName.text = variableName

  • Dynamic sizing of a component to fit the content

    Hi All,
    How can I make my component so that it will be dynamically sized to fit the content height?  I would like to create a component that will have a variable height.  It has a serious of user input controls.  Depending on the answers given, more input from the user may be necessary--specifically, they will have to provide an explanation in a textbox.
    So, my thinking is that I don't want to display the textbox unless they answer "yes" to any questions that require additional explanation.  If they do, then I want display the TextArea control along with instructions to enter an additional explanation here.
    However, when I do that, it will cause my component's height to grow.  I don't want to reserve space for that textbox in the component's dimensions--I would prefer it simply grow (pushing anything below it further down) if and when the textbox appears.
    How would I go about doing this?
      -Josh

    I think the standard JSF solution would be not to do the create/delete of inputs on the client side, but to do it on the server side.
    If that is not your cup of tea, I think that the standard components will not be sufficient. So you are looking at either not binding the inputs to a component and just getting the values via the request parameters or creating a custom component capable of dealing with this.

  • How to preserve special characters in dynamic textfield for text comparison?

    The problem is as follows:
    Since I mostly develop for multiple languages I am forced to have dynamic textfields in my buttons which contain three lines (to account for the differnt text.lengths in different languages).
    I then populate the textfields with strings out of an array or xml and use the textfields contents later in my button class to execute different code depending on the textfields content.
    This works fine as long as I don`t use any special characters, like for example "\n".
    var labels:Array = ["\nLABEL1","LABEL\n\n2"];
    switch (e.currentTarget.txt.text)
                    case labels[0]:
                        doSomething();
                        break;
                    case labels[1]:
                        doSomethingElse();
                        break;
    shows the right thing in the button label (breaks the text were I want it)
    but stops to work
    (with htmlText &  <br> its the same)
    my workaround for the moment is to use filler spaces,
    var labels:Array = ["                   LABEL1","LABEL                                                                        2"];
    but that`s obviously ugly to setUp and requires a lot of trial/error to get it right for all languages.
    Any ideas how to bypass that?

    Bad habits die hard ;-)
    Weird enough spelling the problem out and getting this response from you cleared my head and  I finally got an easy solution.
    I simply attach a dynamic property to the movieclip, copy the array contents into them and instead of using the text-property for comparison I compare the MovieClips fresh created spectext property.
    Voila: Now I can be lazy without too much of a bad conscience.

  • How to set a dynamic textfield?

    How to set a dynamic textfield that can baseon the user input data to resize the textfield height and width? Beside, I would like to copy the MS word table into the Form textfeild with the original design, how to do that? Many thanks!

    You need to check two things:
    1- Make sure to check the "Allow Multiple Lines" under the object tab.
    2- Check the Expand to Fit checkboxes under the layout tab.
    Jasmin

  • Trouble with Dynamic TextField and Virtual Keyboard

    I'm working on a flashlite 3.1 touchscreen device running a flash app that I've written. At certain times, I need to be able to enter text, so I created an onscreen keyboard that updates a dynamic textfield.
    If I use a dynamic textfield, a caret doesn't appear, and you can tell where you are entering text. Using some of the text metric info, I've been able to *draw* a caret at the proper position for single line textfields. However, when I try and handle multiline textfields (with wordwrap on), I can seem to figure out what line the *caret* would be or how to breakdown what text is on each line. Has anybody had any success with this? Obviously, hard newlines could be parsed, but the wordwrap is giving me grief.
    In addition, for the Selection class to work, the textfield must have focus. In flashlite, this results in a yellow box around the input, which looks horrible. Is there a way to disable the yellow box?
    Regards,
    Bill

    It is simple, and should be, but I can't say whether you are implementing something incorrectly or if CS5 has some added complexity (or bug) at play.  If we go back to your initial posting, and my initial response, then that should be the end of the story.
    I don't own CS5, but I'd hate to think they made something else difficult to deal with like they seemingly did with timeline tweening in CS4 (which I also did not buy into).  I believe they invented some new form of textfield in CS5, but it'd be sad if they invented some new property to deal with for assigning text to it.
    The only thing I can imagine at this point where it might be something you did involves a couple of factors being at play... 1)  you are using the library name of the movieclip, not the instance name, and 2) your Publish Settings are set for AS2 (so that no error is generated... AS2 is not generous with them like AS3).

  • Calling function from html tag in dynamic textfield

    Hi!
    Tried several approaches for making this happen, but can't seem to do it. I could really use an example of how to do this in my particular case, since I'm not exactly a code - guru.....
    I have a sprite menu which populates a dynamic textfield  with textlabels as users click individual items in the menu in addition to ordinary actions(gotoAndStop).
    As these labels appear in the textfield, I want to be able to link them to the frames assosciated with the menu - item frames. As you can understand from this, I am working with the timeline.
    By enabling  html rendering of text in the textfield, I have been able to link these output labels via a  a href - tag, but I am not able to call a function from this html. The function I am trying to call uses a switch statement to take the appropriate actions according to which label is being clicked, but the only effect I get is the html opening a browser window...... Unfortunately I do not know how to explain this any better, but here is my code for the following:
    Main Timeline, frame 1, actions layer:
    [AS]import flash.display.*;
    import flash.events.*;
    import flash.display.Stage;
    var buttonTrace:TextField;
    var sectionNames:Array = new Array("Frontpage","Introduction",
    "Designparadigm", "Tooling", "Maya & c++ API", "Geometric Vectors","Lindenmayer systems","Artificial Life",
    "Projects","Litterature","Disclaimer","Site credits","Newsletter & Rss",
    "Blogging","Plugins","LINKS");
    var sectionCount: int = sectionNames.length;
    var menu:Sprite = new Sprite();
    menu.x = 452;
    menu.y = 172;
    this.addChild(menu);
    buildMenu();
    function buildMenu():void {
    for(var i:int=0; i < sectionCount ; i++){
    var item:MovieClip = new MenuItem();
    item.labelName = sectionNames[i];
    item.targetClip = this;
    if(i<4){
    item.y = i*125
    menu.addChild(item)}
    else if (i>3 && i<8){
    item.y = (i-4)*125
    item.x = 125
    menu.addChild(item)}
    else if (i>7 && i<12){
    item.y = (i-8)*125
    item.x = 250;
    menu.addChild(item)}
    else if (i>11 && i<16){
    item.y = (i-12)*125
    item.x = 375
    menu.addChild(item)}
    }[\A]
    Then, for the movieclip called MenuItem, I have button placed on the first frame of the timeline, and this code in the actions layer:
    [AS]import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    import flash.text.TextField;
    import flash.events.Event;
    import flash.events.TextEvent;
    var buttonTrace:TextField;
    var labelName:String;
    var targetClip:MovieClip;
    clickButton.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(evt:MouseEvent):void {
    trace(labelName);
    targetClip.gotoAndStop(labelName);
    MovieClip(root).buttonTrace.appendText("\n" + labelName);
    MovieClip(root).buttonTrace.addEventListener(TextEvent.LINK,linkHandler);
      function linkHandler(linkEvent:TextEvent):void {
      switch (linkEvent.text) {
      case"Introduction":
      var text= "Introduction";
      text.addEventListener(TextEvent.LINK,"Introduction");
      trace("Listening");
       Intro();
       break;
      case "Designparadigm":
       DP();
       break;
      case"Tooling":
       Tooling();
       break;
      case "Maya & c++ API":
       MayaAPI();
       break;
      case "Geometric Vectors":
       GeometricVectors();
       break;
      case "Lindenmayer systems":
       Lsystems();
       break;
      case "Artificial Life":
          AL();
       break;
      case "Projects":
          Projects();
       break;
      case "Litterature":
          Litterature();
       break;
      case "Disclaimer":
          Disclaimer();
       break;
      case "Site credits":
          Sitecredits();
       break;
      case "Newsletter & Rss":
          Rss();
       break;
      case "Blogging":
          Blogging();
       break;
       case "Plugins":
          Plugins();
       break;
      case "LINKS":
          LINKS();
    function Intro():void {
    targetClip.gotoAndStop(2);
    function DP():void {
    targetClip.gotoAndStop(3);
    function Tooling():void {
    targetClip.gotoAndStop(4);
    function MayaAPI():void {
    targetClip.gotoAndStop(5);
    function GeometricVectors():void {
    targetClip.gotoAndStop(6);
    function Lsystems():void {
    targetClip.gotoAndStop(7);
        function AL():void {
    targetClip.gotoAndStop(8);
    function Projects():void {
    targetClip.gotoAndStop(9);
    function Litterature():void {
    targetClip.gotoAndStop(10);
    function Disclaimer():void {
    targetClip.gotoAndStop(11);
    function Sitecredits():void {
    targetClip.gotoAndStop(12);
    function Rss():void {
    targetClip.gotoAndStop(13);
    function Blogging():void {
    targetClip.gotoAndStop(14);
    function Plugins():void {
    targetClip.gotoAndStop(15);
    function LINKS():void {
    targetClip.gotoAndStop(16);
    MovieClip(root).buttonTrace.htmlText="<a href=\'function:linkHandler,?????'>History</a>";
    [\A]

    as3 textfields have a TextEvent.LINK you can use.

  • Firefox.exe - entry point not found The Procedure entry point GetLogicalProcessorInformation could not be located in the dynamic link library Kernel32.dll

    Here's my problem, until yesterday my firefox browser is fine, unless sometimes when i playing games/app in facebook the plugin keep crashing but thats okay i can stop it and reload my firefox.
    But now everytime i try to open firefox it displaying the error massage:
    firefox.exe - entry point not found
    The Procedure entry point GetLogicalProcessorInformation could not be located in the dynamic link library Kernel32.dll
    I try to uninstall firefox, and reinstall again.
    i have to use internet explorer and torch browser, which don't fit me and make me in pain.
    i try to run in firefox safe mode, according to some suggestion here, but it wouldn't allow me to open Safe Mode (i even holding the Shift button when clicking on firefix icon)
    Can you guys help me in here?
    Iam using windows xp.
    Thank you so much in advance, GBU all :)

    hi, do you have service pack 3 installed on your xp computer?

  • I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?

    I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?
    I have tried bootcamp and have had no luck due to the fact that boot camp doesn't see the additional HDD space of 250Gb. What am I not doing?

    Ouch, well there is a problem.
    This is the stack of partitions on your old drive
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    This is the same stack on your new drive imaged from the old one.
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    Emtpy Space (100GB say)
    This is what you want
    EFI (hidden)
    Lion (100GB say)
    Bootcamp (100GB say)
    Lion Recovery Partiton (hidden)
    EFI has to be at the top of the drive and Lion Recovery has to be at the bottom of the drive.
    And you only have four partitions.
    You can't move the Lion Recovery Partition or Bootcamp partiton, however you can expand the Lion Partition into empty space below it. (but can't delete or move the Lion Recovery partition)
    Your Duplicator duplicated perfectly, too perfectly Likely would work with same sized drives/partitions.
    This is what your going to need to do.
    You need to move the Bootcamp partition to a blank external drive using WinClone and disconnect. This is so you have two backups of it. (one on your old 500GB drive)
    You will need a drive enclousre or IDE/SATA to USB adapter cable for the older 500GB drive and option key boot from it. (some enclosures can't be booted from so check first Other World Computing is good place to ask)
    Download the free Carbon Copy Cloner, grab any new files off the new 750GB internal drive to the old 500GB your booted from.
    Open Apple's Disk Utility and Erase with Zero option the entire internal 750GB drive and let it rip, this will map off as many bad sectors and improve reliability.
    Now use Carbon Copy Cloner to clone the 500GB Lion + Lion Recovery Partitions to the internal 750GB, it will "fix" things and place Lion Recovery at the bottom of the drive where it belongs, give all the extra space to OS X Lion.
    Next your going to have to follow WinClones instructions to restore your Bootcamp, likely you will have to recreate the Bootcamp partition first (in Bootcamp) to the size you want and then clone. Likely Winclone may "fix" Windows to recognize it's in a new larger partition now. I don't know you'll have to check as I haven't used it.
    When Bootcamp creates the partition it will place it near the bottom next to the Lion Recovery Partition.
    As you know you will have to re-validate Windows with Lord Redmond or it expires as you changed the hardware.

  • Booklet .pdf with crop marks, booklet doesn't fit the current paper size warning

    Hello. I am on XP using CS4 InDesign.
    I have the document set up as 4 pages, each 8.5 x 11, however, when creating a booklet .pdf, I mean it to be 2 pages 11x17.
    When I add in the crop marks they do not appear on the .pdf when it is created. I receive a warning in the booklet diaglog that the booklet doesn't fit the current paper size and it says to specify a larger paper size.
    What can I do to have the crop marks on my file? I understand the .pdf will be a little larger than 11x17 in order to fit the crop marks.
    Thanks for any help in advance.

    Hi Peter,
    Thank you. I did try that first, but now I figured out what I did wrong. When the .pdf was made and opened, I cropoped the page according to the marks, but the page remained 12 x 18 instead of 11x17. I made sure that the "automatically adjust to fit marks and bleeds" and "use document bleed settings" was checked in the booklet dialog and print InDesign dialog.
    When I cropped the page again to make sure I sized it correctly, it was 11x17.
    Thank you!!!

  • Resizing/moving MovieClips to fit screen problem

    I'd like to make an Android and iOS app with Adobe AIR, but I found a problem I can't solve.
    The Flash document size of the app is 800px x 600px, and I'd like to resize MovieClips to fit Android's and iOS' screens, suporting the Retina display on iOS devices.
    I tried using StageDisplayState.FULL_SCREEN and StageScaleMode.SHOW_ALL, and this does seem to work with static MovieClips, so the snippet would look something like this:
    import flash.system.Capabilities;
    import flash.events.Event;
    import flash.display.StageScaleMode;
    import flash.display.StageDisplayState;
    stage.addEventListener(Event.ENTER_FRAME,process);
    var difN:Number = (((stage.stageHeight*stage.fullScreenWidth/stage.fullScreenHeight)-stage.stageWidth)/2);
    function process(e:Event):void {
              difN = (((stage.stageHeight*stage.fullScreenWidth/stage.fullScreenHeight)-stage.stageWidth)/2);
              stage.scaleMode = StageScaleMode.SHOW_ALL;
    stage.addEventListener(KeyboardEvent.KEY_UP,useFullScreen);
    function useFullScreen(e:KeyboardEvent):void {
              if (e.ctrlKey) {
                        switch (e.keyCode) {
                                  case Keyboard.M:
                                            stage.displayState = StageDisplayState.FULL_SCREEN;
                                  break;
    obj.x -= difN
    However, I'd like to use classic tweens in my application, and this won't work since most of the elements are moving.
    I'd like to rescale/move MovieClips so they don't look distorted and every moving item moves correctly, showing all the content and trying to not make any borders. I read this article but it seems like it doesn't support classic tweens: http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.html.
    Thanks for the help.

    1. scaleMode only has an effect when you embed your swf in an html AND you publish for a percentage.
    2. you need to resize your displayobjects using code and/or in the ide.  if you open your document settings panel (modify>document) and change your stage size you are offered some scaling options.  see if any work for you.

  • [Q] how to change lines in dynamic textfield

    Hi, I am struggling to change lines of loaded text from xml.
    Basically I wrote few sentences in one child of xml file but
    when i loaded it to dynamic textfield I cant change the lines.
    (i tried with <br> /n both didnt work, textfield was
    multilined)
    thank you for your time

    how much text are we talking about?
    What parameters have you set for the text field? multilane?
    html?
    What size is your text field?
    Just some basic questions to think about. I actually link to
    an external text file if I have too much text to deal with. However
    I usually write text box's in the code.
    You already have the text field, so you shouldn't need the
    create command, which I probably got wrong anyway.
    my_TXT.createTextFeild(name,depth, x, y, width, hight)
    my_TXT = new textformat ("my_format")
    my_format.size = 27
    my_format.mutilne = ture
    my_TXT.html = true
    my_TXT.htmltxt = "bla bla <b>bla</b>"
    my_TXT.format(my_format)
    Again I can't be sure I got all the names right, but
    that’s about how it works.
    Again you don't have to use that, but to get the text to work
    you at least need mutiline to be on. To get html to work, you need
    html to be on, and you need to use the htmltxt to write it to the
    txt field in code. However I’m not 100% on if that’s
    the correct way to write it.

  • How to fit the images within textframe in indesign using javascript?

    Hi,
    We are using the update script for updating the values in table.
    If i am using images within textframe, the table is not fitting after updating it. Without using images the table is fitting.
    First i have dragged the table in Indesign document. Then i have altered the image size and updated the table using Update script.
    Finally i want to fit the table with the resized images.
    Note: I can get the updated values in table . but i cannot get the resized images.( Now i can get the original image after updating the table)
    Please help me if anyone has idea regarding this issue.
    Thanks,
    Vimala L

    Hi,
    Please find below the Update Script,
    var myDocument = app.activeDocument;
    var updateOption = app.scriptArgs.get("updateOption");
    main();
    function main()
    if(updateOption=="UPDATE")
      UpdateLink();
    function UpdateLink()
    myDoc = app.activeDocument;
    myLinks = myDoc.links;
    for (j = myLinks.length - 1; j >= 0; j--)
    myName = myLinks[j].filePath;
      var ext =  myName.substring(myName.length-3,myName.length) ;
    if (myLinks[j].status == LinkStatus.linkOutOfDate)
    myLinks[j].update();
    After running this script i cannot get the image in table.
    While running the Fitting script followed by Update script i am getting the Original size of the image. But i want the re-sized image in table.
    Fitting Script:
    var textFitoption= app.scriptArgs.get("textFitOption");
    var imageFitoption= app.scriptArgs.get("imageFitOption");
    var tableFitoption= app.scriptArgs.get("tableFitOption");
    main();
    function main()
      IterateDocument();
    function IterateDocument()
      for(myCounter = 0; myCounter < app.activeDocument.activeLayer.textFrames.length; myCounter++)
      myStory = app.activeDocument.activeLayer.textFrames.item(myCounter);
      FitPageItem (myStory);
    function FitPageItem (mySel)
      if(mySel.associatedXMLElement!=null)
    if (mySel.constructor.name == "TextFrame")
      if(mySel.associatedXMLElement.xmlAttributes.itemByName("IMAGE_FILE")==null)
    mySel.parentStory.clearOverrides();
      mySel.parentStory.appliedCharacterStyle = app.activeDocument.characterStyles.add()
      mySel.parentStory.appliedCharacterStyle.remove();
    //Fit all inline Items
      graphicItems = mySel.allGraphics;             // I cannot get the graphicItems.
      for(g=0;g<graphicItems.length;g++)
      if(imageFitoption=="Fit Frame To Content")
      graphicItems[g].fit(FitOptions.frameToContent);
      else if(imageFitoption=="Fit Content Proportionally")
      graphicItems[g].fit(FitOptions.proportionally);
      }//for
      }//Has image_file attr
      }//is text frame
       if(mySel.associatedXMLElement.markupTag.name=="products")
      if(IsImageEmbeddedInTable(mySel)==true)
      xmlElem = mySel.associatedXMLElement;
      mySel.placeXML(xmlElem);
      }//if products
    function IsImageEmbeddedInTable(mySel)
      for( var j = 0; j< mySel.tables.length ; j++ )
      table = mySel.tables[j];
      for( var i = 0 ; i< table.cells.length ;i++ )
      cell= table.cells[i];
      cellElement = cell.associatedXMLElement;
      if(cellElement !=null)
      if(cellElement.xmlElements!=null)
      if(cellElement.xmlElements.count()>0)
      if(cellElement.xmlElements[0].xmlAttributes.itemByName("href")!=null)
      return true;
    Thanks,
    Vimala L

Maybe you are looking for