Auto grow canvas to contain children?

Hi, I have a custom component that extends Canvas. It has a
few children like buttons and textinputs, and a custom programmatic
skin. When one of the children grows (like my textInput), the
parent canvas gains scroll bars, but I'd like the canvas to grow
instead, so that it is always big enough to contain it's children.
Is there a way to set this in AS3?
Thanks,
Cliff

"Clifford Meece" <[email protected]> wrote
in message
news:gmi3r6$lda$[email protected]..
>I decided to just change my component from a canvas to a
hbox, but it still
> doesn't seem to grow.
>
> I'm adding components to it in the createChildren
funcion...do I need to
> do
> something special to get it to resize?
>
call invalidateDisplayList() and invalidateSize() in
createChildren.

Similar Messages

  • JS ScriptUI container.children[name] problem

    Has anyone any experience accessing controls by name?
    The JS Tools reference mentions that a control should have been created using the creation property {name: } syntax, which I obey. Nonetheless, I cannot get the control afterwards.
    I have to use this approach because I'm creating containers on the fly, assigning them names with variables, so the syntax container.children[index] is not a way to go for me.
    Anyone of knowledge out there?
    Regards

    Yeah, one might hear it's a feature not a bug, but I pronounce it a 'bug'.
    Group containers don't return children controls by their name. You have to use panels instead.
    Filed a bug to Adobe, FWIW.

  • Auto-start application on Container/Server restart

    What's the easiest was to have the container auto-launch a specific application whenever it is started/restarted? I assume this would also happen if the entire server were rtestarted?
    _mike                                                                                                                                                                                                                                                                                                                                                                                                   

    Hello,
    If you put a server in your project and you put the servlet at auto-start your application will start automatically when the server will start.
    To do that you just have to use the element:
    <load-on-startup>1</load-on-startup>
    in the servlet tag.
    server.xml:
    <application name="foo" path="../applications/foo.ear" auto-start="true" />
    http-web-site.xml:
    <web-app application="foo" name="foo-web" load-on-startup="true" root="/foo" />
    Regards
    Tugdual Grall

  • Flash CS4/AS3 auto-size movieclip box containing TextField

    I have a TextField that I'm going to populate dynamically in code.  Imagine as a simple example a cartoon with the text bubble above the speaker's head, the bubble is a rounded rectangle with some embellishments like drop shadow and a border and such, and I want the bubble to be a fixed width but a variable height to accomodate a few words or maybe a long sentence that wraps to three lines.  I understand that TextField will do this with autosize and wordwrap, but how do I make the 'bubble' movieclip that contains it also resize accordingly, without writing various hacks involving counting the number of characters and resizing the bubble myself?  Thanks!

    assign your bubble a scale9grid and then assign its height based on your textfield's height.

  • Auto-open DHTML dropdowns containing highlighted search result?

    I have submitted the following feature request.
    Does anyone know of a script or other "trick" that will produce this result?
    When returning search results in published output, automatically open DHTML dropdowns containing the highlighted search term. Otherwise, users go to the listed page but cannot see the highlighted search term. There may be many dropdowns on a single page, resulting in some inconvenience for end-users of published output.

    Hi Willam
    I stand to be corrected on this, but won't that cause all drop-downs to expand for all topics? I understood the issue to be that only when a term was found inside a drop-down was when the expansion was desired. So perhaps a single page has ten drop downs and a searched term is found that occurs in one of the ten, only expand that drop-down do the term would be visible.
    AFAIK this isn't possible.
    As an aside, it always did strike me as odd that someone would go to all the trouble of inserting drop-downs and expands, only to later want them all presented by default when the topic was opened. Isn't the idea behind them to hide information until the user wishes to see it?
    Scratching head.... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Re-size Container Children when AIR App Re-sizes

    I have component panels witin a dataGroup. The dataGroup re-sizes when the AIR application is resized, but the panels do not re-size along with the dataGroup. I'm using TileLayout for the dataGroup. The goal is, of course, to fill the entire dataGroup container, regardless the size of the application. Application source is below. What happens is if I resize the application after the comPanelClick event, the panel containers do not re-size with the container.
    <?xml version="1.0" encoding="utf-8"?><s:WindowedApplication  xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="
    library://ns.adobe.com/flex/spark"xmlns:mx="
    library://ns.adobe.com/flex/mx"xmlns:components="
    components.*"width="
    1200" height="720" backgroundColor="#6D6666" creationComplete="maximize()">
     <fx:Declarations>
     <s:ArrayCollection id="panelsAC">
     <components:comInformation click="comPanelClick(event, 0);" id="pnlInformation" height="100%" width="100%"/>
     <components:comDocuments click="comPanelClick(event, 1);" id="pnlDocuments" height="100%" width="100%"/>
     <components:comCommunications click="comPanelClick(event, 2);" id="pnlCommunications" height="100%" width="100%"/>
     <components:comNotes click="comPanelClick(event, 3);" id="pnlNotes" height="100%" width="100%"/>
     </s:ArrayCollection>
     </fx:Declarations>
     <fx:Script>
    <![CDATA[
     private var tLayout:TileLayout = new TileLayout(); 
    private var selectedPanelId:String; 
    private function comPanelClick(event:MouseEvent, target:Number):void { 
    if (event.target.toString().indexOf('btnComShow') > 0) {selectedPanelId = panelsAC.getItemAt(target).id;
    panelsAC.getItemAt(target).currentState =
    'ViewState';panelsAC.filterFunction = panelACFilter;
    panelsAC.refresh();
    tLayout.horizontalGap = 10;
    tLayout.horizontalAlign =
    'center';tLayout.columnWidth = (grpContent.width - 20);
    tLayout.requestedColumnCount = 1;
    tLayout.requestedRowCount = 1;
    tLayout.verticalAlign =
    'middle';tLayout.rowHeight = (grpContent.height - 20);
    tLayout.verticalGap = 10;
    grpContent.layout = tLayout;
    else if (event.target.toString().indexOf('btnComHide') > 0) {panelsAC.getItemAt(0).currentState =
    'StartState';panelsAC.filterFunction =
    null;panelsAC.refresh();
    tLayout.horizontalGap = 10;
    tLayout.horizontalAlign =
    'center';tLayout.columnWidth = ((grpContent.width - 20) / 2);
    tLayout.requestedColumnCount = 2;
    tLayout.requestedRowCount = 2;
    tLayout.verticalAlign =
    'middle';tLayout.rowHeight = ((grpContent.height - 30) / 2);
    tLayout.verticalGap = 10;
    grpContent.layout = tLayout;
    private function panelACFilter(item:Object):Boolean { 
    return item.id == selectedPanelId;}
    ]]>
    </fx:Script>
     <s:DataGroup id="grpContent" left="20" right="20" top="50" bottom="135"contentBackgroundAlpha="
    1.0" contentBackgroundColor="#FFFFFF"dataProvider="
    {panelsAC}">
     <s:layout>
     <s:TileLayout horizontalAlign="center" horizontalGap="10" orientation="rows" columnWidth="{((grpContent.width - 20) / 2)}"requestedColumnCount="
    2" requestedRowCount="2" verticalAlign="middle" rowHeight="{((grpContent.height - 30) / 2)}"verticalGap="
    10" useVirtualLayout="true"/>
     </s:layout>
     </s:DataGroup></s:WindowedApplication>

    I just created a custom layout script to deal with it.
    package  
    scripts{
    import  
    import  
    import  
    public  
    override public function updateDisplayList(containerWidth:Number,containerHeight:Number):
    void{
    // The position for the current element 
    var x:Number = 0; 
    var y:Number = 0; 
    // loop through the elements 
    var layoutTarget:GroupBase = target; 
    var count:int = layoutTarget.numElements; 
    var element:ILayoutElement; 
    var elementWidth:Number; 
    var elementHeight:Number; 
    if (count == 1) {element = layoutTarget.getElementAt(0)
    element.setLayoutBoundsSize(NaN, NaN);
    elementHeight = (containerHeight - 10);
    elementWidth = (containerWidth - 10);
    element.setLayoutBoundsPosition(x, y);
    element.setLayoutBoundsSize(elementWidth, elementHeight);
    else { 
    for (var i:int = 0; i < count; i++){
    // get the current element, we're going to work with the 
    // ILayoutElement interfaceelement = layoutTarget.getElementAt(i);
    // Resize the element to its preferred size by passing 
    // NaN for the width and height constraintselement.setLayoutBoundsSize(NaN, NaN);
    // Find out the element's dimensions sizes. 
    // We do this after the element has been already resized 
    // to its preferred size.elementWidth = ((containerWidth - 30) / 3);
    elementHeight = ((containerHeight - 20) / 2);
    // Would the element fit on this line, or should we move 
    // to the next line? 
    if (x + elementWidth > containerWidth){
    // Start from the left sidex = 0;
    // Move down by elementHeight, we're assuming all  
    // elements are of equal heighty += elementHeight + 10;
    // Position the elementelement.setLayoutBoundsPosition(x, y);
    // Update the current position, add a gap of 10 element.setLayoutBoundsPosition(x, y);
    element.setLayoutBoundsSize(elementWidth, elementHeight);
    x += elementWidth + 10;
    } class PanelLayout extends LayoutBase{
      spark.layouts.supportClasses.LayoutBase;  spark.components.supportClasses.GroupBase; mx.core.ILayoutElement; 

  • Canvas children and mouseOver

    Simply put, I have a repeating canvas that contains buttons,
    an image, and a text field. When the user rolls their mouseOver the
    canvas, a child canvas becomes visible with buttons inside of it.
    Works great when you make sure that the mouse stays only over true
    canvas area and not over a child inside of the canvas. If it falls
    over a child, it fires the mouseOut and the buttons become
    invisible. Essentially, you can't click on the buttons because they
    are a child and the mouseOut goes off, making them invisible! How
    can I keep the mouseOver alive, even over a child?
    Thanks!

    check the parent of the event "target", not the parent of the
    event.
    In Flex, events can possibly participate in three phases:
    1) cascading phase as the event goes from the top of the
    display list through all parents of the control that dispatched the
    event.
    2) targeting phase, as the event goes through the target, the
    control that dispatched the event.
    3) bubbling phase as the event goes back up the display list
    through parents of the control that dispatched the event.
    - not all events bubble
    - you may need to add an event listener twice, and have the
    arg to addEventListener for bubbling to true and then false if you
    want to listen during cascading and bubbling phases.
    Now you are probably confused, so ignore some of what I said,
    and concentrate on listening to mouseOver events in the Cnavas, and
    then when the event handler is called, examine the target and
    possibly currentTarget properties of the event object to see if it
    is the child of the Canvas, and then act as appropriate.

  • Container not repsecting min sizes for children

    Hi,
    I have a basic problem with HBox / HDividedBox (and other
    layouts) - see below code.
    Button 2 on right has minimum width and this is respected by
    the HDividedBox dragger - the button always get it's minimum width.
    However Button 1 on left, which is inside a HBox can get clipped
    when moving the dragger.
    It seems that HBox isn't constrained to have minimumWidth
    sufficient to always show it's children - or the HdividedBox is not
    respecting it. Surely there a way to do this? I've tried playing
    around with scroll bar policies etc but without luck.
    BTW I find it odd that Buttons don't automatically constrain
    min height/width to always so the label text (most other UI
    toolkits I've used before did this by default) - but that is
    another issue.....
    Thanks for any hints !
    Rick

    Thanks - you are correct that the layout is correct when app
    is initially started.
    I *could* hardcode the HBox width and this would work - but
    this would mean whenever any HBox child changed width I'd have to
    adjust it.....
    What I don't understand is why the HBox doesn't expose it's
    minimum size as the minimum dictated by the sum of min sizes of
    contained children and the various padding (the single button in
    this case).
    This is the normal behaviour I've seen on h/v box layouts in
    other UI toolkits - e.g. the C++ based, cross platform Qt
    http://doc.trolltech.com/4.4/layout.html
    Also why does HDividedBox respect the minimum widths of it's
    children - but HBox doesn't?
    Cheers
    Rick

  • Cocoa text auto-scale?

    Is there a way to get a text label or similar object to auto-scale with the container window? That is, as the window grows, I want the text size to grow to fill all available space without clipping, and to shrink back down again as the window shrinks. I'm sure I could do some sort of calculation based on font metrics and the displayed string to figure out the best size based on the window, and then somehow tie that into when the user resizes the window, but is there a better/easier method? Thanks.

    RayNewbie wrote:
    I would register for the [NSWindowDidResizeNotification|http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Application Kit/Classes/NSWindowClass/Reference/Reference.html#//appleref/doc/uid/20000013-BCIIHIHC], which is posted continuously as the window is resized.
    This seems to work perfectly to get the visual result, and is precisely what I was thinking of. Thanks.
    RayNewbie wrote:
    In any case, this Wil Shipley blog might be of interest to you. Note the example code seems to be manually calculating the point size: [Pimp My Code, Part 6: The Pimp Before Christmas|http://www.wilshipley.com/blog/2005/12/pimp-my-code-part-6-pimp-before.html].
    Definitely helpful, primarily in that their method of calculating the font size is noticeably more efficient than what I had come up with. Still inefficient though- processor usage spikes to around 50% on my mac mini 2.0 core2duo machine when resizing the window. I suppose it might not be too big a deal, but I'd hate to see window resizing lag on slower or more heavily loaded machines. I'm not sure there's much choice when doing a live resize, however- waiting to resize the text until the window resize is completed would look horrible.
    Hope that helps!
    \- Ray

  • Stacked Canvas issue

    1st issue:-
    I have created 3 pages layout under same .fmb
    Out of those , page1 I have made in content canvas & 2 layout(Say page2 & page3) I have made in two different stack canvas.Page1 contain two text field- 1.NAME 2. PROFILE CODE.
    when user open it page1 (content canvas) & page2 (1st stack canvas) should show .For a specific value in PROFILE CODE (say JAPAN) profile code (page1+page3) should open.& for all other profile codes (page 1+page2) should remain,irrespective of whatever value in NAME.
    Please tell me how can I do this??
    1. Please help me with a sample code & also where (in which trigger) I should write the condition.
    2. What all changes are required in property palette?
    3. will both the canvas will be on the same window?
    2nd issue:-
    I have tried
    In the Object Navigator, under the Canvases node, double-click the content canvas' object icon. In the Layout Editor, choose View | Stacked Views.
    and could see both the page1+page2 there from layout editor.
    BUT while I run it its showing only the page1(content canvas)
    Please help me out.....
    Thanks in advance..
    Edited by: 977083 on Dec 29, 2012 5:09 AM

    If I put it like this In WHEN-NEW-FORM-INSTANCE trigger check the PROFILE CODE and display the stacked canvas based on the value in PROFILE CODE---
    Then content canvas will be shown first(Page1) ,then user will select profile code, depending upon the profile code selected ,either page2 (stacked canvas) or page3(stacked canvas) will be shown.
    But I want whenever user opening the form ,page1 & page2 should show by default.then user will select profile code.if profile code is for page2 ,it should stay in that (default) page only.If profile code is for page3 then it will automatically go to page3 along with page1.

  • Tab Canvas displaying Stacked Canvas at runtime disappears?

    Hi,
    I have 3 canvases that contain the following:
    1) Content Canvas -- This contains the TREE item.
    2) Tab Canvas -- A tab canvas with a single Tab Page
    3) Stacked Canvas -- This is a Stack Canvas with a few
    text items on it.
    4) Single Window.
    ======At runtime the following actions occur: ==========
    1) The Viewport of the stacked canvas is set to the
    Viewport of the Tab Page on the Tab Canvas so that it
    looks like the Tab Page has a vertical and horizontal
    scrollbar with text items displayed.
    2) A text item on the Stacked Canvas is in focus as soon
    the as the form window is displayed.
    ===================Problem is : =====================
    1) When I select a Node of the Tree Item, the Tab Canvas
    automatically disappears(or becomes invisible) , as a
    result the stacked canvas displayed within it at
    runtime also becomes invisible. I am left with only
    the Tree item being displayed.
    =======================================================
    PS : I have never experienced this problem with just the
    content canvas and the Tab Canvas together.
    Any soultion to this problem is most appreciated.
    Thanks
    Sharath

    I am experiencing the exact same thing. The width of the tabs in the layout editor is varied depending on the length of the text. However, at run-time, the width of the tabs is fixed, causing the tabs to be wider than the window and a set of VCR buttons to appear in the upper right corner of the canvas. Personally, I think this is a Forms bug. Why would they intentionally let us set the width to variable at design-time only to force a fixed width at run-time?

  • How to create a jpg file for a desired  part of the canvas

    i hav to create a jpg file from the canvas which contains basic shapes which are drawn using methods like drawOval(),drawRectangle(). i need only a part of the canvas to be saved as a jpg file i.e for example from xpos 50-100 & ypos 200-250.i need all the portions of the shapes already drawn in that area as a jpg file..
    can anyone help me?

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    public class CanvasClip extends Canvas implements ActionListener
        Rectangle clip;
        boolean showClip;
        public CanvasClip()
            clip = new Rectangle(50, 50, 150, 150);
            showClip = false;
        public void paint(Graphics g)
            super.paint(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            int dia = Math.min(w,h)/4;
            g2.setPaint(getBackground());
            g2.fillRect(0,0,w,h);
            g2.setPaint(Color.blue);
            g2.drawRect(w/16, h/16, w*7/8, h*7/8);
            g2.setPaint(Color.red);
            g2.fillOval(w/8, h/12, w*3/4, h*5/6);
            g2.setPaint(Color.green.darker());
            g2.fillOval(w/2-dia/2, h/2-dia/2, dia, dia);
            g2.setPaint(Color.orange);
            g2.drawLine(w/16+1, h/16+1, w*15/16-1, h*15/16-1);
            if(showClip)
                g2.setPaint(Color.magenta);
                g2.draw(clip);
        public void actionPerformed(ActionEvent e)
            Button button = (Button)e.getSource();
            String ac = button.getActionCommand();
            if(ac.equals("show"))
                showClip = !showClip;
                repaint();
            if(ac.equals("save"))
                save();
        private void save()
            int w = clip.width;
            int h = clip.height;
            BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = img.createGraphics();
            g2.translate(-clip.x, -clip.y);
            paint(g2);
            g2.dispose();
            String ext = "jpg";  // or "png"; "bmp" okay in j2se 1.5
            try
                ImageIO.write(img, "jpg", new File("canvasClip.jpg"));
            catch(IOException ioe)
                System.err.println("write error: " + ioe.getMessage());
        private Panel getUIPanel()
            Button show = new Button("show clip");
            Button save = new Button("save");
            show.setActionCommand("show");
            save.setActionCommand("save");
            show.addActionListener(this);
            save.addActionListener(this);
            Panel panel = new Panel();
            panel.add(show);
            panel.add(save);
            return panel;
        public static void main(String[] args)
            CanvasClip cc = new CanvasClip();
            Frame f = new Frame();
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            f.add(cc);
            f.add(cc.getUIPanel(), "South");
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How to move the canvas in the screen

    Hi,
    I am a j2ME game developer. I wanna create a canvas which contains something that can't be displayed all at a time. the user has to scroll across to view the canvas. I am not aware of the issues of this kind. Help me out in this regard.
    Cheers
    joe

    You could add a scrollPane to the component holding the image however, as you may or may not know, a scrollPane can only be added to Container type components so you can't add a scrollPane to a Canvas. You could add it to its parent Frame however.

  • Which one is better to use..Canvas or J2ME Polish

    Hello Frnds,
    I want to add background images n want to use High level GUI, So is the polish be a good option for it , or should I go for simple j2me canvas n write my own low level... GUI like construct .....or should go for Synclast 3rd party API. library......

    I've J2ME Polish on a few projects, and it can be really nice. But sometimes you just need more, you need pure Canvas flexibility. And for that (and for 90% of my projects) I use synclast. It's a canvas based container toolkit, it allows you to do a LOT with a canvas, and you can also extend it very easily to create your own widgets for the UI.
    http://synclast.com/ui_api.jsp
    don't download the release build, it's REALLY old, download the source and compile your own jar for a much more up-to-date library.

  • A BUG in the Genres and Rankings for Auto Playlists

    I recently spent too much time ranking each of my many songs on my iTunes hoping to set up auto-playlists that will contain my favorite songs among various genres. However, when i went to create an auto playlist with more than one genre at a ranking, say, greater than 1 star, no songs would appear on my auto playlist.
    however, when i tried the converse, and selected genres NOT to be included in the auto list at a ranking greater than 1 star, i was able to create my desired auto playlist. Doing this procedure among 20 or so genres, however, is needlessly tediously.
    I would like for Apple to please fix this bug in the software.
    thank you
    dell   Windows XP Pro  

    eh, I don't think it's a bug.
    Match ALL of the rules
    Genre=Jazz
    Genre=Alternative
    Sure, you'll get an empty playlist.
    If you change it to Match ANY of the rules, you'll get songs from both genres.
    But I do know what you're saying, other people have wanted the playlists to have an OR function.
    You can get what you want in two steps
    Match ANY
    Genre=Jazz
    Genre=Alternative
    call this playlist "Favorite Genres" for example.
    Then have another playlist
    Match ALL
    playlist= Favorite Genres
    My Rating is greater than 1 star
    Message was edited by: Katrina S.

Maybe you are looking for