#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    325
    Rep Power
    10

    Dynamically changing movie clip for drop target


    Hi
    I've hit a snag with a simple maths game.
    Questions come from an array, because the questions need to come from anarrow range.
    Code:
    var index = Math.floor(Math.random()*1);
    var sums = new Array ();
    sums [0] = "5-4";
    var answer = new Array();
    answer[0] = pig1;
    prob = sums[index];
    Prob is a dynamice text boxon the screen.
    I want to use drag and drop to solve the problem.
    Currently, I have:
    Code:
    pig1.onPress = function() {
    	startDrag(this);
    	}
    	pig1.onRelease = function() {
    	stopDrag();
    	trace(this);
    	if (eval(this._droptarget) == target[index]) {
    trace(this._droptarget);
    e="Well done";
    score++;
    }
    else{
    	e="wrong!!!!";
    	this._x = this.myHomeX;
    this._y = this.myHomeY;
    }
    	}
    Assuming the code expands to 10 questions in the array, how can I dynamically work out which pig picture will display as the correct answer when dragged over the target?
    Attached Images

IMN logo majestic logo threadwatch logo seochat tools logo