Label1.text + Label2.text = mess

Hello!

(I guess) im sorry im troubling you with this simple problem. My problem I have simple. I want to add two numbers stored in two different labels.

Ex:
{
Label1.text = 1;
Label2.text = 1;

Label3.Text = Label1.text + Label2.text;
}

The result is that Label3.text becomes 11, but I want it to become 2! How can I add the numbers instead of simply add two strings to each other.

convert strings to numbers using Number().

Tags: Adobe Animate

Similar Questions

  • Text messed up in iTunes 12.3.1.23

    Hello

    Since the update to iTunes 12, various text labels are missing or misplaced. For example, in the screenshots below, you will notice that none of the playlist names appear, any more than what anyone in the top reading window. You will also notice the text to how many songs in my library (or selected) appears higher than expected, so I do not see the bottom of the letters. When I connect to my iPhone, almost no text on the summary screen appears.

    Other weirness:

    -No album covers

    -I can not click on an arbitrary position in the currently playing song, I rather stuck ""<" and="" "="">> "to move"

    I thought I might have a damaged or missing font, but it seems that the labels are simply displaced instead of lack (sometimes so that they seem to be missing).

    I thought that the reclassification of Mavericks in El Capitan could fix, but the problem remains. My iTunes version is 12.3.1.23, OS is 10.11.1. Mid 2012 macbook pro.

    iTunes is almost unusable for me

    After the update was 12.4, the problem disappeared

  • on some Web pages only you use firefox, the display text is sometimes glitched.

    OK, sometimes the text is glitched on Web pages. and if you highlight the text messed up it will be instantly normal. also have the most updated drivers. and this only happens with firefox.

    Hello trentenmarschel, try disabling graphics hardware acceleration. As this feature has been added to Firefox, it has gradually improved, but there are still some problems.

    You will have to perhaps restart Firefox for it to take effect, so save any work first (e.g. you compose mail, documents online that you are editing, etc.).

    Then perform the following steps:

    • Click on the orange top left Firefox button, then select the 'Options' button, or, if there is no Firefox button at the top, go to tools > Options.
    • In the Firefox options window, click the Advanced tab, and then select 'General '.
    • You will find in the list of parameters, the checkbox use hardware acceleration when available . Clear this check box.
    • Now restart Firefox and see if the problems persist.

    This solve your problems? Please report to us!

    Thank you.

  • Unicode text with ios10

    Since Unicode text ios10 does not work...

    for example

    myText.Text = "\u2692";

    Why?

    Hi Thomas,

    We tried with a sample application and thought that this problem could be solved if we use stageText. Please refer to the below excerpt of code:

    package {}

    import flash.display.Sprite;

    import flash.geom.Rectangle;

    import flash.text.StageText;

    SerializableAttribute public class StageTextMulti extends Sprite {}

    private var label1:StageText;

    public void StageTextMulti() {}

    configurationLabel();

    }

    private function configureLabel (): void {}

    Label1 = new StageText();

    Label1.text = "\u2692";

    Label1.color = 0xFF0000

    Label1.FontSize = 30;

    Label1.stage = stage;

    Label1.viewPort = new Rectangle (20, 20, 90, 90);

    }

    }

    }

    However, we further study to TextField on iOS 10.

    Thank you

    Adobe AIR Team

  • Text of the 3D perspective

    Hello world

    I'm creating a Flex application which is in fact a calculator of loan from a bank.

    I have a psd of a designer and have cut out the important part:

    Cropped screenshot

    My problem is the numeric values that have been twisted a bit to create a 3D effect. I think that the designer used the "Edit-> transform-> Perspective' tool of Photoshop.

    Is it possible to create this effect in Flex? Or Flash also.

    Best regards
    Mads

    Are the labels of your dynamic text? If this is the case, the less painful to do this would be to create the context and dynamic text labels in Flash and mix * this SWF in your Flex application.

    In Flash, you can tilt and rotate labels interactively to match what the designer has created. You'll want to tilt them the text first, and then rotate. Tilt the upper part of the text slightly to the left (horizontally). Due to the perspective of the background, each label shall be biased and rotate individually.

    Make sure that the text in Flash is set to "Dynamic text" in the property inspector. Select "Anti-alias for animation". I guess your labels will be numbers only, so incorporate only those to reduce the size of the file. Give a unique name to the instance of this text label. Now, you would be able to fix these labels from your application Flex (e.g., mySWF.label1.text). It is true that if you load the SWF Flash runtime (Flash 9 SWF).

    For Flash 8 SWF, or if you are incorporating the final Flash SWF in your Flex application, you must use LocalConnection to set the labels in your Flex application. The docs have a few examples on the use of LocalConnection.

    TS

    Edit: Changed "Anti-alias for readability" to "Anti-alias for animation".

  • StackLayout works do not (children that overlap)

    I'm trying to use the StackLayout in AIR BB10 application for the first time and things are not stacked.

    Example code:

    package
    {
        import flash.display.Sprite;
        import qnx.fuse.ui.dialog.AlertDialog;
        import qnx.fuse.ui.text.Label;
        import flash.events.Event;
        import qnx.fuse.ui.text.TextFormat;
    
        import qnx.fuse.ui.core.*;
        import qnx.fuse.ui.layouts.stackLayout.*;
        import qnx.fuse.ui.listClasses.*;
    
        [SWF(width="768", height="1280", backgroundColor="#000000", frameRate="60")]
        public class Example extends Sprite
        {
            private var label1:Label = new Label();
            private var label2:Label = new Label();
    
            public function Example()
            {
                try
                {
                    init();
                }
                catch(error:Error)
                {
                    dialog("Error on Initialization", error.message);
                }
            }
    
            private function init():void
            {
                var container : Container = new Container();
                container.setActualSize(stage.stageWidth, stage.stageHeight);
                container.scrollDirection = ScrollDirection.VERTICAL;
    
                var layout : StackLayout = new StackLayout();
                layout.padding = 25;
    
                container.layout = layout;
                addChild(container);
    
                var myFormat:TextFormat = new qnx.fuse.ui.text.TextFormat();
                myFormat.bold = true;
                myFormat.size = 50;
                myFormat.color = 0xFFFFFF;
                myFormat.font = "Slate Pro";
    
                label1.text = "A";
                label1.format = myFormat;
                label1.validateNow();
                label1.height = label1.textHeight;
                label1.width = label1.textWidth;
                container.addChild(label1);
    
                label2.text = "B";
                label2.format = myFormat;
                label2.validateNow();
                label2.height = label2.textHeight;
                label2.width = label2.textWidth;
                container.addChild(label2);
            }
    
            private function debug(msg:String):void
            {
                dialog("Debug", msg);
            }
    
            private function dialog(title:String, msg:String):void
            {
                var alert:AlertDialog = new AlertDialog();
                alert.title = title;
                alert.message = msg;
                alert.addButton("Ok");
                alert.show();
            }
        }
    }
    

    The labels 'A' and 'B' overlap in the upper left corner.

    "The StackLayout class organizes controls in a pile that overlap, where the stack is defined by the control hierarchy."

    Well, this explains why.

    Why the Cascades StackLayout work go and AIR StackLayout work otherwise?

    The Cascades class organizes things horizontally or vertically.

    Sigh.

  • Label visibility does not not with actionItem

    Hello

    I have a follow up on my page. I want to alternate the two labels of visibility on my page. So when I click on the action point first, I want the title to change the visibility of Label1 to disable and visibility of Label2 to switch on. And conversely, when I hit the actionitem twice.

    When I click on it the first time, changes in visibility (i.e. no visible = label1, label2 = visible and the title was changed to the action item).  However, it will not work the second time I click on the button - it remains fair to label2 = visible and the title for the action remains the same.

    Any ideas? Here is my code below:

    Page {
        id: pageID
        Container {
            id: rootContainer
            Label {
                visible: true
                id: label1
                text: "Label 1"
            }
            Label {
                visible: false
                id: label2
                text: "Label 2"
            }
        }
    
        actions: [
            ActionItem {
                id: actionitem
                title: "View Label 2"
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    if (label1.visible = true) {
                        label1.visible = false
                        label2.visible = true
                        actionitem.title = "View Label 1"
                    } else if (label2.visible = true) {
                        label2.visible = false;
                        label1.visible = true;
                        actionitem.title = "View Label 2"
                    }
                }
            }
        ]
    }
    

    Hello

    My friend ther are different between '=' and '== '.

    You must write "is" (label1.visible = true) in your code to check the status.
    .

    Statement of console.log("") User for debugging.

  • minWidth = USE_COMPUTED_SIZE is ignored?

    I want to throw a simple HBox like this:

    [label1] [label2...] [label3]

    I want label3 to be aligned to the right, and I'm more interested to see the contents of the label1 and that label2 label3 when the container shrinks. If naively, I think I should put minWidth = USE_COMPUTED_SIZE for the major labels and to label3 justified to the right, I put HBox.hgrow = ALWAYS for the middle label:
    <HBox xmlns:fx="http://javafx.com/fxml" spacing="5">
      <maxWidth>
        <Double fx:constant="MAX_VALUE" />
      </maxWidth>
      <Label fx:id="label1" text="Important Label">
        <minWidth>
          <Pane fx:constant="USE_COMPUTED_SIZE" />
        </minWidth>
      </Label>
      <Label fx:id="label2" text="Vastly less important message" HBox.hgrow="ALWAYS" />
      <Label fx:id="label3" text="Important Label">
        <minWidth>
          <Pane fx:constant="USE_COMPUTED_SIZE" />
        </minWidth>
      </Label>
    </HBox>
    But it does not work in most respects! Label3 is not justified to the right, and the labels 1 and 3 shrink ellipses as fast, if not faster, than label2 when I do the narrow window. A little experimentation reveals that defining a large maxwidth on label2 realizes the justification right that I want, but minwidth is always a problem.

    Look, I think USE_COMPUTED_SIZE (-1.0) is actually the minwidth default! What good is that?

    If instead of using USE_COMPUTED_SIZE, I simply set the minwidth of labels 1 & 3 at real value 99, they shrink indeed later than label2. But of course, I don't want to hardcode a minwidth like that. What am I supposed to do?

    Try something similar to the following.
    Load it into SceneBuilder 1.1 +, then choose overview | Look in the window and resize the preview window to test the resizing behavior:

    
    
    
    
    
    
    
    
    
    
      
        
          
            
          
            
          
        
      
    
    

    This is probably not exactly what you want, but I hope it's useful.

    Curiously, in my tests, the HBox.hgrow SOMETIMES priority seems to be no preference on priority NEVER. So, when you resize the smallest thing, the first two labels are starting to get shortened unless you start specify values of minWidth.

    So I put the minWidth of the first label of the default width (and even for the last label). Which causes two important to have never shortened labels (which could be the behavior for the major labels in any case).

    Setting of the alignment of the HBox himself to CENTRE_DROITE means (in combination with HBox.hgrow of ALWAYS of good label most and a default width minWidth) right-most important label is still visible and the other labels get pushed out of the left hand side if there is not enough room.

    Affecting the maxWidth to the label right alignment MAX_VALUE and CENTRE_DROITE right aligns the label in the HBox.

    The styles are just there so that it is easy to see how each label is high - will normally keep such things in a style sheet.

    Values for things like minWidth = ""-Infinity "and maxWidth ="1.7976931348623157E308"are weird constants because that's what SceneBuilder outputs rather than something non-sensiques like Label.USE_PREF_SIZE or Double.MAX_VALUE"

    And Yes, as you point out in your question "USE_COMPUTED_SIZE (-1.0) is actually the default minwidth", so there is no need to explicitly set minWidth value.

  • Edit PS CS5 3D

    Hello!

    I know almost nothing about the 3D and wonder if it's possible with the PS:

    I got a 3D model of a bottle, the Panel of the stage shows, next to the light, 3 "objects", which are, respectively: a sticker on the bottle (object001/label2), the bottle itself (wine_0/wine) and the top of the bottle (line001/material_91937, label1).

    The layer panel shows, only a single layer, called layer 1 that contains texturs for: material_91937, wine, label1 and label2.

    Now, what I would do:

    On this bottle, I want to add a new stcker with a text on this subject; is it possible to do it in photoshop?

    No idea can be useful.

    Thank you

    Edgar

    This model will never work as you want because it has not been established proeprly. This is very typical of the free patterns on the net, but with a little hunting, you can find something that works.

    Here is my result with the model, just to check...

    You can find a model much better here:

    http://www.sweethome3d.com/importModels.jsp

  • Reference a radiobutton in a group of components

    I am new to export and work with catalyst for Flex project files. I imported a catalyst project into Flash Builder, and I have a problem.

    This is my problem:

    I have a component that contains a group that I must so I can add code to get the current value selected for the reference group. How can I make reference to this group? Catalyst the group name is "radioGroup". I don't see a reference like that in my Flash Builder project.

    for example, it is similar to the structure of the component:

    <>Group

    ...

    < radiobutton id = "radiobutton2" / >

    < radiobutton / >

    ...

    < / Group >

    Since I have an ID for the first item I thought I'd be able to get the parent group by referring to "radiobutton2". I don't know how to reference radiobutton2 with AS3 in Flash Builder/Flex.

    Does anyone know how could reference "radiobutton2" so I can get the group like this: radiobutton2.group?

    Thank you

    -Eric

    Main.MXML


    http://ns.Adobe.com/MXML/2009.
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx".
    "minWidth ="955"="600"xmlns:local = minHeight" * ">
       
       
            public function getValues (): void
    {
    Label1.text = myGroup.radioButton1.value.toString ();
    Label2.text = myGroup.radioButton2.value.toString ();
    If (myGroup.radioButtonGroup.selectedValue! = null)
    {
    Label3.text = myGroup.radioButtonGroup.selectedValue.toString ();
    }
    on the other
    {
    Label3.text = "nothing selected";
    }
    }
    ]]>
       

       
       
           
       

       
       
       
       
       
       
       

    MyGroup.mxml


    http://ns.Adobe.com/MXML/2009.
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" >
       
           
       

       
       
           
       

       
       
       
       
           
       

       
       

  • Flex glitch?

    Hello guys, I'm doing a simple animation here. When I click btn1, the State will change, the button moves and labels fade (btn will have to move first, then labels fade). When I click btn2 that State will change, moving the buttons and labels will be fades out. My problem is when the btn2 is clicked, somehow kills enforcement btn1 without reason and the animation is completely off the track... I paste my sample code here and really need help from someone. I tried to solve this problem for more than 10 hours... .. Thanks for any response...

    <? XML version = "1.0" encoding = "utf-8"? >

    " < = xmlns:fx s:Application ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx" minWidth = "955" = "600" minHeight >

    < fx:Script >

    <! [CDATA]

    protected function btn1_clickHandler(event:MouseEvent):void

    {

    currentState = 'state2 ';

    }

    protected function btn2_clickHandler(event:MouseEvent):void

    {

    currentState = "state3;

    }

    ]]>

    < / fx:Script >

    < fx:Declarations >

    <! - Place non-visual elements (e.g., services, items of value) here - >

    < / fx:Declarations >

    < s: states >

    < s: State name = "state1" / >

    < s: State name = 'state2' / >

    < s: State name = "State3" / >

    < / s: states >

    < s:transitions >

    < s:Transition toState = 'state2' >

    < s:Parallel >

    < s:Move target = "{[btn1, btn2]}" / >

    < s:AddAction target = "{[label1, label2, label3, textInput1, textInput2, textInput3]}" / >

    < s: bland target = "{[label1, label2, label3, textInput1, textInput2, textInput3]}" / >

    < / s:Parallel >

    < / s:Transition >

    < s:Transition toState = "State3" >

    < s: bland target = "{[label1, label2, label3, textInput1, textInput2, textInput3]}" / >

    < / s:Transition >

    < / s:transitions >

    the labels and buttons I want to fade

    < s:Label = "10" text = "label1" id = "label1" includeIn = "state2" / >

    < s:TextInput = "30" id = "textInput1" includeIn = "state2" / >

    < s:Label = "50" text = "label1" id = "label2" includeIn = "state2" / >

    < s:TextInput = "70" id = "textInput2" includeIn = "state2" / >

    < s:Label = "90" text = "label1" id = "label3" includeIn = "state2" / >

    < s:TextInput = "120" id = "textInput3" includeIn = "state2" / >

    < s:Button = y.state2 = "350"180"" label = "btn1" id = "btn1" click = "btn1_clickHandler (event)" / > "

    < s:Button = y.state2 = "550"250"" label = "btn2" id = "btn2" click = "btn2_clickHandler (event)" / > "

    < / s:Application >

    Hello

    I changed it a bit, it can be optimized alittle better but did not have much time, you didn't need the 3 States so I removed 1 and made a 3 State, by default. I hope this will help you a little.

    David.

    http://ns.Adobe.com/MXML/2009.

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx" minWidth = minHeight = "955" "600" currentState = "State3" >

    protected function btn1_clickHandler(event:MouseEvent):void

    {

    currentState = 'state2 ';

    }

    protected function btn2_clickHandler(event:MouseEvent):void

    {

    currentState = "state3;

    }

    ]]>

  • Incorrect label height

    I have a code which creates a label, and then is supposed to use the height of this label to determine where to put another beneath him.  The problem is that the height returned is always 22, whether a line or two and change the font size does not change it no more.  These labels are created in a table.  Here is a code example:

    Outside of the table:

    var myFont: Font = new helvetica_bold();

    var text_format:TextFormat = new TextFormat();

    TEXT_FORMAT.font = myFont.fontName;

    TEXT_FORMAT. Size = 14;

    TEXT_FORMAT. Align = "center";

    On the inside of the table:

    Add Label 1

    var text_string1:String = xmlData.Product [i] .name;

    var label1:Label = new Sun;

    label1.move(xpos,ypos);

    label1.width = 200;

    label1.wordWrap = true;

    label1.text = text_string1;

    label1.autoSize = TextFieldAutoSize.CENTER;

    label1.textField.antiAliasType = AntiAliasType.ADVANCED;

    label1.setStyle ("IncorporerPolices", true);

    label1.setStyle ("textFormat", text_format);

    addChild (label1);



    / / / Add label 2

    var text_string2:String = xmlData.Product [i] .brand;

    var label2:Label = new Sun;

    trace (label1.height);        It always returns the value 22

    label2.move (xpos, ypos + label1.height);

    label2.width = 200;

    label2.wordWrap = true;

    label2.text = text_string2;

    label2.autoSize = TextFieldAutoSize.CENTER;

    label2.textField.antiAliasType = AntiAliasType.ADVANCED;

    label2.setStyle ("IncorporerPolices", true);

    label2.setStyle ("textFormat", text_format);

    addChild (label2);

    Because labels can be a line or two lines, I need this height must be generated dynamically.  Any ideas on how to have the label returned with precision height?  Should I use a different text object instead?

    Thank you!

    I think that the method drawNow() can help you. You might like this:

    Import fl.controls.Label;

    var pos:Number = 0;
    var pad: Number = 10;
    for (var i = 0; i)<3; i++)="">
    var l:Label = new Sun;
    l.wordWrap = true;
    l.autoSize = 'left ';
    l.Text = "Hello world. How are the wife and children? « ;
    addChild (l);
    l.drawNow ();
    l.y = pos;
    POS += l.height + pad;
    }

  • Edge of metering using nicaiu.dll

    I am trying to create a counter edge by directly calling functions in VB.NET nicaiu.dll. I am able to read the counter OK value but counties still return to the initial value set when I created the channel. For example, I create the task of counter by using DAQmxCreateCICountEdgesChan and the value of the initial counter 100000. I then read the meter using DAQmxReadCounterScalarU32. The County changes when I turn the encoder cable channel meter but returns to 100000 once the encoder stops.

    The wiring is correct, because it works correctly using the Test i/o counter OR-max Panel. The number increases as I turn the encoder and never resets when the encoder stops.

    Finally, I need to get this working using DAQmxCreateCILinEncoderChan but I see the same behavior when using this type of channel. For now, I use DAQmxCreateCICountEdgesChan because it is easier and mimics the function in the Test NOR-MAX Panel.

    I did this job using the .NET DAQmx API. However, there are errors when my application runs on a computer with a different version of NOR-DAQmx of what was used when the application is compiled. The appeal of the DLL directly seems to eliminate problems with different versions of DAQmx.

    No idea what I'm missing?

    Public Class Form1

    Private Declare Function DAQmxCreateTask Lib "nicaiu.dll" (ByVal TaskName As String, ByRef NITaskHandle As IntPtr) As Integer
    Private Declare Function DAQmxCreateCICountEdgesChan Lib "nicaiu.dll" (ByVal TaskHandle As Integer, ByVal PhysicalChannel As String, ByVal NameToAssignToChannel As String, ByVal edge As Integer, ByVal InitialCount As UInteger, ByVal CountDirection As Integer) As Integer
    Private Declare Function DAQmxReadCounterScalarU32 Lib "nicaiu.dll" (ByVal TaskHandle As Integer, ByVal Timeout As Double, ByRef ReadVal As UInteger, ByVal Reserved As IntPtr) As Integer

    Private Const DAQmx_Val_Rising = 10280
    Private Const DAQmx_Val_Falling = 10171

    Private Const DAQmx_Val_CountUp = 10128
    Private Const DAQmx_Val_CountDown = 10124
    Private Const DAQmx_Val_ExtControlled = 10326

    Private TaskHandle As IntPtr

    Private Const STARTCOUNT = 100000
    Private Const DEVICECHAN = ' DEV1/CTR0.

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim ErrVal As Integer

    ErrVal = DAQmxCreateTask ("ENCODER", TaskHandle)
    Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

    ErrVal = DAQmxCreateCICountEdgesChan (TaskHandle, DEVICECHAN, "ENCODER", DAQmx_Val_Rising, STARTCOUNT, DAQmx_Val_CountUp)
    Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

    Dim ErrVal As Integer
    InVal As UInteger Dim

    ErrVal = DAQmxReadCounterScalarU32 (TaskHandle, 0, InVal, Nothing)
    Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

    Label1.text = InVal.ToString

    End Sub

    End Class

    Try to explicitly run your task (DAQmxStartTask) after you have created the channel meter.  If you do not explicitly start your task, the appeal of reading starts the job instead, which would reset the count value.

    As far as I know if only this should once (on the first read call), then maybe it something else.

    Out of curiosity, have you considered using the API of VB.NET DAQmx instead of the dll unmanaged c?

    Best regards

  • CellRenderer attracts more when resizing to a list

    I can't understand why the box drawn in my CellRenderer class shoot each other when resizing to height of the list. Here's the example code to demonstrate. Click resize.

    package
    {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
    
        import qnx.fuse.ui.buttons.LabelButton;
        import qnx.fuse.ui.listClasses.List;
        import qnx.ui.data.DataProvider;
    
        [SWF(height="600", width="1024", frameRate="30", BackgroundColor="#000000")]
        public class test3 extends Sprite
        {
            private var l:List = new List();
            public function test3()
            {
                var dp:DataProvider = new DataProvider();
                for (var i:int = 0;i<=10;i++)
                {
                    dp.addItem({number:i});
                }
                l.dataProvider = dp;
                l.setPosition(10,50);
                l.width = 1004;
                l.height = 500;
                l.cellRenderer = test3CellRenderer;
                addChild(l);
    
                var b:LabelButton = new LabelButton();
                b.label = "Resize List";
                b.addEventListener(MouseEvent.CLICK, but_click);
                addChild(b);
            }
            private function but_click(e:MouseEvent):void
            {
                if (l.height != 200)
                    l.height = 200;
                else
                    l.height = 500;
            }
        }
    }
    

    and my CellRenderer class:

    package
    {
        import flash.display.Sprite;
    
        import qnx.fuse.ui.listClasses.AlternatingCellRenderer;
        import qnx.fuse.ui.text.Label;
    
        public class test3CellRenderer extends AlternatingCellRenderer
        {
            private var label1:Label;
    
            public function test3CellRenderer()
            {
                super();
            }
    
            override protected function init():void
            {
                label1 = new Label();
                label1.width = 200;
                addChild( label1 );
                super.init();
            }
    
            override public function set data( data:Object ):void
            {
                super.data = data;
    
                if (data != null)
                {
                    label1.text = data.number;
                    var _color:uint;
                    if(data.number == 0 || data.number == 2 || data.number== 4 || data.number ==  6 || data.number== 8)
                        _color = 0x068000;
                    else
                    _color = 0xC40000;
                    var s:Sprite = new Sprite();
                    s.graphics.beginFill(_color);
                    s.graphics.drawRect(200, 1, 100, 48);
                    s.alpha = .5;
                    addChild(s);
                }
            }
        }
    }
    

    You must add elements in the function onAdded() Overrides and remove them to the function onRemoved() override.

    //////////////////////////////////////////////////////////////////
        override protected function onAdded():void
        {
            super.onAdded();
            this.addChild( this.label1 );
        }
    
            ////////////////////////////////////////////////////////////////
        override protected function onRemoved():void
        {
            super.onRemoved();
            this.removeChild( this.label1 );
        }
    
  • QML/C++ call problem

    Hey guys. Looking for a little help here. I know that this problem has been addressed before, but I'm a little lost. I have searched the forums and looked through the tutorials, but I havn't been able to find the answer I was looking for. I'm calling a simple C++ function of my UI QML/waterfalls and it won't work. The problem I have is I've seen code snipets where people have solved their problems with this, but nothing as an explanation as to what or why of it. In any case, here are a few snippets, please tell me what I'm missing here.

    Main.qml// Default empty project template
    import bb.cascades 1.0
    
    // creates one page with a label
    // The button was added by me to change the text of the label
    
    Page {
        Container {
            layout: DockLayout {}
            Label {
                id: label1
                text: qsTr("Huh?")
                textStyle.base: SystemDefaults.TextStyles.BigText
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
            Button {
                text: "Say Hi..."
                onClicked: { label1.text=HelloWorld.returnMyString(); //Works perfectly if written label1.text="Hello World";
    
                }
            }
        }
    }
    
    HelloWorld.cpp
    
    // Default empty project template
    #include "HelloWorld.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    HelloWorld::HelloWorld(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
        // set created root object as a scene
        app->setScene(root);
    }
    
    //The only thing I added to the file was this function
    QString HelloWorld::returnMyString()
    {
        return ("Hello World");
    }
    
    HelloWorld.hpp
    
    // Default empty project template
    #ifndef HelloWorld_HPP_
    #define HelloWorld_HPP_
    
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class HelloWorld : public QObject
    {
        Q_OBJECT
    public:
        HelloWorld(bb::cascades::Application *app);
        virtual ~HelloWorld() {}
    
        //Added the ability to invoke the function from QML
        Q_INVOKABLE QString returnMyString();
    };
    
    #endif /* HelloWorld_HPP_ */
    

    I don't know what I'm missing here. What I read in other posts, I had what seems to be correct, but if I call it as I wrote, then the feature apparently never gets called and nothing happens. I don't get the error while compiling codes and it works on the SIM perfectly, except for the inability to call the C++ function.

    If you guys can give me some guidance, I think I could really off and running with my real application coding. I know that there must be something stupid that I'm missing.

    Thank you guys!

    Hello

    You must give your qml know your c++ as follows object before accessing an object c ++ QML.

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);qml->setContextProperty("HelloWorld",this);
    

    MAZ

Maybe you are looking for