• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

A Little Help with some Simple Actionscript

Engaged ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

I am using a Flex MobileGrid to display some real estate date in a mobile app. Unfortunately, if the columns contain too much information, they do not automatically truncate the column to ellipsis "..." As a result, I am trying to write an ActionScript ItemRenderer to help with this and am having no success. I am a MXML programmer for the most part, and use actionscript for program logic, but I am not very good with creating my own ActionScript classes. I will list my ActionScript ItemRenderer here. Please let me know if you see anything that would help me to get the ellipsis "..." that I am hoping for. Thanks!

 

package renderers {

    import flashx.textLayout.formats.LineBreak;
    import spark.components.itemRenderers.MobileGridTextCellRenderer;

        public class mobileGridRenderer extends MobileGridTextCellRenderer{

        public function mobileGridRenderer() {
            super();
            multiline = false;
            lineBreak = LineBreak.EXPLICIT;
            truncateToFit("...");
        }
    }
}

 

Views

101

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 09, 2021 Jan 09, 2021

Copy link to clipboard

Copied

LATEST

I know this is basic stuff for most of you, but I thought I would add it for anybody who may have a similar problem. I got the item renderer to work by adding the following code:

 

override public function set data(value:Object):void{
    super.data = value;



    width = AppVars.appWidth * .4;
    multiline = false;
    lineBreak = LineBreak.EXPLICIT;
    truncateToFit("...");
}

 

Apparently, it is important to wait until the "data" has changed before you take the actions to truncate the text, but you also have to set a width for the StyleableTextField that is the basis of the itemrenderer for the truncateToFit method to work properly. The thing that I cannot figure out is why I have to calculate a width the way that I have done above instead of getting it from the MobileGrid that the itemrenderer works on. I would think width=this.width, or width = parent.width, or width = owner.width or something along these lines would work, but I was sadly disappointed. In other words, I have to write a different itemrenderer for every column that I want to truncate because I cannot get the width of the column from within the itemrenderer.

 

Any thoughts on how I might effectively get the width of the column from within the itemrenderer so that I can apply it to the width of the StyleableTextField so that it will truncate at the appropriate place in the string???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines