New value of what? Can you provide a minimal example reproducing the problem?
New value of what? Can you provide a minimal example reproducing the problem?
what can you suggest me? I found out that because same .js is used for 2 different qml files, it doesn't work properly. Because in QT, it protect to same variables.
But, how can I do that? Because, one of qml files plays animation to make score, and second one shows the score. Can you imagine something?
----------
edit: I also found another same question on Internet, you may check it:
http://goo.gl/7dm7d
Last edited by Yonetici; 23rd July 2012 at 13:19.
I don't know what you are trying to do so it is hard to suggest a solution. How does your animation look like?
on my Animation1.qml: (import "total.js" as Logic)
Qt Code:
... onExited: { if(sRect.visible == true){ jet1.opacity = 0; rectJet.opacity = 0; jet1_1.visible = true; jet1_2.visible = true; jet1_sound.play(); if(jet1.opacity == 0){ Logic.mV = 5; // here is working but it can't change text of main.qml } } } ...To copy to clipboard, switch view to plain text mode
main.qml: (import "total.js" as Logic)
Qt Code:
... Text { id: total_txt text: Logic.totaltxt // here is working but it can't understand if or not Animation.qml changes the value anchors.topMargin: 2 anchors.leftMargin: 15 font.pixelSize: 50 color: "white" } Animation1 { id: animation1 anchors.bottom: parent.bottom anchors.left: parent.left anchors.bottomMargin: 10 anchors.leftMargin: Math.floor(Math.random()*600+20) } ...To copy to clipboard, switch view to plain text mode
total.js :
Qt Code:
.pragma library for(var i = 0; i<1; i++){ var totaltxt = 0; var mV; if(mV == 5){ totaltxt++; } }To copy to clipboard, switch view to plain text mode
I still don't understand what you are trying to do but I belive you approach the problem incorrectly. You're thinking in an imperative way rather than using the declarative engine at hand. If you want to animate the value of some label then you can do it this way:
javascript Code:
Text { property int value: 0 id: total_txt text: value // ... Behavior on value { NumberAnimation {} } }To copy to clipboard, switch view to plain text mode
And then elsewhere in your app:
javascript Code:
total_txt.value = 5To copy to clipboard, switch view to plain text mode
Thank you for feedback but it isn't actually what I need. Because I want to do that: when my animation plays, when onExit works, a value (mV = 5) will turn what I added and javascript code will give this value to mV in total.js ; then because javascript code works, (text: Logic.totaltxt) totaltxt will take 1 instead of 0 and we will see 1 on screen instead of 0.
I think that I can't tell what I mean because I'm new on qml
because if it works, it is very easy to applicate anywhere
The thing is it doesn't work And you are really not helping me solve your problem. The code you posted last time makes completely no sense and your explanation doesn't really explain what you are trying to do. Your "because if it works, it is very easy to applicate anywhere" also doesn't add anything to the subject. Please state what you are trying to achieve instead of trying to fix this nonsense code.
ok, I have a animation qml file, Anime.qml, and I added it to Main.qml as Anime { ...some code... }. In this Anime.qml, if mouse exit from mouse area (I did it with onExited{..some code...}), some opacity and visibilty change and they works well. However, I want to add a code for SCORE in onExited{...}, because I want to increase score +1, when onExited works.
This SCORE is in Main.qml like Text{... text = bla bla ...} , and normally it shows 0. I want that, if onExited condition ok in Anime.qml, this SCORE text in Main.qml should increase +1, and we see 1 instead of 0 on the screen.
Bookmarks