How to remove the object dynamically?

Hi all

I created an object dynamically. But I don't know how to remove dynamically in QML.

I called the function to "destroy ()", but I don't know it works or not. The code is as follows:

LogView.qml

import bb.cascades 1.0

ScrollView {
    id:logviewaaa

    signal addnewlog

    property variant number:100
    property variant log1
    property variant log2
    property variant log3
    property variant log4
    property variant log5
    property variant log6
    property variant log7
    property variant log8
    property variant log9
    property variant log10

    onAddnewlog:{

        number=logcontain.count()
        console.log("the log number is "+number)
        if(number == 0)
        {
            console.log("ready to add the first log");
            log1 = log.createObject(logcontain);
            console.log("ready to add the first log");
            logcontain.add(log1);

        }else if(number ==1){

            log2 = log.createObject(logcontain)
            logcontain.add(log2)

        }else if(number ==2){
            log3 =log.createObject(logcontain)
            logcontain.add(log3)
        }else if(number ==3){
            log4=log.createObject(logcontain)
            logcontain.add(log4)
        }else if(number == 4){
            log5=log.createObject(logcontain)
            logcontain.add(log5)
        }else if(number ==5){
            log6=log.createObject(logcontain)
            logcontain.add(log6)
        }else if(number ==6){
            log7=log.createObject(logcontain)
            logcontain.add(log7)
        }else if(number ==7){
            log8=log.createObject(logcontain)
            logcontain.add(log8)
        }else if(number ==8){
            log9=log.createObject(logcontain)
            logcontain.add(log9)
        }else if(number ==10){
            log10=log.createObject(logcontain)
            logcontain.add(log10)
        }
     }

    Container{
     id:logcontain      

    onCreationCompleted:{
    }

      attachedObjects:[
          ComponentDefinition{
              id:log
              source:"Log.qml"
          }

      ]

    }

}

Log.QML:

import bb.cascades 1.0

    Container {
       id:root
        signal deletethislog

        TextArea{
            id:recordlog
            inputMode:TextAreaInputMode.Text
        }
    Container {
         id:buttoncontain
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }
        Button {
            id: edittext
            imageSource: "asset:///icons/ic_edit.png"
            onClicked: {
                recordlog.editable = true
            }

        }
        Button {
            id: oktext
            imageSource: "asset:///icons/ic_done.png"
            onClicked: {
                recordlog.editable = false
            }

        }
        Button{
            id:deletetext
            imageSource: "asset:///icons/ic_delete.png"
            onClicked: {
                destroy()
            }

            layoutProperties: AbsoluteLayoutProperties {

            }
            horizontalAlignment: HorizontalAlignment.Right

        }
    }
    onCreationCompleted:{
    }
}

Thank you.

brad_qqq

I solved this problem. I always use "destroy()" function to solve. The code is as follows:

LogView.qml

import bb.cascades 1.0

ScrollView {
    id:logviewaaa

    signal addnewlog

    property variant number:100
    property variant log1
    property variant log2
    property variant log3
    property variant log4
    property variant log5
    property variant log6
    property variant log7
    property variant log8
    property variant log9
    property variant log10

    onAddnewlog:{

        number=logcontain.count()
        console.log("the log number is "+number)
        if(number == 0)
        {
            console.log("ready to add the first log");
            log1 = log.createObject(logcontain);
            console.log("ready to add the first log");
            logcontain.add(log1);
            log1.objectaaa=log1
            log1.maincontain=logcontain

        }else if(number ==1){

            log2 = log.createObject(logcontain)
            logcontain.add(log2)
            log2.objectaaa = log2
            log2.maincontain = logcontain

        }else if(number ==2){
            log3 =log.createObject(logcontain)
            logcontain.add(log3)
            log3.objectaaa = log3
            log3.maincontain = logcontain
        }else if(number ==3){
            log4=log.createObject(logcontain)
            logcontain.add(log4)
            log4.objectaaa = log4
            log4.maincontain = logcontain
        }else if(number == 4){
            log5=log.createObject(logcontain)
            logcontain.add(log5)
            log5.objectaaa = log5
            log5.maincontain = logcontain
        }else if(number ==5){
            log6=log.createObject(logcontain)
            logcontain.add(log6)
            log6.objectaaa = log6
            log6.maincontain = logcontain
        }else if(number ==6){
            log7=log.createObject(logcontain)
            logcontain.add(log7)
            log7.objectaaa = log7
            log7.maincontain = logcontain
        }else if(number ==7){
            log8=log.createObject(logcontain)
            logcontain.add(log8)
            log8.objectaaa = log8
            log8.maincontain = logcontain
        }else if(number ==8){
            log9=log.createObject(logcontain)
            logcontain.add(log9)
            log9.objectaaa = log9
            log9.maincontain = logcontain
        }else if(number ==10){
            log10=log.createObject(logcontain)
            logcontain.add(log10)
            log10.objectaaa = log10
            log10.maincontain = logcontain
        }
     }

    Container{
     id:logcontain      

    onCreationCompleted:{
    }

      attachedObjects:[
          ComponentDefinition{
              id:log
              source:"Log.qml"
          }

      ]

    }

}

Log.QML:

import bb.cascades 1.0

    Container {
       id:root
       //objectName:"thislog"
        signal deletethislog
        property variant objectaaa
        property variant maincontain

        TextArea{
            id:recordlog
            inputMode:TextAreaInputMode.Text
        }
    Container {
         id:buttoncontain
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }
        Button {
            id: edittext

            imageSource: "asset:///icons/ic_edit.png"
            onClicked: {
                recordlog.editable = true
            }

        }
        Button {
            id: oktext
            imageSource: "asset:///icons/ic_done.png"
            onClicked: {
                recordlog.editable = false
            }

        }
        Button{
            id:deletetext
            imageSource: "asset:///icons/ic_delete.png"
            onClicked: {

               selfdestroy()
            }

            layoutProperties: AbsoluteLayoutProperties {

            }
            horizontalAlignment: HorizontalAlignment.Right

        }
    }
    onCreationCompleted:{
        deletetext.clicked.connect(deletethislog)
    }
    function selfdestroy(){
        objectaaa.destroy()
        maincontain.remove(objectaaa)

    }
}

brad_qqq

Tags: BlackBerry Developers

Similar Questions

  • [REQUEST] How to remove the object from the list to display and memory that added dynamic

    Hi there everyone,

    I have a question which I hope you guys can help me with, so the question is:


    "How to remove us (sprite object that has an external swf that it is child) display and, above all, of the memory, but we can still use the same variable to add another object (yes another sprite like the one we have removed yet a different content)..,

    I did tried the removeChildAt thing he did remove all the child of the display list, but I still can hear the sound of the video running.

    Here is the code on a small scale of what I do (sorry that I can only give you chunk code loading and adding)

    var SWFList:XMLList; used to contain a list of all the external swf source, atribute and etc.
    var totalSWF:int; the total number of swf external, it must be charged

    var swfLoader:Loader; instance of the loader class to load external swf file

    function loadSWF (): void
    {
    for (var i: Number; i < totalSWF; i ++)

    swfLoader = new Loader();
    swfLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, onSWFLoadComplete);
    swfLoader.load (new URLRequest (SWFList [i], .@source));
    }

    function onSWFLoadComplete(e:Event):void

    {

    this.stage.addChild (e.target.content);

    }

    and also if you can give an example of a good method of dynamic add the object to the stage I would really appreciate cause I suspect mine are bad method.

    Thank you all.

    If you have been publishing for fp 10, just use unloadAndStop().

    I assume you're not publication for fp 10 so you have to use something like:

    function clearScreen (): void
    {
    var mc:MovieClip = MovieClip (swfLoader.content);

    MC.yourflvintheloadedswf.Stop ();

    mc.mcinyourloadedswfthathasalistener.removeEventListener (MouseEvent.CLICK, whateverF);

    etc.

    swfLoader.unload ();
    }

  • How to remove the object in video

    I recorded a concert of kid, but some parents walked in my path for 3 seconds, how do I remove these topic unwanted on my video of EPA 12?

    Angus-Y

    What version of Premiere Elements you are using and on what computer operating system is running?

    How much of the frame of these consumes upward? It is small enough so that you can insert a picture indeed image to replace with this type of coverage?

    Can cut you just 3 seconds of video?

    I think that the expression of today for this kind of thing is photobombing, I suppose that videobombing in this case. Depending on the location of the people, you could do a depth of field type of thing with matte where they are on your person of interest fading is in full discussion.

    The details of the circumstance will lead plans to save the 3 seconds of video.

    RTA

  • How to remove the object from the stage

    Hello

    I am currently implementing an AS3 code that generates a snow effect on the scene.  I am using the code from this site, but has difficulty:

    http://www.Kirupa.com/developer/flashcs4/falling_snow_as3_cs4_pg5.htm

    I have no difficulty in implementing of the snow, but I can't understand how get rid of it once it's there!  Here's the code, I have:

    (main.as)

    main/public class extends MovieClip

    {

    var snowamount = 50;

    public void main()

    {

    scene9. SnowPlus.addEventListener (MouseEvent.MOUSE_DOWN, moresnow);

    }

    function makeItSnow()

    {

    for (var i: int = 0; i < snowamount; i ++)

    {

    var newSnowFlake:Snowflake = new Snowflake();

    this.addChild (newSnowFlake);

    newSnowFlake.SetInitialProperties ();

    triggerSnowAnimation();

    }

    }

    function moresnow (MouseEvent): void

    {

    snowamount += 20;

    makeItSnow();

    }

    function triggerSnowAnimation()

    {

    If (snowamount > = 160)

    {

    scene9.gotoAndPlay (3);

    scene9. SnowPlus.Visible = false;

    }

    }

    (Snowflake.as)

    SerializableAttribute public class extends MovieClip Snowflake

    {

    private var xPos:Number = 0;

    private var yPos:Number = 0;

    private var xSpeed:Number = 0;

    private var ySpeed:Number = 0;

    private var radius: Number = 0;

    private var scale: Number = 0;

    private var alphaValue:Number = 0;

    private var maxHeight:Number = 0;

    private var maxWidth:Number = 0;

    public void Snowflake()

    {

    }

    public void SetInitialProperties()

    {

    xSpeed is.05 + Math.random () *.1;.

    ySpeed =.1 + Math.random () * 3;

    RADIUS =.1 + Math.random () * 2;

    Scale =.01 + Math.Random ();

    alphaValue =.1 + Math.Random ();

    var stageObject:Stage = this.stage in the stadium;

    maxWidth = stageObject.stageWidth;

    maxHeight = stageObject.stageHeight;

    This.x = Math.random () * maxWidth;

    This.y = Math.random () * maxHeight;

    PosX = this.x;

    yPos = this.y;

    this.scaleX = this.scaleY = scale;

    This.Alpha = alphaValue;

    this.addEventListener (Event.ENTER_FRAME, MoveSnowFlake);

    }

    function MoveSnowFlake(e:Event)

    {

    xPos += xSpeed;

    yPos += ySpeed;

    This.x += radius * Math.cos (xPos);

    This.y += ySpeed;

    If (this.y - this.height > maxHeight)

    {

    This.y = - 10 - this.height;

    This.x = Math.random () * maxWidth;

    }

    }

    }

    The code is not so difficult to understand, in fact.  I have a button that adds "snowamount" to the variable, so more snow is done on the scene when the button is clicked.  However, once the "snowamount" gets above 160 bee, I trigger an animation.  Once the animation is completed, I want the snow to disappear from the scene.  But I can't understand the correct way to do everything.  Any help would be appreciated!  Thank you very much in advance.

    create an array and store your references to Snowflake in this table.  When you are ready to remove the snow flakes, loop in the table.

    main/public class extends MovieClip

    {

    var snowamount = 50;

    var snowFlakeA:Array = [];

    public void main()

    {

    scene9. SnowPlus.addEventListener (MouseEvent.MOUSE_DOWN, moresnow);

    }

    function makeItSnow()

    {

    for (var i: int = 0; i< snowamount;="">

    {

    var newSnowFlake:Snowflake = new Snowflake();

    snowFlakeA.push (newSnowFlake);

    this.addChild (newSnowFlake);

    newSnowFlake.SetInitialProperties ();

    triggerSnowAnimation();

    }

    }

    function moresnow (MouseEvent): void

    {

    snowamount += 20;

    makeItSnow();

    }

    function triggerSnowAnimation()

    {

    If (snowamount > = 160)

    {

    scene9.gotoAndPlay (3);

    scene9. SnowPlus.Visible = false;

    }

    }

    (Snowflake.as)

    SerializableAttribute public class extends MovieClip Snowflake

    {

    private var xPos:Number = 0;

    private var yPos:Number = 0;

    private var xSpeed:Number = 0;

    private var ySpeed:Number = 0;

    private var radius: Number = 0;

    private var scale: Number = 0;

    private var alphaValue:Number = 0;

    private var maxHeight:Number = 0;

    private var maxWidth:Number = 0;

    public void Snowflake()

    {

    }

    public void SetInitialProperties()

    {

    xSpeed is.05 + Math.random () *.1;.

    ySpeed =.1 + Math.random () * 3;

    RADIUS =.1 + Math.random () * 2;

    Scale =.01 + Math.Random ();

    alphaValue =.1 + Math.Random ();

    var stageObject:Stage = this.stage in the stadium;

    maxWidth = stageObject.stageWidth;

    maxHeight = stageObject.stageHeight;

    This.x = Math.random () * maxWidth;

    This.y = Math.random () * maxHeight;

    PosX = this.x;

    yPos = this.y;

    this.scaleX = this.scaleY = scale;

    This.Alpha = alphaValue;

    this.addEventListener (Event.ENTER_FRAME, MoveSnowFlake);

    }

    function MoveSnowFlake(e:Event)

    {

    xPos += xSpeed;

    yPos += ySpeed;

    This.x += radius * Math.cos (xPos);

    This.y += ySpeed;

    If (this.y - this.height > maxHeight)

    {

    This.y = - 10 - this.height;

    This.x = Math.random () * maxWidth;

    }

    }

    function removeSnowF (): void {}

    for (var i: int = snowFlakeA.length - 1; i > = 0; i--) {}

    this.removeChild (snowFlakeA [i]);

    snowFlakeA.splice (i, 1);

    }

    }

    }

  • How to remove the objects that appear only in outline view?

    I've hidden objects in a file that only appear in schema view. It wont let me select them and is to make the file larger then it must be. Any ideas to get rid of these unwanted items? Thank you!

    You can check if there is a clipping mask in this layer. Open the layer by clicking on the triangle.

  • I would like to know how to remove the box/cursor information dialog box that appears whenever I have stop my mouse on an object.

    I would like to know how to remove the box/cursor information dialog box that appears whenever I have stop my mouse on an object.

    Have you tried to uncheck both options via Control Panel / folder Options / View?

    "Displays the size of file in folder tips".

    "Display descriptions pop - up for folder and desktop items"

  • How to remove an object (created by a script) element of the project?

    For example:

    TempNull = app.project.activeItem.layers.addNull ();

    .

    .

    .

    Use somehaw

    .

    .

    .

    TempNull.remove ();

    It will remove the object model

    But how the remove project (newly created element Null in folder "Solids")

    I want to keep the structure of the project the same as before the execution of the script.

    var comp = app.project.activeItem;
    var par = comp.pixelAspect;
    
    var layer = comp.selectedLayers[0];
    var rect = layer.sourceRectAtTime(0,false);
    var lpos = layer.position.value;
    var x = rect.left + rect.width/2+lpos[0];
    var y = rect.top + rect.height/2+lpos[1];
    
    app.beginUndoGroup("Centroid");
    
    center = comp.layers.addNull();
    center.name = "CENTROID";
    center.position.setValue([x, y]);
    
    var SceneScaleNull = comp.layers.addNull();
    var SceneScaleNullSource = SceneScaleNull.source; // grab null's source
    SceneScaleNull.name = "fixPAR";
    
    center.parent = SceneScaleNull;
    
    SceneScaleNull.property("Scale").setValue([100/par,100]);
    
    SceneScaleNull.remove();
    SceneScaleNullSource.remove(); // and remove it
    
    app.endUndoGroup();
    
  • How to remove unused objects from the webcatalogs?

    Hi friends,

    How to remove unused objects from the webcatalogs?
    is there a utility like the removal of unused objects of the physical layer in RPD?

    Thank you

    Hello

    Click link responses to the left of the answers click on the catalog button manage manage catalog, you can delete the unused objects

    Concerning

    NGO

  • How to remove the windows vista backup

    I have 2 drives, C: (69.2 GB) all system files. D: (65.7 GB) a backup & my data. I want to install a new s/w of 12 GB in D:, but its low memory(10.5MB) showing. I tried to delete the backup, but his does not work. I tried diskcleanup, but still the same problem persists. I checked, there isn't any extra file to D:. It's just because of the backup. Can someone please tell me, how to remove the full backup.

    Hi kisna234567,

    ·         You get the error message?

    The main objective of the Windows backup and Restore Center is to save the data either automatically in according to the schedule or manually when you want to save data. It is not designed to replace the old data with the new data. Just backup and Restore Center totals with new data every time, and would not remove the old files.

    You can backup the old files and folders to storage device as the external hard drive, CD, DVD, USB flash drives and removes the backup files of the computer. You can format the backup partition.

    Caution:

    ·         Formatting a volume will destroy all data on the partition. Be sure to make backups of all the data to save before you begin.

    ·         You cannot format a disk or partition that is currently in use, including the partition that contains Windows.

    ·         Quick format is a formatting option that creates a new file table, but do not completely overwrite or erase the volume. A quick format is much faster than a normal format, which fully erases the existing data on the volume.

    Follow these steps:

    (a) open computer management by clicking the Start button, select Control Panel, click system and Maintenance, click Administrative Toolsand then double-click computer management. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    (b) in the Navigation pane, under storage, click disk management.

    (c) right click on the volume that you want to format, and then click format.

    (d) to format the volume with the default settings, in the format dialog box, click OK, and then click OK again.

    For reference: create and format a hard disk partition.

  • Helps to remove the object


    I have a shape object on a slide of questionnaire I have to remove.

    • I can't click or right click on the object to remove.
    • I can't see the object in the Slide Master.
    • I don't have any special assigned circles that I can see.

    Any thoughts on how to access the object to remove it?

    Thanks in advance,

    A

    You can view previous slides, maybe it is programmed for the rest of the project?

  • How to remove the variable created when using definedNamedWhereClauseParam()

    Hello

    My Jdev version 11.1.1.7.0.

    I'm Executive where clause programatically where I need to bind two bind parameters under certain conditions. Example, I have two bind variables X, Y.

    Here's the problem:

    Assume that the first time I'm setting one variable X, so I define X bind variable and execute the query.

    What second time I send only Y but not X. In this implementation of the scenario of VO throw an exception, given that the variable X is already created in the VO object and where clause does not have this setting.

    So how to remove variables created in the original Version all in definedNamedWhereClauseParam(). I need to erase what ever the previously created variable every time I execute method.

    I can make the similar functionlity using setWhereClauseParam (using literals). But I have a few technical restrictions for use.

    Could you please help me how to remove the variable before vo using definedNamedWhereClauseParam.

    Caused by: java.sql.SQLException: try to set a parameter name that does not intervene in the SQL: itemNumber
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:15969)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObjectAtName(OraclePreparedStatementWrapper.java:911)
    at weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePreparedStatementWrapper.setObjectAtName (unknown Source)
    at oracle.jbo.server.OracleSQLBuilderImpl.bindParamValue(OracleSQLBuilderImpl.java:4669)
    at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3687)
    at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:22742)
    at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:1298)
    ... more than 96



    Thank you.

    -Diette.

    Published by: Vidya Diette on February 28, 2013 08:43

    Hello

    You need access to the variable Manager. Order of reading in the JavaDocs:

    http://docs.Oracle.com/CD/E28389_01/apirefs.1111/e10653/Oracle/JBO/ViewObject.html--> http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10653/oracle/jbo/VariableManagerOwnerBase.html#getVariableManager%28%29--> http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10653/oracle/jbo/VariableValueManager.html--> http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10653/oracle/jbo/VariableManager.html#removeVariable%28java.lang.String%29

    Frank

  • How to remove the watermark of Doc?

    How to remove the watermark of Doc?

    Hi fostexlaw,

    You can use the "Remove watermark" option in Acrobat to achieve this.

    The function "Remove watermark" only removes the watermarks that have been created by Acrobat. If the watermark is not an Acrobat one, you can simply remove the object of

    Select the object and delete it.

    Alternatively, you can try to save the file as a Word document, check if you can then enter and delete just the watermark, and then convert the file to PDF.

    Kind regards

    Rave

  • How to remove the Tables of HFM Application in SQL

    Hi gurus

    1. how to remove the HFM Application Tables in SQL?
    Its manual removal but each application having 120-150 tables? How to do this in one fell swoop?

    I deleted some applications using the workspace / shared services, but still its display under HFM under the Tables of SQL Server.

    Please help me

    concerning
    Smilee

    Hi Smilee,

    1. If the application opens in the web management interface, go to Taskflows management module and make sure that no taskflows exist yet for this application. Remove any existing taskflows.

    2. If demand exists in Shared Services, right-click on the demand for Shared Services and try to remove the application from here

    3. stop Hyperion Shared Services and all the Windows of financial management processes and backups of the relational database of the two patterns.

    4. check the relational database of Hyperion Shared Services repository, in the "ces_apps" table and make sure that there are no lines containing the appname "EXAMPLE." If the line still exists you should enlist the help of Oracle Global Support software to clean Hyperion Shared Services before proceeding.

    5. it is possible to remove all content removed from the relational database of financial management application. Must be very careful when handling manually tables database that permanent damage can be done at the application and other applications if the wrong content is removed.

    (a) first remove all tables, indexes, sequences, and the package objects that begin with the name of the application
    (b) remove all tables starting HSV_appname_xxxxxx
    (c) remove all rows in tables referring to demand HSX_CLUSTER_xxxxx.
    (d) delete all the HSV_ACTIVITY_KILL_USERS, HSV_ACTIVITY_NO_ACCESS, HSV_ACTIVITY_SESSIONS and HSV_ACTIVITY_USERS and HSV_USERS_ON_SYSTEM lines that refer to the name of the application.
    (d) remove the line containing the name of the application from the HSX_DATASOURCES table.

    6. the next time that all Hyperion services are restarted, the application must be removed safely from Windows client.

    You can contact your DBA to write a query on how to remove it.

    Hope this helps,

    Thank you
    Charles Babu J

  • RemovePopUp method removes the object from the display list?

    I'm setting up an AIR application that uses several pop-up windows, and I get as much memory as possible windows pop up closed at each Garbage Collection.  Reading through forums / Articles / documentation, I see instances of object created by pop ups stay in memory (No GC would be) up to:

    -all references to the object are = null (cancelled)

    -all receivers on the object are removed (or are weakly referenced)

    -l' object is removed from the display list.

    My question is:

    Does

    PopUpManager.removePopUp (this);

    remove the object from the display list?

    I use PopUpManager.createPopUp () to instantiate a container to display mx:TitleWindow objects.

    The pop-up closed deletion function, however, I'm not sure if it is 'removed from the display list' completely.

    A simple answer is the best, what moves me in the direction of answering the question. (Also useful: How can I see the objects in the display list at a certain point during execution of the application?)

    Thank you all!

    He,

    Yes, removePopUp removes it from the display list.

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • How to remove the permission of pc

    How to remove the permission of pc

    On the latest version of iTunes: account > permissions > Deauthorise This Computer (store > Deauthorise computer on older iTunes) on this computer: Deauthorize your computer using iTunes - Apple Support

Maybe you are looking for