Problem in setproperty

Hello

I have a file test.qml and I am trying to change the text of a button and a label of CPP file using setProperty, I found the component using findChild but always setproperty does not

Help, please.

test.qml

import bb.cascades 1.0

Page {

    Container {
        objectName: "testContainer"
        Button {
            objectName: "myButton"
            text: "myButton"
            onClicked: {
                app.test1();

                }
        }

    }
}
applicationui.cpp

void ApplicationUI::test1()
{
    qDebug()<<"test1 called";

    QmlDocument *qml = QmlDocument::create("asset:///test.qml");
    //Container *c = qml->createRootObject();
    AbstractPane *root = qml->createRootObject();

    QObject *newContainer = root->findChild("testContainer");
    QObject *newButton = newContainer->findChild("myButton");

qDebug()<property("text");//Printing "myButton"

    if(newButton)
    {
        newButton->setProperty("text", "New button text");
        qDebug()<<"Button Found";
    }
    else
    {
        qDebug()<<"Button not found";
    }

    qDebug()<setProperty("text","my Button Text");qDebug()<property("text");//printing "my Button Text"

}

'Button Found' is getting printed in the console.

newButton-> setProperty ("text", "my button text") returns true.

The changes are producing, but are not visible on Simulator

Hello

Most likely, you create a second instance of QMLDocument and component root and modifying this second instance. The original remains unmodified. To refer to the original:

void ApplicationUI::test1()
{
    qDebug()<<"test1 called";

    AbstractPane *root = Application::instance()->scene();

    QObject *newContainer = root->findChild("testContainer");
    QObject *newButton = newContainer->findChild("myButton");
...

In addition, you can convert the result to the directly relevant classes:

Container *newContainer = root->findChild("testContainer");
Button *newButton = newContainer->findChild

findChild is recursive, so it is possible to search button without getting the container first:

Button *newButton = root->findChild

setProperty is rarely necessary. In most cases, it is best to use the methods of the corresponding class, such as setText to the button:

newButton->setText("text");

Tags: BlackBerry Developers

Similar Questions

  • Dynamic changes on qml page does not not via RPC

    Hello

    I want to change a user interface of the qml page dynamically according to the response from the web service of CPC file. If I make a few changes that I need to reload the page qml whenever changes are displayed. If I don't make these changes using JavaScript function so no need to reload the page. The changes are automatically displays on screen.

    How can I change the dynamic UI of the CPC file without reloading the qml file?

    Hello

    Are you sure you are not creating a second instance of the leaf? If you create and show the QML sheet, you will need to find the original instance in C++ code. This thread describes a similar problem:

    http://supportforums.BlackBerry.com/T5/native-development/problem-in-SetProperty/m-p/2611947#M49267

  • Storage VI SetProperty causes error - 2500 (internal error storage screws)

    Hello!

    As mentioned above the VI of Strorage Advanced "SetProperty" always results in the error Code - 2500 and I don't know why this is the case.

    I'm under LabView2013.

    I have already received a few messages about this error but they all problems within the LabView8.

    Attached is an example that should produce the error when running with the default values.

    Hello world

    I finally found the source of the problem: you can't name a property 'group '. If someone encounters this weird error sometimes, try another name of the property. In my view, the Error Message that appears is really poor in this case.

    Have a nice weekend

    Moritz

  • setProperty in pushed NavigationPane Page

    How to set the property on the page, which was pushed from NavigationPage?

    hand. QML

    import bb.cascades 1.0
    
    NavigationPane {
        id: navigationPane
        Button {
            text: qsTr("Game")
            onClicked: {
                navigationPane.push(gameDef.createObject())
            }
        }
        attachedObjects: [
            ComponentDefinition {
                id: gameDef
                source: "game.qml"
            }
        ]
    
        onPopTransitionEnded: {
            // Destroy the popped Page once the back transition has ended.
            page.destroy();
        }
    }
    

    Game.QML

    import bb.cascades 1.0
    
    Page {
        property int life: 40000
    
        //rest correct, not important
    }
    

    applicationui.cpp

    //fragment
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        qml->setContextProperty("app", this);
    
        // Create root object for the UI
        root = qml->createRootObject();
    
        root->setProperty("life", int(4));    //not work
    

    What to put in this CPC file, to change the ownership of life in the game.qml file?

    Thanks in advance

    I think you're going to struggle to write a full app so if you think it takes too much time.

    It's not a tip, it's a more condensed way to do what you already do part.

    If you do not do it this way it will NEVER work because THERE is NO such thing as the page that you want to access in applicationui.cpp.

    [Edit] I have also a problem with findChild as long as you understand its functionality and where and how to use it, then he has a purpose distinct and separate from the definition of property values.

  • Beginner problem Qt - signal clicked() button does not

    Hi guys,.

    I'm sorry to waste time of people with this problem, but it was my * beep * for a while and I really cannot proceed without assistance.

    Basically, I just try to hang a signal clicked() by a button. I've got the button instance, but the connect call returns false and the slot is not called when I click on the button.

    Here is the code:

    Class ApplicationUI: public QObject
    {
    Q_OBJECT
    public:
    ApplicationUI (bb::cascades:Application * app);
    Virtual ~ ApplicationUI() {}

    void GetButtonClickHandler();

    BB::Cascades:button * _getButton;
    };

    ==========

    ApplicationUI::ApplicationUI (bb::cascades:Application * app)
    : QObject (app)
    {
    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);
    AbstractPane * root = qml->() createRootObject;
    App-> setScene (root);

    _getButton = root->findChild ("getButton");
    Boolean result = QObject::connect (_getButton, SIGNAL (clicked ()), this, SLOT (GetButtonClickHandler ()));

    _getButton-> setProperty ("text", "Yes");
    }

    Sub ApplicationUI::GetButtonClickHandler()
    {
    _getButton-> setProperty ("text", "clicked");
    }

    ==========

    Default empty project template
    import bb.cascades 1.0

    {Page}
    {Of container

    Button {}
    objectName: "getButton.
    text: 'Get '.
    horizontalAlignment: P
    }
    }
    }

    Thank you very much!
    Paul

    Try adding:

    public slots:

    above this line:
    void GetButtonClickHandler();

    In addition, you can use the methods of the button directly, as
    _getButton-> SetText ("clicked")

    BTW, member variable is not really necessary. Slot sender() method can be used to access the button:

    void ApplicationUI::GetButtonClickHandler(){  Button *button = qobject_cast
  • Vodafone UK wav file download problem

    Hi all

    I have a request that download a WAV from my server and play. So far, it works well in the United States and other parts of the world. However, in the Vodafone UK network, anything that has been downloaded is a wav file of 'silence' with small sounds of background hiss. Any who encounter this problem and know how to work around?

    Thank you.

    RML

    I finally found the solution to this problem. So that the Vodafone UK server does not interfere with the HTTP traffic, I added the following to the HTTP header:

    1 requestHeaders.setProperty("User-Agent", "Blackberry");
    2 requestHeaders.setProperty("Cache-Control", "no-transform");

    I hope this information can help someone.

    RML

  • Problems with GPS signal/slot

    Hello

    I try to get GPS information for my application. I did a class to do so.

    #ifndef GPSHANDLER_H_
    #define GPSHANDLER_H_
    
    #include 
    
    #include 
    
    #include 
    #include 
    #include 
    
    using namespace QtMobilitySubset;
    
    class GPShandler : public QObject{
        Q_OBJECT
    public:
        GPShandler(QObject* parent);
        virtual ~GPShandler();
    private Q_SLOTS:
        void positionUpdatedSlot(const QGeoPositionInfo &geoInfo);
    
    public:
        void start();
    
        void stop();
    
        double Latitude();
    
        double Longitude();
    
    private:
        double mGeoInfoLat;
        double mGeoInfoLong;
        QGeoPositionInfoSource *mGeo;
    };
    #endif /* GPSHANDLER_H_ */
    
    #include "GPShandler.h"
    
    GPShandler::GPShandler(QObject* parent)
    : QObject(parent) {
        mGeoInfoLat = 0;
        mGeoInfoLong = 0;
        mGeo = QGeoPositionInfoSource::createDefaultSource(this);
        if (mGeo) {
            bool checkval = connect(mGeo, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
                    SLOT(positionUpdatedSlot(const QGeoPositionInfo &)));
    
            mGeo->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
            mGeo->setUpdateInterval(1000);
    
            //checkval = mGeo->setProperty("backgroundMode", true);
            //int i = 3;
        }
    }
    
    GPShandler::~GPShandler() {
        // TODO Auto-generated destructor stub
    }
    
    void GPShandler::positionUpdatedSlot(const QGeoPositionInfo &geoInfo) {
        // Here's where you can do something with the device's position
        mGeoInfoLat = geoInfo.coordinate().latitude();
        mGeoInfoLong = geoInfo.coordinate().longitude();
    }
    
    void GPShandler::start()
    {
        mGeo->startUpdates();
    }
    
    void GPShandler::stop()
    {
        mGeo->stopUpdates();
    }
    
    double GPShandler::Latitude()
    {
        return mGeoInfoLat;
    }
    
    double GPShandler::Longitude()
    {
        return mGeoInfoLong;
    }
    

    As you can see I have connected the signal postionUpdate() of QGeo class that I use for the positionUpdatedSlot() of the slot. I use the class as follows:

    Pop = new GPShandler (this);

    void::startTimer() {} App

    Pop-> start();

    }
    void::stopTimer() {} App

    Pop-> stop();

    }

    which are called when a key is pressed. However, the positionUpdatedSlot() of slot function is never called. I have debugged in my code and cannot find the problem. I can confirm the work of connection (function returns true), and that presented startup and shutdown functions are called as expected. Is there a reason why my slot machine function is not called?

    Note: I have another implementation of signal/slot in this app:

    Connect (mTimer, SIGNAL (timeout ()), this, SLOT (update ()));

    and it works very well.

    Thank you

    Gerry

    I do not know which of the following has solved my problem, but in any case, it's working now after doing these things:

    1. give permission to app to device identification information. (I had already given GPS, but examples also being device identifying information I thought I'd try that)

    2. remove the line:

           mGeo>setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
    

    as an example, I created using this example: http://blackberry.github.com/Cascades-Samples/geo-locationdiagnostics.html did not have this line

  • script event problems

    I try to get the following script as a startup script.

    the goal is that when the user chooses to save the document, they are presented with a dialog box asking for a brief summary of the changes that have been made. Then this info is written to the XMP fields.

    The basic functionality actually works, the dialog box and the data is saved in the XMP.

    The problem is that when the record action is undertaken an error dialog announcing "the requested operation was not successful because the object does exist more." and then the script proceeds and working properly, then it calls for entry and saves the data again.

    I get an error, then the script runs twice.

    I'm confused.

    #targetengine session

    myEventListener var = app.addEventListener ("beforeSave", myPromptForInput);

    function myPromptForInput (myEvent) {}

    var myTimeStamp = myEvent.timeStamp

    myDialog = app.dialogs.add var ({name: "enter a simple description of changes", canCancel:true}); "})

    {with (MyDialog)}

    Add a column of the dialog box.

    {with (dialogColumns.Add ())}

    Create a text edit field.

    var myTextEditField = textEditboxes.add ({editContents: "Changes in the Description of the document", minWidth:300});})

    Display the dialog box.

    Ditto var = myDialog.show ();

    if(myResult == true) {}

    Get the values of the dialog box controls.

    var myNotes = myTextEditField.editContents;

    Remove the memory dialog box.

    myDialog.destroy ();

    myAddXMPData (myNotes + "-" + myTimeStamp);

    Alert (MyEvent);

    }

    }

    }

    }

    function myAddXMPData (myNotes) {}

    myDocument var = app.documents.item (0);

    myDocument var = app.activeDocument;

    {with (myDocument.metadataPreferences)}

    author = 'James Haney';

    Description = myNotes;

    var myNewContainer = createContainerItem ("http://ns.adobe.com/xap/1.0/", "LCCRevisionNotes");

    setProperty ("'http://ns.adobe.com/xap/1.0/", "LCCRevisionNotes / * [1]", myNotes "" ");

    }

    }

    Hello

    I don't know if #targetengine and dialog UI work together.

    Try to use the Following window may be...

    I run it on my side. Looks like it works.

    #targetengine 'session'
    //just to remove if exists
    var old1 = app.eventListeners.itemByName("mXMP");
    if (old1.isValid) old1.remove();
    //
    var myEventListener = app.addEventListener("beforeSave", function (myEvent) {
      var myTimeStamp = myEvent.timeStamp;
      var myDialog = new Window("dialog", "Enter a simple description of edits made", undefined, {closeButton: false});
      var myStatText = myDialog.add("statictext", undefined, "Description of document changes: ");
      var myEditText = myDialog.add("edittext", undefined, "");
      var myButtons = myDialog.add("group");
      myButtons.add("button", undefined, "OK", {name:"OK"});
      myButtons.add("button", undefined, "Cancel", {name:"Cancel"});
    
      myEditText.characters = 45;
      myStatText.alignment = "left";
    
      //Display the dialog box.
      var myResult = myDialog.show();
      if(myResult == true){
      //Get the values from the dialog box controls.
      var myNotes = myEditText.text;
      myAddXMPData(myNotes + " - " + myTimeStamp);
      //~ //alert(myEvent);
      }
    }).name = "mXMP";
    

    Including your myAddXMPData() function of course.

    Jarek

  • AF:panelTabbed - problem with displaying a popup on tab switching

    Hello

    I am facing a problem with disclosureEvent using clientListener of handling. I'm going to show a popup Ok/cancel whenever a user leaves a tab in panelTabbed.


    Here's the code: (this is the same code provided on the Oracle ADF code corner)

    < af:resource type = "javascript" >

    function alertTabSwitch (disclosureEvent) {}

    tab var = disclosureEvent.getSource ();

    {if (Tab.getDisclosed () == false)}

    popup var = tab.findComponent ('p1');

    Popup.Show ();

    popup.setProperty ("tabToOpen", tab.

    disclosureEvent.cancel ();

    }

    }

    function handlePopupOkCancel (actionEvent) {}

    popupButton var = actionEvent.getSource ();

    var butPressed = popupButton.getProperty ('popupAction');

    var = popupButton.getParent () dialog box;

    popup var = dialog.getParent ();

    If (butPressed == 'OK') {}

    var tabToFindAndFocusOnString = popup.getProperty ("tabToOpen");

    If (tabToFindAndFocusOnString.length > 0) {}

    var tab = AdfPage.PAGE.findComponentByAbsoluteId (tabToFindAndFocusOnString);

    tab.setDisclosed (true);

    actionEvent.cancel ();

    Popup.Hide ();

    }

    }

    else {}

    Close the pop-up window and stay on the page

    actionEvent.cancel ();

    Popup.Hide ();

    }

    }

    < / af:resource >

    < af:panelStretchLayout id = "PSL1" >

    < f: facet name = "center" >

    < af:panelTabbed id = "pt1" >

    < af:showDetailItem text = 'TAB 1' id = 'sdi1"disclosed ="true"stretchChildren ="first ".

    clientComponent = "false" >

    First tab

    < af:clientListener method = "alertTabSwitch" type = "Disclosure" / >

    < / af:showDetailItem >

    < af:showDetailItem text = 'TAB 2' id = 'sdi2' stretchChildren = 'first' clientComponent = "false" >

    Second tab

    < af:clientListener method = "alertTabSwitch" type = "Disclosure" / >

    < / af:showDetailItem >

    < / af:panelTabbed >

    <!-id = "af_one_column_stretched"->

    < / f: facet >

    < f: facet = 'Start' name >

    < af:popup = "deferred" autoCancel childCreation = "disabled" id = 'p1' clientComponent = 'true '.

    contentDelivery = "immediate" >

    < af:dialog id = "d1" title = "Tab switch Alert" type 'none' = >

    < f: facet name = "buttonBar" >

    < af:panelGroupLayout id = "g1" >

    < af:commandButton text = "OK" id = "cb1" partialSubmit = "true" >

    < name af:clientAttribute = "popupAction" value = "OK" / >

    < af:clientListener method = "handlePopupOkCancel" type = "action" / >

    < / af:commandButton >

    < af:commandButton text = 'CANCEL' id = "cb2" partialSubmit = "true" >

    < name af:clientAttribute = "popupAction" value = "CANCEL" / >

    < af:clientListener method = "handlePopupOkCancel" type = "action" / >

    < / af:commandButton >

    < / af:panelGroupLayout >

    < / f: facet >

    < af:outputText value = "Do you really want to switch tabs?" id = "ot1.

    inlineStyle = "do-size: medium;" Color: Red; "/ >

    < / af:dialog >

    < name af:clientAttribute = "tabToOpen" value = "" / >

    < / af:popup >

    < / f: facet >

    < / af:panelStretchLayout >

    Everything is done on the client side. When I click on a tab, first the "Unselect" event is fired for the selected tab and the value disclosed in this tab becomes false. After the value is changed, the listener is called.

    So in javascript, the same tab is released again after clicking OK.

    The value was not changed before calling the af: clientListener, this problem would not have arisen.


    Can someone help me with this?


    Kind regards

    Frédéric

    Change the as follows:

    The following has been tested against JDeveloper 11.1.1.7

    
    
        var theTabToClose;
        var theTabToOpen;
        function alertTabSwitch(disclosureEvent){
            var tab = disclosureEvent.getSource();   //This is the tab to close
            if(tab.getDisclosed()==false){
               theTabToClose = tab;
               theTabToOpen = disclosureEvent.getDisclosureCounterpart();
               var popup = tab.findComponent('p1');
               disclosureEvent.cancel();
               popup.show();
            }
        }
    
        function handlePopupOkCancel(actionEvent){
            var popupButton = actionEvent.getSource();
            var butPressed = popupButton.getProperty('popupAction');
            var dialog = popupButton.getParent();
            var popup  = dialog.getParent();
    
            if(butPressed == 'OK'){
                theTabToOpen.setDisclosed(true);
            }else{
                theTabToClose.setDisclosed(true);
            }
                actionEvent.cancel();
                popup.hide();
        }
        
    
  • Noob-nooby problem. Do not use stop(); but I want film to continue playing scene 1.

    Hello once more!

    I have this film I made when the user switches between 3 scenes. stage 1 is the main scene more or less. I want to stay in scene 1 of the sequence. Correct me if im wrong, but if I do not put stop(); in code, the film switches to scene 2 (as scene1 is only 1 frame per layer.). This creates a problem since I have stuff on my stage 1 I can't stop, otherwise they lose their point of aim. I have the following on this scene:

    Clock which will accordingly at the same time. with this script in this topic:

    time = new Date();

    seconds = time.getSeconds)

    minutes = time.getMinutes)

    hours = time.getHours)

    hours = hours + (minutes/60);

    seconds = seconds * 6;

    minutes = minutes * 6;

    hours = hours * 30;

    SEK._rotation = seconds;

    min._rotation = minutes;

    Tim._rotation = hours;

    Eyes that follow the mouse cursor:

    a = eye1._y - _ymouse;

    b = eye1._x - _xmouse;

    Alicia = Math.atan2 (a, b);

    degrees = angleA/(Math.PI/180);

    setProperty ("eye1", _rotation, degrees);

    A2 = eye2._y - _ymouse;

    B2 = eye2._x - _xmouse;

    angleA2 = Math.atan2 (a2, b2);

    degrees2 = angleA2/(Math.PI/180);

    setProperty ("eye2", _rotation, degrees2);

    and a piece of music. But this isn't the problem.

    Maybe there's an easy solution for this?

    When you say "like"scene1 is only 1 frame per layer." I can only interpret wrongly you have only an image of the scene.

    If you have several frames and want continuous looping through of scene 1, then put a gotoAndPlay (1) in the last frame of scene 1.

    If this is still not what you're after, you should show a screenshot of yout timeline and add any explanatory notes to it which could help to explain what you want.

  • help - problem with a function

    There's a good scenario Kasyan here he prepared for one of my tasks / a special workflow:

    Imagine that you have a document with a hundred pages and all pages contain an image and a text box with individual photo credit / description.

    The script is paste each image text box in the description of the images via the bridge - great, fast xmp and I have never seen anything like this elsewhere

    Now, there's a problem: the script removes all forms of breakts hard/new line the credit, but I need sometimes.

    I'd like to get rid of the ReturnWithSpace function, but it seems that it is a bit more complex.

    Here is the complex function...

    function ReplaceReturnWithSpace (myString) {}
    myString = myString.replace (/ \n/g, "");
    myString = myString.replace (/ \r/g, "");
    return myString;
    }

    Here's the complete script - maybe someone can help you:

    indesign #target

    myDoc var = app.activeDocument;
    mySelection var = app.selection;

    If (mySelection.length == 0) {}
    ProcessPages();
    }
    Else if (mySelection.length == 1) {}
    Alert ("a picture and a textframe must be selected.");
    Exit();
    }
    Else if (mySelection.length == 2) {}
    try {}
    If (. constructor.name mySelection [0] == 'TextFrame' & &. images.length mySelection [1] == 1) {}
    var myTextFrame = mySelection [0];
    var myImage = .images mySelection [1] [0];
    var myCaption = ReplaceReturnWithSpace (myTextFrame.contents);
    var myPath is new file (myImage.itemLink.filePath) .absoluteURI;.
    }
    ElseIf (. constructor.name mySelection [1] == 'TextFrame' & &. images.length mySelection [0] == 1) {}
    var myTextFrame = mySelection [1];
    var myImage = mySelection .images [0] [0];
    var myCaption = ReplaceReturnWithSpace (myTextFrame.contents);
    var myPath is new file (myImage.itemLink.filePath) .absoluteURI;.
    }
    }
    {catch (e)}
    Alert ("something wrong with your selection. ("\nError:" + e.message);
    Exit();
    }

    CreateBridgeTalkMessage (myCaption, myPath);
    }
    ElseIf (mySelection.length > 2) {}
    Alert ("a picture and a textframe must be selected.");
    Exit();
    }

    UpdateAllOutdatedLinks();
    myDoc.save ();
    Alert ("All done.");

    //+++++++++++++++++++ FUNCTIONS ++++++++++++++++++++++

    function CreateBridgeTalkMessage (myCaption, myPath) {}
    var bt = new BridgeTalk();
    BT. Target = "bridge."
    var myScript = WriteCaption.toString () + "\r";
    myScript += ' WriteCaption (\ "" + myCaption + ' \ ", \"' myPath + "\"); ";
    BT. Body = myScript;
    BT. Send();
    }

    function WriteCaption (myCaption, myPath) {}
    If (xmpLib == undefined) {}
    If (Folder.fs == "Windows") {}
    var pathToLib = "/ C/Program Files/Adobe/Adobe Bridge CS3/AdobeXMPScript.dll";
    }
    else {}
    var pathToLib = "/ Applications/Adobe Bridge CS3/Bridge CS3.app/Contents/MacOS/AdobeXMPScript.framework";
    }
    libfile var = new file (pathToLib);
    var xmpLib = new ExternalObject ("lib:" + pathToLib);
    }
    var thumb = new thumbnail (file (myPath));

    If {(thumb.hasMetadata)
    var md = thumb.synchronousMetadata;
    var = new XMPMeta XMP (md.serialize ());
    xmp.deleteProperty (XMPConst.NS_XMP, "Description");
    xmp.setProperty (XMPConst.NS_XMP, "Description", myCaption);
    var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER |) XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
    Thumb.Metadata = new Metadata (updatedPacket);
    }
    }

    function ProcessPages() {}
    myPages var = myDoc.pages;
    for (i = 0; i < myPages.length; i ++) {}
    var myPage = myPages [i];
    If (myPage.textFrames.length == 1 & & myPage.rectangles.length == 1) {}
    If (myPage.rectangles [0].graphics.length == 1) {}
    var a = myPage.rectangles [0];
    var myImage = myPage.rectangles [0] .graphics [0];
    var myPath is new file (myImage.itemLink.filePath) .absoluteURI;.
    var myTextFrame = myPage.textFrames [0];
    var myCaption = ReplaceReturnWithSpace (myTextFrame.contents);
    CreateBridgeTalkMessage (myCaption, myPath);
    }
    }
    }
    }

    function ReplaceReturnWithSpace (myString) {}
    myString = myString.replace (/ \n/g, "");
    myString = myString.replace (/ \r/g, "");
    return myString;
    }

    function UpdateAllOutdatedLinks() {}
    for (var myCounter = myDoc.links.length - 1; myCounter > = 0; myCounter-) {}
    myLink var = myDoc.links [myCounter];
    If (myLink.status == LinkStatus.linkOutOfDate) {}
    myLink.update ();
    }
    }
    }

    If I can make a comment, the XMPScript API is separate from the bridge DOM, if your script could avoid to call bridge.

    InDesign is able to load the required library - new ExternalObject('lib:AdobeXMPScript') - and to deal directly with the XMP data.

    Then we can really simplify the code. Try this:

    TextFrame.prototype.getCaption = function()
    // Here you can customize the caption written in XMP
    {
    // old behavior :
    // return this.contents.replace( /[\n\r]/g , " " );
    
    // contents as it (keeping newlines) :
    return this.contents;
    }
    
    Document.prototype.getScope = function()
    { // return the array of {txf,img} objects to process
    var scope = [], pages = this.pages;
    for ( var pg, p = pages.length-1 ; p >= 0 ; p-- )
         {
        pg = pages[p];
         if ( pg.textFrames.length != 1 ) continue;
         if ( pg.rectangles.length != 1 ) continue;
         if ( pg.rectangles[0].images.length != 1 ) continue;
         scope.push({txf: pg.textFrames[0],img: pg.rectangles[0].images[0]});
        }
    return(scope);
    }
    
    Application.prototype.main = function()
    {
    if ( this.documents.length<=0 )
         {alert("Think to open a document!");return;}
    
    var scope, sel = this.selection;
    switch(sel.length)
         {
         case 0 :
              scope = this.activeDocument.getScope();
              break;
         case 2 :
              scope = ( function()
                   {
                   var t = (sel[0].constructor == TextFrame) ? 0 :
                        ( (sel[1].constructor == TextFrame) ? 1 : false );
                   if (t===false) return(null);
                   if ( sel[1-t].images.length != 1 ) return(null);
                   return [{txf: sel[t], img: sel[1-t].images[0]}];
                   } )();
              if (scope) break;
         default :
              alert("One image and one textframe should be selected.");
              return;
         }
    
    if (ExternalObject.AdobeXMPScript == undefined)
         {
         try {ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');}
         catch(ex) {alert("Unable to load the AdobeXMPScript library"); return;}
         };
    
    var txfImg, iLink, iFile, xmpFile, xmp;
    var err=0, cpt=0;
    while (txfImg=scope.pop())
         {
         iLink = txfImg.img.itemLink;
         try {iFile = new File(iLink.filePath);}
         catch(ex) {err++;continue;}
    
         xmpFile = new XMPFile(iFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
    
         xmp = xmpFile.getXMP();
         xmp.deleteProperty(XMPConst.NS_XMP, "Description");
         xmp.setProperty(XMPConst.NS_XMP, "Description", txfImg.txf.getCaption());
    
         if (xmpFile.canPutXMP(xmp)) { xmpFile.putXMP(xmp); cpt++;} else err++;
         xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
    
         if (iLink.status == LinkStatus.linkOutOfDate) iLink.update();
         }
    
    alert(''+cpt+" image descriptions updated -- "+err+" errors.");
    
    try{this.activeDocument.save();}
    catch(ex){}
    }
    
    app.main();
    
  • Drag &amp; Snap Puzzle new problem

    I have re-tooled a flash drag and snap game puzzle, so rather than use dragable buttons, I now video clips which snap into place.  This part works... My problem is that when all the pieces are in place, a message should pop up and say "Bravo!" in an area of dynamic text with a name istance of 'message '.  This part does not work.  I got the great insight of this forum so if someone could look at the code below and show me how to fix the problem I would owe.  The code is all about an image in the main time line and there are 8 pieces of the puzzle:

    piece1.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece1.StartDrag ();
    }
    piece1.onRelease = function() {}
    piece1.stopDrag ();
    If (piece1._x > 321 & & piece1._x < 371 & & piece1._y > 164 & & piece1._y < 214)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece1", _x, "346,6")
    setProperty ("piece1", FLF, "189,8")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }


    piece2.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece2.StartDrag ();
    }
    piece2.onRelease = function() {}
    piece2.stopDrag ();
    If (piece2._x > 243 & & piece2._x < 293 & & piece2._y > 121 & & piece2._y < 171)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("exhibit2", _x, "268,2")
    setProperty ("exhibit2", FLF, "146.9")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece3.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece3.StartDrag ();
    }
    piece3.onRelease = function() {}
    piece3.stopDrag ();
    If (piece3._x > 202 & & piece3._x < 252 & & piece3._y > 84 & & piece3._y < 134)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece3", _x, "227.3")
    setProperty ("piece3", FLF, "109.2")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece4.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece4.StartDrag ();
    }
    piece4.onRelease = function() {}
    piece4.stopDrag ();
    If (piece4._x > 295 & & piece3._x < 345 & & piece4._y > 76 & & piece3._y < 149)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece4", _x, "320,9")
    setProperty ("piece4", FLF, "101.8")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece5.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece5.StartDrag ();
    }
    piece5.onRelease = function() {}
    piece5.stopDrag ();
    If (piece5._x > 392 & & piece5._x < 442 & & piece5._y > 148 & & piece5._y < 198)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece5", _x, "417.1")
    setProperty ("piece5", FLF, "173,4")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece6.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece6.StartDrag ();
    }
    piece6.onRelease = function() {}
    piece6.stopDrag ();
    If (piece6._x > 347 & & piece6._x < 397 & & piece6._y > 45 & & piece6._y < 95)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece6", _x, "372.3")
    setProperty ("piece6", FLF, "70.8")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece7.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece7.StartDrag ();
    }
    piece7.onRelease = function() {}
    piece7.stopDrag ();
    If (piece7._x > 260 & & piece7._x < 310 & & piece7._y > 33 & & piece7._y < 83)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece7", _x, "285.7")
    setProperty ("piece7", FLF, "58.4")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    piece8.onPress = function() {}
    this.swapDepths (this._parent.getNextHighestDepth ());
    piece8.StartDrag ();
    }
    piece8.onRelease = function() {}
    piece8.stopDrag ();
    If (piece8._x > 431 & & piece8._x < 481 & & piece8._y > 106 & & piece8._y < 156)
    If the pieces of the puzzle lies within the limits of the puzzle and then snap!
    {
    {if(!this.Completed)}
    _root.completedPuzzleCheck (); Add this to each of your pieces
    This.Completed = true;
    }

    setProperty ("piece8", _x, "456,4")
    setProperty ("piece8", FLF, "131,4")

    } else {}
    {if (this.Completed)}
    This.Completed = false;
    -_root.numCompleted;
    }
    }
    }

    {if(!numCompleted)}
    numCompleted = 1;
    } else {}
    numCompleted ++;
    }
    {if(numCompleted==8)}
    message. Text = "Great Job! « ;
    }

    Stop();

    I didn't have all the details, but the piece of the puzzle that seems to be missing includes these lines:

    {if(!numCompleted)}
    numCompleted = 1;
    } else {}
    numCompleted ++;
    }
    {if(numCompleted==8)}
    message. Text = "Great Job! « ;
    }

    They will run only once at the beginning of the film.  So I wonder if they really are, which belongs to the missing piece... completedPuzzleCheck

    function completedPuzzleCheck() {}

    {if(!numCompleted)}
    numCompleted = 1;
    } else {}
    numCompleted ++;
    }
    {if(numCompleted==8)}
    message. Text = "Great Job! « ;
    }

    }

  • problem with the transition and external image

    Hello! I have a little trouble with the transition to a new state that contains an external image. I want a titlewindow to resize when the user clicks on a button and view an external image. the size of the external image is unknown until it is loaded, so I put the widths/heights to 100%. However, the transition "resize" does not know the size of the image in time and comes alive in a small rectangle...

    I discovered how to solve this problem by deleting the passage and making the invisible titlewindow until the image is loaded (using the event 'complete'). Ideally, I would like to use the functionality of transition, however and am curious to know if anyone has any ideas on this point - perhaps triggering the resizing to start once the image is loaded? I can only find a way to display a transition through mxml - this can be achieved via actionscript?

    When you use States and there is a tag This means that the child will be added to the display list. The object already exists (a new operation has been made about it). It may not be in a fully realized State first because it has not been added to the display list and therefore his complete cycle of creating the Flex framework has not been executed.

    I haven't run the scenario I propose, so it might actually not, but I have another suggestion below.

    You should be able to have in the State that when you are ready to load the image, img.source = url; should not give you an error. The question is, without the image being added to the display list, try even to load image from url and trigger the complete event? If it does not trigger the complete event, then you can change the States there.

    My alternative is to not put the Image in the State, but leave it in your state of base with a width and a height of zero. Having the button set the source property of the image (or call the load() method). When the complete event triggers switch States.

    In your , instead of having an AddChild, you'll SetProperty. Something like this (width, height would be similar):

    Now, the transition must simply use the effect of .

  • setProperty alternative?

    OK here is the deal... I have some old code that worked in as2 and im trying to make it work in as3. I think that I've solved all the problems with (I think), but im am confused on how to bypass the setProperty part. button instance is oney, and MC instance's box. Here's the code...


    code for button and say the clip to go
    function mouseDownHandler(event:MouseEvent):void {}
    box.targXmove = 151.1;
    box.targYmove = 151.1;
    }
    oney.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler);

    code to make it move
    function Poopey (event): void {}
    var cXmove = box.x;
    var cYmove = box.y;
    var difXmove = cXmove - box.targXmove;
    var difYmove = cYmove - box.targYmove;
    setProperty (this, x, cXmove-(difXmove/5));
    setProperty (this, there, cYmove-(difYmove/5));
    }
    box.addEventListener (event. ENTER_FRAME, Poopey);


    any suggestions? (please do not change from AS2, I already know that works)

    crila5000,

    > im am stumped on how to bypass the setProperty part.

    setProperty() is older than the hills. It is just a precursor of the dot
    Notation, you already use. ;)

    For example, this...

    box.targXmove = 151.1;

    ... is an example of dot notation. You set the targXmove property of
    This box to 151.1 clip. It's the same as saying that...

    setProperty (box, targXmove, 151);

    ... only clunkier.

    To edit a line like this...

    setProperty (this, x, cXmove-(difXmove/5));

    ... you make it like this:

    This.x = cXmove-(difXmove/5);

    David Stiller
    Adobe Community Expert
    Dev blog, http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Custom problem with scrollbar in kifani

    Hi, I have a class that extends kifani. This class displays a JEditorPane inside a get for simple HTML display (I have try it with text, the problem persists).

    The problem is that, so I put a date in the JEditorPane and the scollbars are visible, they are positioned at the end of the 'view '! I try to reproduce the problem with a simple swing application, but it works.

    Any idea?

    PS: I'm using Jinitiator 1.3.1.25

    Here is the code:
    package ch.ceg.ecoles.forms.pjc;
    
    import java.awt.Rectangle;
    
    import javax.swing.JEditorPane;
    import javax.swing.JScrollPane;
    
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    
    public class HtmlFrame extends VBean {
    
         private static final long serialVersionUID = 1L;
         // property to set the content
         public final static ID pSetContent = ID.registerProperty("SETCONTENT");
         // private variables
         private JEditorPane htmlPane;
         private String content;
    
         public HtmlFrame() {
              super();
    
              htmlPane = new JEditorPane("text/text", "Chargement en cours...");
    
              htmlPane.setEditable(false);
              JScrollPane scrollPane = new JScrollPane(htmlPane);
              add(scrollPane);
         }
    
         public boolean setProperty(ID pId, Object pValue) {
    
              if (pId == pSetContent) // set and display the new URL
              {
                   String sValue = (String) pValue;
                   content = sValue;
                   htmlPane.setText(content);
                   
                   htmlPane.scrollRectToVisible(new Rectangle(0,0,1,1));
                   System.out.println("après le scroll");
    
                   return true;
              } else {
                   return super.setProperty(pId, pValue);
              }
         }
    }

    Use:

    htmlPane.setCaretPosition(1);
    

    Instead of

    htmlPane.scrollRectToVisible(new Rectangle(0,0,1,1));
    

    François

Maybe you are looking for

  • Reinstallation of win7

    I have xps l502x, out of warranty, and I reinstall win 7. He ask drivers, but it doesn't accept my CD "drivers and utilities". When I insert the cd and reboot I get the message "No operating system..." ». Load the drivers before you install the opera

  • My printer is leaving stains

    My printer is leaving traces so that I do not see what is supposed to have been printed

  • Hora del reloj

    Why cada vez as desconecto mi PC prenderlo al be desactualiza date y hora? MUCHAS gracias

  • I continue to disconnect from my wireless network.

    When I try to WiFi (wireless) my computer keeps me blow... How can I fix? Original title: when I try to Wfi I keep get started off... can only get the internet.by Ethernet cable

  • Catalogue Lightroom can't see files

    My CC lightroom cannot see more than 1000 files in a specific subdirectory with more than 2000 files it contains. The files are there when you look at them with explore. Other files are there and are seen by the CCRB. When I try to synchronize LR sai