Validate when all parts have made ​​the whole picture

I have 16 parts that make up whole picture shuffled on doc ready and now i must validate with an alert when whole picture is discovered.Also parts of picture shouldnt be available to switch again. I have tryed this code:

fiddle: http://jsfiddle.net/w53Ls/4/

$(function() {
        $("#puzzle").sortable({
            update: function() {
                var CorrectAnswers = ["bucata0", "bucata1", "bucata2", "bucata3", "bucata4", "bucata5", "bucata6", "bucata7", "bucata8", "bucata9", "bucata10", "bucata11", "bucata12", "bucata13", "bucata14", "bucata15"];
                var UserAnswers = [];
                $('#puzzle img').each(function(){
                    var imageId = $(this).attr("id");
                    UserAnswers += imageId.replace("recordArr_", "")+",";
                });           
                    UserAnswers = UserAnswers.substr(0,(UserAnswers.length) -1);
                if(UserAnswers == CorrectAnswers){
                    alert("You  Won");
                }
            }
        });
    });

Answers


It turns out that UserAnswers is no array (any more), while CorrectAnswers is. By simply joining the values of CorrectAnswers, the code will work

if(UserAnswers== CorrectAnswers.join(',')){
    alert("You  Won");
}

Or you rewrite CorrectAnswers to a comma separated string.


Need Your Help

Loading a swf named in xml into a parent swf in Actionscript 3

actionscript urlrequest spring-actionscript

OK, I have a situation where I use loadvars to load an xml file, which has the address of 2 swf's on the server. I can trace the xml items so know they are loading. So I'm trying to load the swf'...