Best practice for adding text to Flex container?

Hi,
I'm having some troubles to lay a TextFlow class out properly
inside a Flex container. What's the best practice to achieving
this, for example adding a lot of text to a small Panel?
Is it possible to pass anything other than a static width and
height to DisplayObjectContainerController constructor, or is this
not the place to implement this? I guess what I am looking for is
the layout logic I'd normally pack into a custom Flex component and
implement inside measure() and so on.
My use case: a chat application which adds multiple TextFlow
elements to a Flex container such as Panel. Or use TextFlow as a
substitute for UITextField.
Some example code would help me greatly.
I'm using Flex 3.2.
Regards,
Stefan

Thanks Brian, the example helps. However problems quickly
arise if I modify it slightly to this (please compile it to see):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" initialize="init()">
<mx:Script>
<![CDATA[
import flashx.textLayout.compose.StandardFlowComposer;
import
flashx.textLayout.container.DisplayObjectContainerController;
import flashx.textLayout.container.IContainerController;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextFilter;
private var _container:Sprite;
private var _textFlow:TextFlow;
private function init():void
_container = new Sprite();
textArea.rawChildren.addChild(_container);
var markup:String = "<TextFlow xmlns='
http://ns.adobe.com/textLayout/2008'><p><span>Hello
World! Hello World! Hello World! Hello World! Hello World! Hello
World! Hello World! Hello World! Hello World! Hello World! Hello
World! Hello World! </span></p></TextFlow>";
_textFlow = TextFilter.importToFlow(markup,
TextFilter.TEXT_LAYOUT_FORMAT);
_textFlow.flowComposer.addController(new
DisplayObjectContainerController(_container, 200, 50));
_textFlow.flowComposer.updateAllContainers();
]]>
</mx:Script>
<mx:Canvas width="100" height="100" id="textArea" x="44"
y="46" backgroundColor="#F5EAEA"/>
</mx:Application>
What is the best way to make my textflow behave like a
'normal' UIComponent in Flex? Should I use UIComponent instead of
Sprite as a Container? Will that take care of resize behaviour?
I have never before needed to use rawChildren.addChild for
example, maybe you can explain why that's needed here?
I realise that the new Textframework works on an AS basis and
is not Flex or Flash specific, but this also poses some challenges
for those of us using the Flex framework primarily.
I think it would help to have some more basic examples such
as using the new text features in a 'traditional' context. Say for
example a TextArea that is just that, a TextArea but with the
addition of inline images. I personally feel that the provided
examples largely try to teach me to run before I can walk.
Many thanks,
Stefan

Similar Messages

  • Best practice for adding and removing eventListeners?

    Hi,
    What is the best practice in regards to CPU usage and performance for dealing with eventListeners when adding and removing movieclips to the stage?
    1. Add the eventListeners when the mc is instantiated and leave them be until exiting the app
    or
    2. Add and remove the eventListeners as the mc is added or removed from the stage (via an addedToStage and removedFromStage listener method)
    I would appreciate any thoughts you could share with me. Thanks!
    JP

    Thanks neh and Applauz78.
    As I understand it, the main concern with removing listeners is to conserve memory. However, I've tested memory use and this is not really an issue for my app, so I'm more concerned if there will be any effect on CPU (app response) if I'm constantly adding and removing a list of listeners every time a user loads an mc to the stage, as compared to just leaving them active and "ready to go" when needed.
    Is there any way to measure CPU use for an AIR app on iOS?
    (It may help to know my app is small - I'm talking well under 100 active listeners total for all movieclips combined.)

  • Best practices for adding CLICK listeners to complicated menus?

    OK, I’m gonna wear out my welcome but here’s my last question of the day:
    I’ve got a project that is essentially a large collection of menus, some buttons common across multiple screens, others unique. The following link is the work in progress, most of the complexity is in the “Star Action Items and Forms” area (btw: the audio in the launch presentation is just a placeholder track, I know we can't use it):
    http://www.appliedcd.com/Be-A-star/Be-A-star.html
    To deal with the large number buttons my timeline simply has the following for every menu frame:
    stop();
    initFrame();
    The initFrame() function then has a list of frames and activates the buttons appearing on each screen, a very simplified example follows. In this example commonButtons span all 3 menus, semiCommonButtons span menu 2 and 3, button1A, button2A, etc… are unique per menu.:
    function initFrame():void {
         var myFrame:String = this.currentLabel;
         commonButton1.addEventListener(MouseEvent.CLICK,onInternalLink);
         commonButton2.addEventListener(MouseEvent.CLICK,onInternalLink);
         commonButton3.addEventListener(MouseEvent.CLICK,onInternalLink);
         switch(myFrame) {
              case "menu1":
                   button1A.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button1B.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button1C.addEventListener(MouseEvent.CLICK,onInternalLink);
              break;
              case "menu2":
                   semiCommonButton1.addEventListener(MouseEvent.CLICK,onInternalLink);
                   semiCommonButton2.addEventListener(MouseEvent.CLICK,onInternalLink);
                   semiCommonButton3.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button2A.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button2B.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button2C.addEventListener(MouseEvent.CLICK,onInternalLink);
              break;
              case "menu3":
                   button3A.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button3B.addEventListener(MouseEvent.CLICK,onInternalLink);
                   button3C.addEventListener(MouseEvent.CLICK,onInternalLink);
              break;
    The way the project was designed, I “thought” menu3 would only be accessible through menu2, thus guaranteeing that the semiCommonButtons would get initialized, but I forgot the functionality of my back button could jump the user directly from menu1 to menu3. The solution is simple, initialize every button on every navigation  target, however, is this really the best way to initialize a bunch of buttons? Another possible approach would be to have an array of button instance names and a function that said: if instance XYZ exists, add listener, then simply loop through the array on every nav target. Anyone with more experience have advice on best practices in this situation?

    Hmmmm just run a test on this whereby I added the above snippet to my master page. I then publish a major version. I can see that every (Welcome) custom page layout has this data widget working, providing I add the div to the page..  
    I wonder if the reason I can't add the snippet  directly  to an individual custom layout page is a bug or am I doing something incorrectly?
    Daniel

  • Best practices for adding components in a composite custom component

    Hello,
    I am developing a custom, composite JSF component need to dynamically add child components in my renderer class. I've noticed that people add components to a custom component in many different ways. I'd like to follow JSF best practices when developing this component - of the following approaches, which would you recommend? Or is there yet another approach I should be using?
    1) in the encodeBegin method of my renderer class, create a new component, add it to the component tree, and let the page life cycle take care of the rendering:
    HtmlDataList dimensionStateGroupDataList = (HtmlDataList) app.createComponent( HtmlDataList.COMPONENT_TYPE );
    //set properties on dimensionStateGroupDataList
    component.getChildren().add(dimensionStateGroupDataList);
    2) in either the encodeBegin or encodeEnd method, create a component and encode it:
    HtmlDataList dimensionStateGroupDataList = (HtmlDataList) app.createComponent( HtmlDataList.COMPONENT_TYPE );
    //set properties on dimensionStateGroupDataList
    dimensionStateGroupDataList.encodeBegin();
    dimensionStateGroupDataList.encodeEnd();
    Both of these methods are functional, and I prefer the first (why encode children if you don't have to?), but I am interested in other people's take on how this should be done.
    Thanks for your help.
    -Christopher

    My bad, sorry, wasnt concentrating, Im afraid I have no experience with portlets, but I would have thought that you can mimic the outputLinkEx in you renderer by encoding your own links?
    If you were to bind a backing bean variable to an outputLinkEx what would it be? Not understanding portlets, or knowing what an outputLinkEx is may be hindering me, but you should be able to create an instance of it in code like (this example uses HtmlOutputLink, you would need to know which component to use):
    HtmlOutputLink hol = new HtmlOutputLink();
    hol.set....Then set any attributes on it, and explicitly call its encodeStart, encodeEnd functions. Is that way off the mark.

  • Best practice for adding agents based on queue stats

    I am looking for some guidance (sanity check really) on the best way for to add agent to a CSQ base on call statistics. Scenario: 20 agents logged in and ready. The first 15 agents take all the calls until the contacts waiting reaches 10, then and only then should the other 5 agents start taking calls.
    I appreciate any help or sample scipts on this subject.

    You cannot add agents to skills dynamically; however, you can queue the caller into more than one CSQ based on statistics. You would use the Get Reporting Statistics and an If step within the Queued branch of your first Select Resource step. If the condition is met (e.g. Contacts Waiting >= 10) then exectue a second Select Resource step within the queued branch of the first. The contact would then be waiting in both CSQs waiting for an agent.

  • What is best practice for adding copyright page, etc?

    Hi Folks,
    I'm using iBooks Author for the first time. When I added a copyright page using Insert > Pages > Section > Copyright, I get a loose page that I was able to drag in front of the table of contents. However, the copyright page now has no formatting. That is, it spans a full two-page spread without the page break in the middle, like the rest of the book. How can I get the the same format for pages before the TOC?
    Thanks,
    Rob

    iBooks Author will definitely need a code view feature to users can hack the XML manually and fix these things.
    While I don't see that happening , (a) you can show package contents and go nuts now, if you like and (b). feel free to use iBA's menu to feedback [ http://www.apple.com/feedback/ibooks-author.html ] for any features, changes, etc. you may have in mind for the future and (c) remember, the best defense is a good offense...best way to stay out of jams w/IBA is to not get into them in the first place...practice with different templates to see which may support specific needs.
    For use of the appllcation, if you haven't seen it already, try:
    Publishing With iBooks Author
    http://shop.oreilly.com/product/0636920025597.do

  • Best practice for adding application to $env:Path in PowerShell?

    I'm trying to figure out the best way to add a program to PS's path. When I look at $env:Path, I see tons of different entries pointing to various programs on the system that seem to have been added by their installers. This would suggest that I could just
    add another entry pointing to the .exe I want to have available in the path, but if I do this every time I want to have an application available at the shell my path is going to get hideously cluttered.
    In bash, I would normally make a bin directory within my home directory, add it to the path at startup in my .bashrc, and then make symlinks in that directory for anything I wanted available. This keeps the path clean and easy to manage. Is there a way to
    do something like this in PS, or is the standard solution just to add a new entry to the path for every application you want until it's like a million miles long and unreadable? Putting symlinks or shortcuts in directories already in the path hasn't worked
    so far.

    I'm trying to figure out the best way to add a program to PS's path. When I look at $env:Path, I see tons of different entries pointing to various programs on the system that seem to have been added by their installers. This would suggest that I could just
    add another entry pointing to the .exe I want to have available in the path, but if I do this every time I want to have an application available at the shell my path is going to get hideously cluttered.
    In bash, I would normally make a bin directory within my home directory, add it to the path at startup in my .bashrc, and then make symlinks in that directory for anything I wanted available. This keeps the path clean and easy to manage. Is there a way to
    do something like this in PS, or is the standard solution just to add a new entry to the path for every application you want until it's like a million miles long and unreadable? Putting symlinks or shortcuts in directories already in the path hasn't worked
    so far.
    You can't put symlinks in a folder to a folder but you must put a link or shortcut to the executable.  Links to folders are not scanned. Only the root folder in the path is scanned.  No programs wil lever be found through the path if it is in the
    current folder in a PowerShell session.
    You can quickly alter the patch for the current session like this:
    $env:path+='c:\myprogramfolder'
    When you exit PowerShell it will not reamian.  It will only change the PowerShell process path for that PowerShell session.
    ¯\_(ツ)_/¯

  • What is Best Practice for Adding Thousands of Tasks to CloudJob?

    I am looking for some guidance on adding lots of tasks to a CloudJob.
    I have thousands of tasks to add to a job, and several parent tasks running across multiple TVMs are participating in adding the new tasks to the job. However, I can reproduce my problem with a single task that tries to add new tasks to the job with
    a max degree of parallelism of 15.
    In each thread, I call IBatchClient.OpenWorkItemManager, then IWorkItemManager.GetJobAsync, then ICloudJob.AddTaskAsync, followed by ICloudJob.CommitAsync in order to add a new task. I will occasionally get a "Server encountered an internal error. Please
    try again after some time." exception. After I delay, and then retry the entire series of operations again (from OpenWorkItemManager all the way to ICloudJob.CommitAsync), I receive the "A task instance can only be added to a single job." exception.
    Since I am receiving these exceptions frequently, I am hoping that there is a better way to add a lot of tasks to the job. I see a way to add multiple tasks to a work item, but I don't know what the tasks will be ahead of time. I have to wait until I am
    well into processing the job before I know what new tasks need to be added to the job.

    Am I correct in assuming you're doing something like this?
    Parallel.For(0, 100, new ParallelOptions() { MaxDegreeOfParallelism = 15}, async (idx) =>
    IWorkItemManager manager = batchClient.OpenWorkItemManager();
    ICloudJob job = await manager.GetJobAsync("wiName", "jobName");
    await job.AddTaskAsync(new CloudTask("foo", "cmdline"));
    You are doing some extra exception handling and stuff too as well I assume.
    There are a few improvements you can/should make that ought to make your life easier.
    First, the GetJobAsync() call actually does a round trip to the server -- you can avoid doing this for every task you add and reduce your round trips by half:
    IWorkItemManager manager = batchClient.OpenWorkItemManager();
    ICloudJob job = manager.GetJob("wiName", "jobName");
    //Foo("Test", "Abc", "test");
    Parallel.For(0, 100, new ParallelOptions() { MaxDegreeOfParallelism = 15}, async (idx) =>
    await job.AddTaskAsync(new CloudTask("foo", "cmdline"));
    Even more than that, we provide a helper method which has this functionality and performs bulk adds behind the scenes, which will reduce your round trips by about a factor of 50-100.
    IWorkItemManager manager = batchClient.OpenWorkItemManager();
    List<ICloudTask> tasksToAdd = new List<ICloudTask>(); //Popualte this with your tasks
    await manager.AddTaskAsync("wiName", "jobName", tasksToAdd, new BatchClientParallelOptions() { MaxDegreeOfParallelism = 15 });
    Additionally, we have a way where you can configure a "retry policy" without having to manually do it yourself on every call.  It's pretty handy, you can set it on the BatchClient itself, or on an individual call, below you can see I set it
    on both (just to show you - in a real application usually you would just set it on the batchClient and be done with it -- it would then apply to all operations done by the batch client):
    IBatchClient batchClient = BatchClient.Connect("", new BatchCredentials());
    IRetryPolicy retryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 6);
    batchClient.CustomBehaviors.Add(new SetRetryPolicy(retryPolicy));
    IWorkItemManager manager = batchClient.OpenWorkItemManager();
    List<ICloudTask> tasksToAdd = new List<ICloudTask>(); //Popualte this with your tasks
    await manager.AddTaskAsync(
    "wiName",
    "jobName",
    tasksToAdd,
    new BatchClientParallelOptions() { MaxDegreeOfParallelism = 15 },
    additionalBehaviors: new List<BatchClientBehavior>() { new SetRetryPolicy(retryPolicy) });
    Also a clarification -- you cannot ever add tasks to a work item.  The method for add tasks happens to live on the "WorkItemManager" which a bit confusingly also manages job related stuff as well (since job is a child of work item). 
    Whenever you are adding tasks, you are always adding tasks to a job, so the "workItemManager" methods related to adding tasks all take job name as a parameter.
    Another issue you may be hitting has to do with .NETs service point manager... see:
    https://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit%28v=vs.110%29.aspx
    You may want to set this property to be something larger than the default of 2.
    Now, it's possible after making the changes I suggested you still experience some issues -- give these changes a try and if you're still having issues come back and let us know what they are and we can help you improve the submission code further.
    You can also see the sample code for TextSearch which demonstates this in the JobManager task.
    https://code.msdn.microsoft.com/windowsazure/Azure-Batch-Sample-Text-87d08017/sourcecode?fileId=129811&pathId=1120079659
    Hope that helps,
    -Matt

  • Best practice for adding products in multiple languages

    We have multiple products with the same product number and product name - but have different descriptions (translations).
    Our BigMachines quotation system allows us to have several language layers for the same product. But it seems like this is not possible in CRMOD?
    I guess the work around would be to have x amount of fields containing the description in different languages in CRMOD.
    Just wanted to confirm this before moving on down that road..
    Regards,
    Allan

    Thank's Bobb. That was unfortunately the answer I expected.
    I can't really wait for the enhancement, so I thought of the following work around:
    - Rename the product name field to product number
    - Create x amout of new product name and product description fields (for each language)
    Do you see any pitfalls here?
    Regards,
    Allan

  • Best practice for adding video

    Hi. I've crafted a lovely app with multiple slideshows which was rejected for lack of interactivity. I'm now in the process of planning multiple short videos and audio files to add into it.
    To test the video feature I used Handbrake to turn a video to a 330 x 178 resolution MP4 h.264. (I will probably make the final versions about 400 horizonta.)
    I used the Place command and in the Content viewer preview it looks fine.
    1) Using the Media panel you can choose the Poster be from a current frame but this does not add the Play symbol so app users might think it a static picture. Is my only option to do this is to make my own poster and add the Play symbol on top or is there an integrated way to do this?
    2) My app pages have white backgrounds. Aesthetically is it 'wrong' to place the video directly on it. Should I just create a larger black rectangle for each video to give it a border or is there anything else to make it look professional?
    3) The Media panel also has a Controller option which i presume allows you to set the video playback controls but anything I select doesn't seem to make a difference. I've also used Lynda but haven't found an explanation. What does it do?
    4) I've viewed the My 9 months app made by forum MVP Bob Levine. When turning to a new page a button pops out with a mic. symbol that when pressed plays back audio. It looks pretty clever. If it's not a trade secret how do you make the button pop out?
    Thanks

    1. I generally create a poster image with that play symbol. Easy enough
    to do. Open the video in Photoshop, go to the frame you want, add the
    symbol and save as a PNG file.
    2. If it looks good, it is good.
    3. If you really want to control the video I'd suggest creating buttons
    and assigning video actions to them
    4. Those are three state MSOs. The first state is an image sequence with
    a go to next state button. The next state is the pop out glossary
    containing a scrolling frame with anchored MP3 files positioned over the
    terms. The close button takes you to a third state with a state version
    of the button.

  • Best practice for adding non networked hardware

    Dear all
    I'm looking for some advice how to manage hardware which is not connected to the network e.g.
    - standalone printers
    - beamers
    - docking stations
    I know that I can do an import using a CSV file (mandatory fields IP and DNS name), however I think there must be another way....
    Thank you & best regards
    Werner

    whenz,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • Best practice for adding images to a RH8 HTML project?

    I'm working on a Word to RH8 HTML conversion. The images in Word are SNAG images but the resolution is poor and some of the images may need to be recreated from scratch again. Going forward I imagine I should work on getting them right in Snagit9. Any suggestions?

    For example, installation help topics dealing with install/uninstall screenshots for an application's client and server:
    client_dir_sum.gif
    client_dot_net.gif
    client_uninst_wlcm.gif
    server_wlcm.gif
    server_cfg_tomcat.gif
    server_success.gif
    server_uninst_wlcm.gif
    ...or, screenshots dealing with an Accounts window:
    acct_groups.gif
    acct_lookup.gif
    acct_lookup_btn.gif
    acct_templates.gif
    In other words, use cfg for configuration, dir for directory, btn for button, etc., and use either a function or application window as your lead, allowing you to see all related graphics in sequential order. If you've ever done any manual book indexing, think of this as Index entries/subentries, only the "entry" in file naming is your leading prefix (client_, acct_, etc.), and your subentries are the rest of each file name. Such as:
    Accounts
    configuring groups
    using lookup feature
    lookup button
    templates
    Use the same naming conventions for your topic file names as well; using this method eliminates the need for virtual folders. Many users on this forum use the folder structure, but editing/renaming/adding/deleting folders seems to very often create all sorts of grief. I find this naming structure to be less stressful.
    Good luck,
    Leon

  • Best practices for sharp text in menus, can't get my W's clear!

    I am making a widescreen movie and trying to get either sharp or non pixelated text in the menus using the latest DVDSP version, be it typed in, a graphic in Photoshop/Illustrator, 300 dpi, the font is always bad (particularly the W's).
    I try Photoshop and the font is bad for a start using the Widescreen setting and anti-aliasing, I try 300 dpi then bringing it in to DVD Studio Pro, still bad.
    I've looked at professional DVD's and they seem to use really clear fonts.
    Does anyone have any good suggestion before I chuck my Apple out the window?!
    Thanks!

    I found the solution, make everything in Illustrator (well text anyway) at a big size then bring it ibto Photoshop in a dicument 1024 x 576 (so no widescreen pixel ratio) then when saving document bring size of Image to 720 x 576 then you get great anti aliased pictures.
    Solved.

  • Looking for best solution for adding Text Alerts to site

    I would like to add a feature to a website which permits visitors to get text alerts on their mobile phones. Can someone recommend an application...preferably one which is free.
    Thanks1

    Here's a tutorial to help you build it into your own application:
    http://net.tutsplus.com/tutorials/php/how-to-send-text-messages-with-php/

  • Best practices for adding link to Google Maps

    Does anyone know anything about this? I want to link to several Google maps, but want to make sure I"m doing it the right way.

    http://forums.adobe.com/message/3917965#3917965

Maybe you are looking for

  • Mid 2010 Macbook Pro +1000 Euro repair costs (no external marks)

    Hello together, I am looking out for some advise. My mid 2010 Macbook Pro 15inch with an anti glare display just got a new logic board. I paid more than 500 Euro at a Premium Reseller called mStore in Kiel (Germany) to replace it, because the display

  • How to set values in JMS Adapter using Adanced specific Message Attributes

    Hi Frnds, in my scenarios i have to add extra header information MQ Message, using Adanced specific Message Attributes i defined 7 parameters(Transaction,Environment,shema......) all are type Interger.But i have to set values ( Transaction type,Envir

  • Button for iTunes scripts and iTunes Plug-Ins is gone in 7.3.x

    In iTunes 7.3.x I am missing the upper button for iTunes scripts and ITunes Plug-Ins for the little add on programs like iTunes-BPM and iTunes-Lame. Does anybody know a trick how I get this button to show up again? I am talking about this button: /__

  • Hidden Objects from Web Templates

    Hello, I have two tabs on a web template. - On the first tab I only want to see the table - On the second one I want to see the chart. I only want to see the Information from one sub- template on every tab) But the result is: If I click on the second

  • Ideas of how to deal with a non-conforming CSV file?!

    Hi there folks, I've been given a CSV file of which I now wish to import into VizionDB -- unfortunately all of the text fields are not surrounded by quotation marks and there's some 9,000 records in total! Other than going back to my client, is there