hittestobject multiple functions with Drag and drop - actionscript-3

I have troubles making this code functionnal, i am pretty new to coding and learn everyday, so sorry if this question looks stupid.
Here's where I am so far :
a1 is a drag and drop object
a2 is an area, which when a1 is dropped on it, add the value 5 on a textfield
a3 is an area, which when a1 is dropped on it, substract the value 5 on a textfield
a1 start in the a3 area, when I drag a1 to a2, it shows 5, if I drag back to a3, it shows 0, so it's working as intended
Now what I struggle with :
a code that don't add 5 if I move a1 to a2, when a1 is ALREADY on a2.
a code that don't substract 5 if I move a1 to a3, when a1 is ALREADY on a3.
here's my code :
var myTextBox:TextField = new TextField();
var myTextBox2:TextField = new TextField();
addChild(myTextBox2);
myTextBox2.width = 200;
myTextBox2.height = 100;
myTextBox2.x = 100;
myTextBox2.y = 20;
a1.addEventListener(MouseEvent.MOUSE_DOWN, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(e:MouseEvent):void
{
e.target.startDrag();
}
function drop(e:MouseEvent):void
{
stopDrag();
if (a1.hitTestObject(a2))
{
myTextBox.text = "5";
var r:String=String(uint(myTextBox.text)+uint(myTextBox2.text));
myTextBox2.text=r;
}
if (a1.hitTestObject(a3))
{
myTextBox.text = "5";
var r2:String=String(uint(myTextBox2.text)-uint(myTextBox.text));
myTextBox2.text=r2;
}
else
{
trace("No collision.");
}
}
I don't think it's too complicated, but I don't have the knowledge yet to make it work, any assistance would be greatly appreciated ! thanks!

Ok, found out a way, so posting the code in case someone need it, or if someone has a better code, always wanting to learn ! thanks !
Added a movable object named a4 to test on multiple drag and drop objects
var myTextBox:TextField = new TextField();
var myTextBox2:TextField = new TextField();
var myTextBox3:TextField = new TextField();
addChild(myTextBox2);
myTextBox2.width = 200;
myTextBox2.height = 100;
myTextBox2.x = 100;
myTextBox2.y = 20;
a1.addEventListener(MouseEvent.MOUSE_DOWN, drag);
a1.addEventListener(MouseEvent.MOUSE_UP, drop);
a4.addEventListener(MouseEvent.MOUSE_DOWN, drag);
a4.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(e:MouseEvent):void
{
if (e.target.hitTestObject(a2))
{
e.target.startDrag();
myTextBox.text = "0";
myTextBox3.text = "5";
}
if (e.target.hitTestObject(a3))
{
e.target.startDrag();
myTextBox.text = "5";
myTextBox3.text = "0";
}
}
function drop(e:MouseEvent):void
{
stopDrag();
if (e.target.hitTestObject(a2))
{
var r:String=String(uint(myTextBox.text)+uint(myTextBox2.text));
myTextBox2.text=r;
}
if (e.target.hitTestObject(a3))
{
var r2:String=String(uint(myTextBox2.text)-uint(myTextBox3.text));
myTextBox2.text=r2;
}
}

Related

Drag Game Puzzle with custom dispatch event

i'm creating a drag puzzle game, and i need to resolve an issue, two to be exact:
a) Make a check if all the objects from dragArray variable are in the same place as the ones from matchArray.
b) If so, then display a button and play a sound file. (The button is *play_btn* and it plays a sound file when clicked, but i also need the sound to be played once the puzzle is solved so to speak.)
Would add some visual aid, but the forums says I need reputation.
Looking forward for some assistance.
The game is based on this tutorial.
var dragArray:Array = [p1, p2, p3, p4, p5, p6, p7, p8, p9];
var matchArray:Array = [p1_n, p2_n, p3_n, p4_n, p5_n, p6_n, p7_n, p8_n, p9_n];
var currentClip:MovieClip;
var startX:Number;
var startY:Number;
for(var i:int = 0; i < dragArray.length; i++) {
dragArray[i].buttonMode = true;
dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
matchArray[i].alpha = 0.2;
}
function item_onMouseDown(event:MouseEvent):void {
currentClip = MovieClip(event.currentTarget);
startX = currentClip.x;
startY = currentClip.y;
addChild(currentClip); //bring to the front
currentClip.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
}
function stage_onMouseUp(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
currentClip.stopDrag();
var index:int = dragArray.indexOf(currentClip);
var matchClip:MovieClip = MovieClip(matchArray[index]);
if(currentClip.hitTestObject(matchClip)) {
//a match was made! position the clip on the matching clip:
currentClip.x = matchClip.x;
currentClip.y = matchClip.y;
//make it not draggable anymore:
currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
currentClip.buttonMode = false;
} else {
//match was not made, so send the clip back where it started:
currentClip.x = startX;
currentClip.y = startY;
}
}
var my_sound:Sound = new Sound();
my_sound.load(new URLRequest("sounds/song.mp3"));
var my_channel:SoundChannel = new SoundChannel();
play_btn.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:MouseEvent):void{
my_channel = my_sound.play();
}
You can use a validate function like this one. It will returns true if all drop items are on their targets, false otherwise
function validate(drags:Array, drops:Array):Boolean {
var found:uint = 0
for (var i:uint = 0;i<drags.length;i++ ) {
var drag:MovieClip = MovieClip(drags[i]);
var drop:MovieClip = MovieClip(drops[i]);
found += (drag.hitTestObject(drop)) ? 1 : 0
}
return found == drop.length
}
Then you can use it to check the global interaction :
var result:Boolean = validate(dragArray,matchArray);
if (result) {
// all ok
// play sound...
} else {
// errors
}

Drawing app undo and redo function action script 3

Can anyone show me how can I make undo and redo function? so this is my current action script. I cant figure how to do it and i see some example in some web site, the action script is to long to under stand. Pls show a simple way that i can make this work..
sorry for bad grammar...
var drawingLine:Shape=new Shape();
board.addChild(drawingLine);
var doDraw:Boolean=false;
var lineSize:Number=7;
var activeColor:uint = 0x000000;
function PencilTool(event:MouseEvent):void{
board.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
board.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
function MouseDown(e:MouseEvent):void{
doDraw=true;
drawingLine.graphics.moveTo(drawingLine.mouseX, drawingLine.mouseY);
drawingLine.graphics.lineStyle(lineSize, activeColor);
board.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
function MouseMove(e:MouseEvent):void{
var curX:Number=drawingLine.mouseX;
var curY:Number=drawingLine.mouseY;
if(doDraw && checkCoords(curX,curY)){
if(active=="Line"){
clearTemp();
temporaryDrawing.graphics.lineTo(curX,curY);
}else{
drawingLine.graphics.lineTo(curX,curY);
}
e.updateAfterEvent();
}
}
function MouseUp(event:MouseEvent):void{
doDraw=false;
}
btn_Pencil.addEventListener(MouseEvent.MOUSE_UP, PencilTool);
this,o Using two graphics,would not be the way to go
The way I would approach this is by creating a lineInfo class (seeing how you are using lines only), and have the information of startpoint, endpoint, lineColour, lineWidth, and lineAlpha .
Then create an array or Vector and populate it with a new LineInfo class, and update the graphics with the line. If you need to undo, you can set the last item use value to false, and redraw the graphics from the instruction of the array. Create a undo step integer, that keeps track of how many (counting from the back) actions should be omitted.
To improve performance, you can create a maximum of 25 instructions, and create a graphics that caches the items not in the undo list.
You could save all movements after clicks in an array or vector, then if you want to undo, you redraw all movements in the array except the last one.
Could be something like this:
var drawingLine:Shape=new Shape();
board.addChild(drawingLine);
// MOVEMENTS INFORMATION
var movements:Array = new Array();
var doDraw:Boolean = false;
var cacheIndex:int = 0;
var lineSize:Number=7;
var activeColor:uint = 0x000000;
function PencilTool(event:MouseEvent):void{
board.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
board.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
function MouseDown(e:MouseEvent):void{
function PencilTool(event:MouseEvent):void{
board.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
board.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
function MouseDown(e:MouseEvent):void{
doDraw=true;
drawingLine.graphics.moveTo(drawingLine.mouseX, drawingLine.mouseY);
drawingLine.graphics.lineStyle(lineSize, activeColor);
board.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
lastTracing = {
mainPoint: {
x:drawingLine.mouseX,
y:drawingLine.mouseY
},
lineSize: lineSize,
activeColor:activeColor,
points:new Array()
}
cacheIndex = 0;
movements.splice(movements.length - cacheIndex, cacheIndex);
movements.push(lastTracing );
}
function MouseMove(e:MouseEvent):void{
var curX:Number=drawingLine.mouseX;
var curY:Number=drawingLine.mouseY;
if(doDraw && checkCoords(curX,curY)){
if(active=="Line"){
clearTemp();
temporaryDrawing.graphics.lineTo(curX,curY);
}else{
drawingLine.graphics.lineTo(curX,curY);
lastTracing.points.push({x:curX, y:curY});
}
e.updateAfterEvent();
}
}
function MouseUp(event:MouseEvent):void{
doDraw=false;
}
function undoFunction(event:MouseEvent=null):void {
if(cacheIndex+1 <= movements.length){
cacheIndex++;
}
drawCache();
}
function redoFunction(event:MouseEvent = null):void {
if(cacheIndex-1 >= 0){
cacheIndex--;
}
drawCache();
}
function drawCache():void {
for(var i:uint=0;i<(movements.length-cacheIndex);i++){
var tracingInfo:Object = movements[i];
drawingLine.graphics.clear();
drawingLine.graphics.moveTo(tracingInfo.mainPoint.x, tracingInfo.mainPoint.y);
drawingLine.graphics.lineStyle(tracingInfo.lineSize, tracingInfo.activeColor);
for(var j:uint=0;j<tracingInfo.points.length;j++){
drawingLine.graphics.lineTo(tracingInfo.points[j].x,tracingInfo.points[j].y);
}
}
}
btn_Pencil.addEventListener(MouseEvent.MOUSE_UP, PencilTool);

Some errors in flash AS3 game, almost completed with lot of effort and help received

First I really want to thank you for all the help you have given me so far, since I did not know anything about AS3 (basics gotoAnd stuff only) I came to Stackoverflow searching for some code already made but I was encouraged by some members to make the code by myself, now after almost 2 weeks and thanks to a lot of great people my soccer penalty kick game is almost finished, I really love this place.
I know I have to work on some collisions and other stuff since currently the game is not the best (remember I’m just a newbie), but Unfortunately while checking the game functioning by playing it over and over again, I have found the following:
1- When you get 3 fails, then game is over and a play again button appears after some animation, you click on it and everything seems to be fine, but when you continue playing the second time you reach 3 fails, when you click the button a new cursor appears??? Please help
2- I tried millions of times to make the ball move with speed and to animate its trajectory but was unable to make it, any help on this will be highly appreciated. I have speed variables and gravity but I didn’t know how to use them
3- I'm getting a actionscript error related to a removeChild, I tried many times removing some lines but I´m unable to fix it.
4- I'm using too many timers, I don't know if this is recommendable.
Here is the .fla file https://rapidshare.com/files/1702748636/kicks.fla just in case anybody want to try the game (this is really simple since it is my 1st AS project) and want to help me with the code and help me improving the game, and here is the code if somebody does not need to get into the file (I know this place is full of really smart people), once I finish it I know I will be able to do a lot of stuff with AS3.
var score:Number;
var angle:Number;
var speed:Number;
var cursor:MovieClip;
var failed:Number;
var ballRotation:Boolean = false;
function initializeGame( ):void
{
ball.x = 296.35;
ball.y = 353.35;
score=0;
failed=0;
cursor = new Cursor();
addChild(cursor);
cursor.enabled = true;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
}
function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}
initializeGame();
var mouse = this.Mouse;
function kick(evt:Event)
{
removeChild(cursor);
pateador_mc.play();
var timer:Timer = new Timer(500,1);
timer.addEventListener(TimerEvent.TIMER, delayedAction);
timer.start();
function delayedAction(e:TimerEvent)
{
moveBall();
}
}
speed=-100000;
var ease:int = 100;
var gravity:Number = 0.5;
function moveBall()
{
var targetX:Number = mouseX;
var targetY:Number = mouseY;
var angle = Math.atan2(targetY,targetX);
ball.x = mouseX + Math.cos(angle);
ball.y = mouseY + Math.sin(angle) ;
ballRotation = true;
stage.removeEventListener(MouseEvent.CLICK, kick);
if (ballRotation==true)
{
keeper.gotoAndStop(1 + Math.floor(Math.random() * keeper.totalFrames));
ball.play();
}
if (ball.hitTestObject ( keeper)){
ball.y=keeper.x-ball.height- ball.width;
trace ("Tomela");
}
if (ball.hitTestObject(goalie) && ball.y>69 /*&& ball.y<178 && ball.X>139 && ball.x<466*/)
{
gol_mc.play();
score ++;
showScore();
var timer3:Timer = new Timer(3000,1);
timer3.addEventListener(TimerEvent.TIMER, delayedAction3);
timer3.start();
function delayedAction3(e:TimerEvent)
{
ball.x = 296.35;
ball.y = 353.35;
stage.addEventListener(MouseEvent.CLICK, kick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
addChild(cursor);
keeper.gotoAndStop(1);
}
}
else
{
fails_mc.play();
failed++;
var timer2:Timer = new Timer(3000,1);
timer2.addEventListener(TimerEvent.TIMER, delayedAction2);
timer2.start();
function delayedAction2(e:TimerEvent)
{
ball.x = 296.35;
ball.y = 353.35;
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
addChild(cursor);
keeper.gotoAndStop(1);
}
trace(failed);
if (failed==3) {
gameFinished();
trace("YOU LOST");
}
}
function showScore():void{
goles_txt.text ="" +score;
}
trace (score);
function gameFinished(){
gameOver.play ();
stage.removeEventListener(MouseEvent.CLICK, kick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
timer2.stop();
Mouse.show();
this.mouseX=cursor.x ;
this.mouseY=cursor.y;
again_btn.addEventListener(MouseEvent.MOUSE_DOWN, playAgain);
}
function playAgain():void{
gameOver.gotoAndPlay(31);
fails_mc.gotoAndStop(1);
keeper.play();
var timer4:Timer = new Timer(1000,1);
timer4.addEventListener(TimerEvent.TIMER, delayedAction3);
timer4.start();
function delayedAction3(e:TimerEvent)
{
initializeGame();
}
}
}
I’ll really appreciate it guys , I promise I won’t be bothering again for a long time
1/3.
Problem 1 & 3 are the same problem. Looks like your trying to remove the cursor from the stage (removeChild) every click (so it will error after the first click because it's no longer a child of anything). Your adding it back on your delayedAction2 which doesn't run unless your hit test is true and only after 3 seconds. On initialize game you create a whole new cursor and add that to the stage which is why you get a duplicate after the first game.
Rather than removeChild the cursor, it might better to just set it's visibility to false/true and only create it once.
You'll need to use an EnterFrame handler, or timer, or tween for this. I can post an example later.
I can't figure out why you're using timers at all or need to delay your functions, except maybe to allow time for the kick animation?
You're code is very disorganized, naming functions things like 'delayedAction' is bad as it doesn't really tell you anything about the purposed of the function. You also have way too much functions inside of other functions. Here is a quick refactoring of your code I've done to hopefully teach a few things. I've also added the tween for the ball animation.
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
var score:Number;
var cursor:MovieClip;
var failed:Number;
var ballRotation:Boolean = false;
var ballTweenX:Tween;
var ballTweenY:Tween;
var targetCursor = new Cursor(); //only want one of these and you want it to exist the whole time so keep out here.
addChild(targetCursor);
initializeGame();
function initializeGame( ):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
ball.x = 296.35;
ball.y = 353.35;
score=0;
failed=0;
targetCursor.visible = true;
Mouse.hide();
}
function dragCursor(event:MouseEvent):void
{
targetCursor.x = this.mouseX;
targetCursor.y = this.mouseY;
}
function kick(evt:Event)
{
//removeChild(targetCursor);
targetCursor.visible = false;
pateador_mc.play();
stage.removeEventListener(MouseEvent.CLICK, kick); //move this here, because you don't the option kick again while already kicking
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragCursor); //added this, you probably don't want the target moving after the click...
setTimeout(moveBall, 500);//cleaner and more efficient than using a timer for a one time delayed call.
}
function moveBall()
{
var targetX:Number = mouseX;
var targetY:Number = mouseY;
var angle = Math.atan2(targetY,targetX);
targetX = mouseX + Math.cos(angle);
targetY = mouseY + Math.sin(angle) ;
ballRotation = true;
ballTweenX = new Tween(ball, "x", null, ball.x, targetX, .3, true);
ballTweenY = new Tween(ball, "y", null, ball.y, targetY, .3, true);
ballTweenY.addEventListener(TweenEvent.MOTION_FINISH, ballTweenDone,false,0,true);
if (ballRotation==true)
{
keeper.gotoAndStop(1 + Math.floor(Math.random() * keeper.totalFrames));
ball.play();
}
}
function stopBallTween():void {
ballTweenX.stop();
ballTweenY.stop();
}
function ballTweenDone(e:TweenEvent):void {
if (ball.hitTestObject ( keeper)){
ball.y=keeper.x-ball.height- ball.width;
trace ("Tomela");
}
if (ball.hitTestObject(goalie) && ball.y>69 /*&& ball.y<178 && ball.X>139 && ball.x<466*/)
{
gol_mc.play();
score ++;
showScore();
}else
{
fails_mc.play();
failed++;
trace(failed);
if (failed==3) {
gameFinished();
trace("YOU LOST");
return; //added this because you don't want the rest of this function running if it's a game over
}
}
setTimeout(resetShot, 3000); //you had the code I put in resetShot repeated twice
trace(score);
}
function resetShot():void {
ball.x = 296.35;
ball.y = 353.35;
targetCursor.visible = true;
keeper.gotoAndStop(1);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
}
function showScore():void{
goles_txt.text ="" +score;
}
function gameFinished(){
gameOver.play();
stage.removeEventListener(MouseEvent.CLICK, kick);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
Mouse.show();
//this.mouseX=cursor.x ;
//this.mouseY=cursor.y; //These are read only properties, your can't set the mouse position...
again_btn.addEventListener(MouseEvent.MOUSE_DOWN, playAgain);
}
function playAgain(e:Event = null):void{
gameOver.gotoAndPlay(31);
fails_mc.gotoAndStop(1);
keeper.play();
setTimeout(initializeGame, 1000);
}

Related to ActionScript 3

I am creating a drag and drop game using AS3. This is the code i used to do the drag and drop. The game will provide a hint for the user where the user has to drag a particular answer out of the three options to the correct position. This coding will allow the user to select all the three options. What i want to do is restrict the user from selecting multiple options. Can someone help me with this?
var myArray:Array = [apple, grapes, gava];
var matchImage:Array = [imgApple, imgGrapes, imgGuava];
var posArray:Array = [ {x:55.3, y:55.6}, {x:100.45, y:100.6}, {x:300.5, y:250.7} ];
var currentClip:MovieClip;
var Xpos:Number;
var Ypos:Number;
for(var i:int = 0; i < wordArray.length; i++) {
myArray[i].buttonMode = true;
myArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
}
function item_onMouseDown(event:MouseEvent):void {
currentClip = MovieClip(event.currentTarget);
Xpos = currentClip.x;
Ypos = currentClip.y;
addChild(currentClip);
currentClip.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
}
function stage_onMouseUp(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
currentClip.stopDrag();
var index:int = myArray.indexOf(thisClip);
var equalClip:MovieClip = MovieClip(matchImage[index]);
if(matchImage.hitTestPoint(thisClip.x, thisClip.y, true)) {
currentClip.x = posArray[index].x;
currentClip.y = posArray[index].y;
currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
currentClip.buttonMode = false;
}
else
{
currentClip.x = startXposition;
currentClip.y = startYposition;
}
}
Once you detect MouseEvent.MOUSE_DOWN on any of the clips you should remove the listeners on the other clips, this will prevent them from being dragged.
Once your done with the dragging you can add them back to allow the user to start dragging again.

AS3 Quiz - How do I move to the next question?

using various tutorials I created the next quiz in AS3. It's dynamic and I use an important function to set up the entire thing, and a counter to manage the quiz and arrays.
After picking an answer you click on a check button and then on a "Next" button.
I'm getting no errors, however for some reason calling the setup() function isn't moving the quiz fwd.
Attached is my short code with edits of the useless stuff, I would love some suggestions.
BTW, the foreign language is Hebrew :)
var arrQuestion:Array = [ "?מיהו סטיב ג'ובס", "מהי משמעות הקיצור WWW?"];
var arrAnswers:Array = [["AOL מנכל","יור אורקל","מנכל אפל","מנכל סאן"], ["World Wide Web", "With Web Wins", "Wired Web Window", "Wap Windows War"]];
var arrCorrect:Array = [3, 1];
var btnNext:myNext = new myNext();
setup();
function setup():void {
var i:Number=0;
var thequestion_txt:TextField= new TextField;
addChild(thequestion_txt);
var feedback_txt:TextField= new TextField;
addChild(feedback_txt);
var radio1:RadioButton = new RadioButton();
var radio2:RadioButton = new RadioButton();
var radio3:RadioButton = new RadioButton();
var radio4:RadioButton = new RadioButton();
var radioGrp:RadioButtonGroup = new RadioButtonGroup("radioGrp");
addChild(radio1);
addChild(radio2);
addChild(radio3);
addChild(radio4);
radio1.label = arrAnswers[i][0];
radio1.value = 1;
//etc..
var checkButton:Button = new Button();
addChild(checkButton);
checkButton.x =230;
checkButton.y = 300;
checkButton.label = "בדוק";
checkButton.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
addChild(btnNext);
btnNext.x =230;
btnNext.y = 300;
if (radioGrp.selection.value == (arrCorrect[i])) {
feedback_txt.text = "!נכון מאוד";
btnNext.addEventListener(MouseEvent.CLICK, myRemove);
} else {
feedback_txt.text = "תשובה שגויה";
btnNext.addEventListener(MouseEvent.CLICK, myRemove);
}
}
function myRemove(e:MouseEvent):void {
removeChild(thequestion_txt);
removeChild(feedback_txt);
removeChild(radio1);
removeChild(radio2);
removeChild(radio3);
removeChild(radio4);
removeChild(checkButton);
removeChild(btnNext);
//chaning the counter to change the question and answers
i++;
//shouldn't the call to setting up the entire stage again be here?
//it is't working, I dont get the next question.
setup();
}
}
change:
function setup():void {
var i:Number=0;
to:
var i:Number=0;
function setup():void {
Otherwise, you're incrementing with 'i++' and calling 'setup()', which then resets 'i' to 0 again and the increment never happened.
P.S. using 'Code Sample' formatting would help the readability of your example immensely.