Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 87561

whats wrong with my concept to make a multiple mc with dynamic name to show on stage on random place and klick them away?

$
0
0

 

 

i wonna make a little game..

you have to hit the red circle, you have 3 seconds for it. the next circle is showing up after 1 second so you have to hit them fast because its geting faster after every 10s circle. this should be the game..

i found a way to make a dynamic variable. it seems working, but the wennduklikst Eventlistener at the end of the code is not working anymore now. but it should. maybe anybody know the anser!!??.

maybe you wonna take the code to try it. i thought this is the the most efficient way but i dont know it for shure. As you will see by looking at the code i am new and far away from professionel. i am just trying to stick codefragments together .. i guess i am on the right track but there are some basics i miss.

 

 

var count:Number = 0

 

var _mc:Array = new Array();

 

for(var i:int = 0; i<=100; ++i)

{

     var _mc0:MovieClip = new MovieClip();

     this.addChild(_mc0);

 

     // now add your square object to our Array

     _mc.push(_mc0);

 

}

 

//var _mc0:MovieClip = new MovieClip();

var _errortimer:Array = new Array();

 

for(var i2:int = 0; i2<=100; ++i2)

{

     var _errortimer0:Timer = new Timer(3000,1);

    

    //addChild(_errorTimer0);

     // now add your square object to our Array

     _errortimer.push(_errortimer0);

 

}

 

//var errorTimer:Timer = new Timer(3000,1);

 

 

 

// 3000 = Zeit zwischen zwei Timeraufrufen in Millisekunden

// 0 = Anzahl der Wiederholungen (0 = unendlich oft)

var myTimer:Timer = new Timer(1000,1);

 

// Event listeners:

myTimer.addEventListener("timer", myTimerAction);

//myTimer.addEventListener("timerComplete", myTimerComplete);

 

 

myTimer.start();

 

 

// Event handlers:

function myTimerAction(event:TimerEvent):void

{

 

    trace(event.target.currentCount+" mal ausgelöst.");

    // der Code

    // der alle x Millisekunden

    // ausgeführt wird.

 

 

 

    // Event listeners:

    _errortimer[0].addEventListener("timer", errorTimerAction);

    _errortimer[0].addEventListener("errortimerComplete", errorTimerComplete);

 

    _errortimer[0].start();

 

    // Event handlers:;

    function errorTimerAction(event:TimerEvent):void

    {

        myTimer.stop();

        ergebnis.text = (count+" hast du geschafft");

    }

 

    function errorTimerComplete(event:TimerEvent):void

    {

        trace("Timer ,,wird entfernt.");

        _errortimer[0].removeEventListener("timer", errorTimerAction);

        _errortimer[0].removeEventListener("timerComplete", errorTimerComplete);

    }

 

function CustomCircle(xInput:Number,yInput:Number,rInput:Number,colorInput:uint)

    {

        _mc[0].graphics.beginFill(colorInput);

        _mc[0].graphics.drawCircle(xInput, yInput, rInput);

    }

    CustomCircle(-35,35, 60, 0xFF3A00);

 

_mc[0].addChild

 

 

 

        var yrandomNum:Number = yrandomRange(70,947);

   

    //y axenwert zufällig

    function yrandomRange(minNum:Number, maxNum:Number):Number

    {

        return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

    }

 

 

    var xrandomNum:Number = xrandomRange(70,570);

 

    //x axenwert zufällig

    function xrandomRange(minNum:Number, maxNum:Number):Number

    {

        return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

    }

   

   

    _mc[0].x = xrandomNum;

    _mc[0].y = yrandomNum;

    _mc[0].name = "mcButton";

 

 

    //addChild(_mc);

 

 

}

 

/**

function myTimerComplete(event:TimerEvent):void

{

    // Es ist immer eine gute Idee, Event listeners

    // zu entfernen, wenn sie nicht mehr benötigt

    // werden:

   

    trace("Timer wird entfernt.");

    myTimer.removeEventListener("timer", myTimerAction);

    myTimer.removeEventListener("timerComplete", myTimerComplete);

}

 

**/

 

_mc[0].addEventListener(MouseEvent.CLICK, wennduklickst);

 

function wennduklickst(event:MouseEvent):void

{

   

    _mc[0].removeChild

 

    _errortimer[0].stop();

 

    count++;

   

}

 

 

thanks for any help :-S


Viewing all articles
Browse latest Browse all 87561

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>