vendredi 16 septembre 2016

How to add my objects to this code?

I have three objects on stage called b1_mc , b2_mc , b3_mc how to add them to code can you edite this code to add b1_mc , b2_mc , b3_mc please add some context to explain code sections or check that you have not incorrectly formatted all of your question as code

        import flash.geom.Point;

        var positions:Vector.<Point >  = new Vector.<Point > (3);
        var numbers:Vector.<uint> = new Vector.<uint>();
        var numbersAllowed:uint = 3;
        var rndNmbrs:Vector.<uint> = new Vector.<uint>(3);;

        var p1:Point = new Point(78,200);
        var p2:Point = new Point(217,200);
        var p3:Point = new Point(356,200);

        positions[0] = p1;
        positions[1] = p2;
        positions[2] = p3;

        trace(positions);

        function populateRndNmbrs(n:uint):void {
            for (var i:uint = 0; i < n; i++)
            {
                numbers[i] = i;
            }
        }
        populateRndNmbrs(numbersAllowed);

        function populateRandomNumbers(n:uint):void
        {
            var rnd:uint;
            for (var i:uint = 0; i < n; i++)
            {
                rnd = numbers[Math.floor(Math.random() * numbers.length)];
                for (var j:uint = 0; j < numbers.length; j++)
                {
                    if (rnd == numbers[j])
                    {
                        numbers.splice(j,1);
                    }
                }

                rndNmbrs[i] = rnd;
            }
        }
        populateRandomNumbers(numbersAllowed);
        trace("rndNmbrs = " + rndNmbrs);
        for (var i:uint = 0; i < numbersAllowed; i++)
        {
            trace("b"+ (i+1) + ".x = " + positions[rndNmbrs[i]].x);
            trace("b"+ (i+1) + ".y = " + positions[rndNmbrs[i]].y);
        // In place of trace, you should place the boxes at those random positions: b1_mc , b2_mc , b3_mc
thank you ... please add some context to explain code sections or check that you have not incorrectly formatted all of your question as code

        }
//please add some context to explain code sections or check that you have not incorrectly formatted all of your question as code

Aucun commentaire:

Enregistrer un commentaire