Another 'Cannot mutate bound sequence' Question

Hi Everyone,
The below code throws a "Cannot mutate bound sequence" when the line (id:'a') is pressed first. However it runs fine when lines 'b' or 'c' are pressed first. But the output shows the correct line 'a' has been deleted when pressed first. Can anyone suggest a way around this or shed some light on what is happening?
Im still new to javafx and have been reading up on 'bind'. It looks like there are a few known issues out there so hopefully this is one and there is a easy fix.
package bindingerror;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.shape.Line;
class Wall extends Line{
     override var onMousePressed = function(e):Void {
            println(WallArray);
            delete e.node as Wall from WallArray;
            println(WallArray);
var WallArray = [
                Wall{id:'a' startX: 10 startY: 20 endX: 90 endY: 20 strokeWidth:10}
                Wall{id:'b' startX: 10 startY: 50 endX: 90 endY: 50 strokeWidth:10}
                Wall{id:'c' startX: 10 startY: 80 endX: 90 endY: 80 strokeWidth:10}
var Group = Group{content: bind for(x in [0..(sizeof WallArray - 1)]) {WallArray[x]}};
Stage {
        scene: Scene {
                   width:   100
                   height:  100
                   content: Group{content: bind Group
                                 }//Group
                      }//Scene
}//Stage

No wonder. Has you have seen yourself, binding is a delicate domain, particularly when used with a sequence and/or a function. That's why I won't answer your question but instead criticize your code... :-) No, seriously, I will try and answer (but the inconsistent behavior is still a bit puzzling), if I can, but since you say you are new to JavaFX, I think some remarks can be beneficial as well.
Generic remark: I am not known to follow blindly the Sun Java coding rules (I have my own internal set of rules I apply across languages, when possible), but I still think using a capital initial for class names, and a lowercase initial for variable names is a useful convention. Particularly when you name a variable the same as a built in class name... The compiler sorts things out, but the reader is confused... :-)
Other remark: I don't know if you come from the Java world. Knowing Java to do JavaFX isn't mandatory, but useful, since JavaFX routinely uses Java classes. I suppose most JavaFX coders have at least some Java background.
That said, I am surprised to see so many newbies to JavaFX using the old Java way of iterating over a sequence, by index.
Let's show a more idiomatic JavaFX. First, you can rewrite your loop as:
for (x in [0 ..< sizeof WallArray]) WallArray[x];The ..< sequence notation is often overlooked/forgotten, I find it more readable than using -1.
It can still be written:
for (w in WallArray) w;But you create a new sequence, why not just use the original one?
var Group = Group { content: bind WallArray };Ah, I magically dispelled the error message! But I modify WallArray, I don't know if that's the intended behavior. Ah, yes, since the mouse pressed function delete items from WallArray. The problem might lie there: I think the Group reference items in WallArray, and you delete items there, so its references hangs out in the void. Or something like that...
Last remark: unless you are simulating something more complex, you don't need to put a group in a group.
So, here is my version of your code:
class Wall extends Line {
     override var onMousePressed = function (e: MouseEvent): Void {
        print(walls); print(" => ");
        delete e.node as Wall from walls;
        println(walls);
var walls = [
    Wall { id:'a' startX: 10 startY: 20 endX: 90 endY: 20 strokeWidth: 10 }
    Wall { id:'b' startX: 10 startY: 50 endX: 90 endY: 50 strokeWidth: 10 }
    Wall { id:'c' startX: 10 startY: 80 endX: 90 endY: 80 strokeWidth: 10 }
//~ var Group = Group { content: bind walls };
Stage {
    scene: Scene {
        width:   100
        height:  100
        content: bind walls
    }//Scene
}//Stage

Similar Messages

  • Responses showing over feedback in sequence question - Captivate 5

    Hi all
    I have an issue with the sequence question type. If you have feedback, the draggable responses show over the top.  Please see grab.
    Is this a bug? I can't find any mention of it. It only seems to do it with certain responses. Makes it completely unusable.
    Suggestions?
    Mitch

    This tends to happen if you add answer options AFTER creating the question and adding the feedback captions.  The last thing added ends up on the upper layers of the quiz question slide, but since you cannot see these layers in the timeline, as you can for other slides, you cannot reorder the layers by normal means.
    The solution is to turn your feedback captions off and then on again so that they then end up on the higher layers again.
    Go to Quiz Properties for this slide and deselect/select the Correct and Incomplete captions to put them above the answer options.  Then set Failure level to NONE and back to whatever it was before to set the Failure caption above everything else.  This will erase any text you had in the captions, so if you've invested quite a lot of time adding text to these feedback captions, it's a good idea to copy that text somewhere else first, so that you can just paste it back in after recycling them.

  • Sequence Questions Merging

    Hi
    I recently created an assessment on Captivate 3, which
    includes a number of sequence questions, the problem that I have is
    that the answers for the sequence questions are moving between
    questions and therefore people are answering it wrong as not all of
    the correct options are available.
    Any ideas on how to resolve this??
    Thanks

    Try separating the "Sequence" questions from one another with
    a different type of questions, i.e.
    1. sequence
    2. t/f
    3. sequence
    4. mult choice
    5. sequence
    This is definitely a bug, i've seen the same thing. --Bob

  • HT5312 I forgot my security question and my rescue email are the same as Apple ID so cannot reset my security question. Any advice on how to reset m security or add a rescue email ? Thanks

    I forgot my security question and my rescue email are the same as Apple ID so cannot reset my security question. Any advice on how to reset m security or add a rescue email ? Thanks

    If you don't have a rescue email address then you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can use the steps half-way down the HT5312 page that you posted from to add a rescue email address for potential future use

  • I have two apple ID's but cannot remember the security question answers and the email address is no longer active - how can I access this account

    I have two apple ID's but cannot remember the security question answers and the email address is no longer active - how can I access this account as it seems to be the one my icloud space is attached to.  I haven't backed up my ipad or photos for a while. 

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312
    If you don’t know your security questions, phone Apple (using the number listed here:  http://support.apple.com/kb/HE57  ) and ask for the Account Security Team.
    About 2-step verification of your Apple ID:
    http://support.apple.com/kb/ht5570
    This is also useful:
    http://www.macworld.co.uk/ipad-iphone/news/?newsid=3463233&olo=email

  • Apple ID issue - Cannot modify a standard question

    I cannot order books/prints from iPhoto as I have been unable to set up my Apple ID account in iPhoto. I have tracked the problem down to the fact that I am unable to update my profile password question/answer. I have tried to do this via myinfo.apple.com and the apple store account settings, and I get the following error:
    Cannot modify a standard question
    Earlier this year, this message was accompanied by the error number -20148.
    Has anyone else had this problem?
    I have spent over 10 hours on the phone with Apple Care and they have been unable (unwilling) to help fix this problem (which seems to be that the Apple ID database is corrupt).
    Also, has anyone else experienced being brushed off by Apple Care with a problem they were unable to solve?

    If all else fails can you just create a new account? You may be thwarted by your email address however as that's usually part of the account info that Apple looks at for duplication. it's worth a try however. If you have a .Mac account you could create an alias email name and use it.
    OT

  • I would like to send an e-mail to apple saying that i cannot remember my security questions's answers

    I would like to send an e-mail to apple saying that i cannot remember my security questions's answers. i just wanted to buy James Arthur's album to put on my sisters ipod and i could not remember the security questions's answers

    Unless you plan to have multiple email accounts open in different tabs at the same time, there is no need for Multifox. If each user has their own [[profiles|profile]], then the Multifox extension will not be required. If you want to open multiple email accounts at the same time in one instance of Firefox then you will need Multifox.

  • I have to create a new iTunes account as I cannot remember the security question answers to my current account, how do I move over my purchases from my current account to my new account?

    I have to create a new iTunes account as I cannot remember the security question answers to my current account, how do I move over my purchases from my current account to my new account?

    fayry wrote:
    ... how do I move over my purchases from my current account to my new account?
    This is not possible...
    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID.
    Apple ID FAQs  >  http://support.apple.com/kb/HE37

  • Cannot get link for contact to work.  Rescue email address is no longer valid and I cannot remember my security questions to update it

    I cannot make any more iTunes or Apps purchases because I cannot remember my security questions.  I have read online that you cannot update rescue email address (mine is no longer valid) until you answer the security questions.  I have clicked on the link for support on account management but it never opens.  I am very upset because all I am needing to do is make purchases.  Any ideas or numbers or actual links you can post in response is appreciated.

    Click here and find the phone number for your country.
    (78231)

  • Fill In The Blank / Sequence Questions

    Is it possible to have a fill in the blank question in captivate (4 or 5) that is scored according to how many options the user got correct?
    For example:
    If you use 4 grams of 'b' you will need _____ grams of 'x', _____ grams of 'y' and ____ grams of 'z' to complete the forumula.
    In this example if they answered all 3 blanks correctly they would get 3 points, 2 correct answers would give them 2 points and so on.
    Also, is it possible to  score sequence questions according to how many items were correctly sequenced?

    Hello,
    For the moment partial scoring (as I'm calling it) is not possible in Captivate, at least not in the included Question slides. If you want that feature, and you are certainly not alone, please fill in a Feature Request to get this feature on the priority list of the Adobe team.
    If you do not mind the work, it is possible to create question slides yourself using the available objects, user variables and advanced actions. I wrote several articles and blogged about those workarounds, one of them is about creating question slides with possibility for partial scoring (it is not a FIB-question but the principles are the same):
    Question slide with partial score
    Lilybiri

  • I've just bought an ipod touch. I cannot get beyond the question asking me for a network name. I don't have a mobile telephone which I think this question is referring to. All I want from an ipod is to listen to music. What should I do?

    I've just bought an ipod touch but I cannot get beyond the question asking me for a network name. I don't have a mobile telephone which I think this question is referring to. All I want from an ipod is to listen to music. What should I do?

    You have to activate a new iPod by either setting it up via wifi network that has an internet connection on to connect to a computer that has iTunes and an internet connection.
    You can go to an Apple store or or to a friend's house if necessary

  • HT5312 Rescue Email has been hacked I cannot rest my security questions what I have to do?

    Rescue Email has been hacked I cannot rest my security questions what I have to do?

    You won't be able to change the addres until you can answer your questions, you will need to contact Support in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use steps 1 to 7 half-way down the HT5312 page that you posted from to update your rescue email address for potential future use

  • Sequence question drop-down list gets hung up on punctuation

    I'm making a sequence question. In drag-and-drop mode, it
    works fine. But in the drop-down list mode, it breaks. In other
    words, even if it is displaying correctly, it is "wrong" when the
    enduser tries to sequence the choices.
    I assume that this is because one of my items has punctuation
    in it.
    It's a person's name, so it looks like this:
    Lastname, FirstInitial.
    Or it could be even two people:
    Lastname, FirstInitial. & Lastname, FirstInitial.
    Is there a way to escape the commas and periods? (I'm willing
    to give up on ampersand!) Use ASCII, escape ActionScript or
    JavaScript? I'm not likely to solve the problem by experimenting,
    so I'm wondering if someone else has figured this out. THANKS.
    (I tried searching the forum, but searching does not seem to
    be working for me)

    I can't help you with this myself as I've not done it but there are quite a few tutorials kicking around the net.
    Simple ODBC Connections in Adobe LiveCycle:
    http://www.youtube.com/watch?v=C56_Cz-aE0c
    Connecting a form to a database:
    http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
    Database connected forms:
    http://acrobatusers.com/tutorials/database-connected-forms

  • Cannot View Older Forum Questions and Bookmarking

    Hi,
    I noticed in the Lightroom for Beginners forum that you can only view one page of forum questions. You cannot view older forum questions/posts (i.e. pages 2,3,4...). There also is no way to bookmark and/or follow questions/topics/discussions.
    Unless I just have a crazy computer
    Is it possible to update the forum for these features???
    Thanks
    Andrew

    Try switching from the default overview - click image below. If you click the content tab it's possible to use the left and right arrow buttons to view older threads.

  • Drop Down Options in Captivate 6 Sequence Question

    Hello!
    I'm working on a project using Captivate 6. There is a Sequence question using the drop down option for Answer Type. For this particular question there are 5 items that need to be placed in order. When a learner clicks the drop down to answer the question only 4 of the 5 options display forcing the learner to scroll to see the last option. Is there a way to make the drop down display larger so the learner doesn't have to scroll?
    Thanks in advance for your advice.
    Marie

    Thanks Lilybiri!
    This was helpful. My team decided to stick with the drop down format, but by making the font size smaller we were able to fit all 5 options into the window (taking away the need to scroll.
    Thanks again,
    Marie

Maybe you are looking for