need a code
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: need a code

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    1

    Question need a code

    hi guyz,
    i am new to flash,i need to develop a flash game which is simple dot to dot game for kids(connecting dots)...so anyone plz help me out to develop a game or give a code for that game to me...its urgent...its part of my project!!!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    902
    hi,

    This link might help you achieve something Here

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,513
    Maybe you can adapt this...
    Code:
    // bottom layer - 'linesMC', empty movie clip at 0,0
    // middle layer -  dot movie clips, put instance names in dots array below
    // top layer - 'drawMC', empty move clip at 0,0
    
    var lineColor = 0x000000;
    var dots = [dot1, dot2, dot3, dot4, dot5, dot6, dot7, dot8];
    var startDot = null;
    onMouseDown = updateLines;
    
    function updateLines() {
            var dot = checkHit(dots);
            if (dot != null) {
                    if (startDot == null) {
                            startDot = dot;
                            onMouseUp = function () {
                                    checkLine();
                                    startDot.onEnterFrame = null;
                                    startDot = null;
                            };
                            startDot.onEnterFrame = function() {
                                    drawMC.clear();
                                    drawMC.lineStyle(6,lineColor,80);
                                    drawMC.moveTo(this._x,this._y);
                                    drawMC.lineTo(_xmouse,_ymouse);
                            };
                    } else {
                            checkLine();
                            startDot.onEnterFrame = null;
                            startDot = null;
                    }
            } else {
                    var line = checkHit(linesMC);
                    if (line != null) {
                            removeMovieClip(line);
                            checkComplete()
                    }
            }
    };
    function checkLine() {
            var dot = checkHit(dots);
            if (dot != null && startDot != dot) {
                    var mc = linesMC.createEmptyMovieClip("mc" + linesMC.getNextHighestDepth(), linesMC.getNextHighestDepth());
                    mc.lineStyle(6,lineColor,100);
                    mc.moveTo(startDot._x,startDot._y);
                    mc.lineTo(dot._x,dot._y);
                    checkComplete();
            }
            drawMC.clear();
    }
    function checkHit(grp) {
            var mc = null;
            for (var i in grp) {
                    if (grp[i].hitTest(_xmouse, _ymouse, true)) {
                            mc = grp[i];
                            return mc;
                    }
            }
            return mc;
    }
    function checkComplete() {
            var ct = 0;
            var len = dots.length - 1;
            var num = 0;
            for (var i in linesMC) {
                    for (var j = 0; j < len; j++) {
                            if (linesMC[i].hitTest(dots[j]._x, dots[j]._y, true) && linesMC[i].hitTest(dots[j + 1]._x, dots[j + 1]._y, true)) {
                                    ct++;
                            }
                    }
                    num++
            }
            if (num == ct && ct == len){
                    trace("puzzle complete")
                    onMouseDown = null;
            }
    }
    Last edited by dawsonk; 02-21-2013 at 12:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com