I'm doing the Actionscript 2.0 to 3.0 work but I have very few idea on 3.0, Can somebody good guys help to make a translate please!
I have try to finish a version but my work just cannot being "drag n drop" after changing the codes.
stop();
var randomPositionFrame = int(Math.random()*9)+1;
content_mc.gotoAndStop(randomPositionFrame);
for(var i=1; i<=5; i++){
eval("content_mc.matching_term_"+i)._alpha = 0;
eval("content_mc.matching_term_"+i).onPress = function(){
if(this._currentframe == 1){
this.startDrag();
}
}
eval("content_mc.matching_term_"+i).onRelease = onMouseUp = function(){
this.stopDrag();
}
eval("content_mc.matching_desc_"+i)._alpha = 0;
eval("content_mc.matching_desc_"+i).onPress = function(){
if(this._currentframe == 1){
this.startDrag();
}
}
eval("content_mc.matching_desc_"+i).onRelease = onMouseUp = function(){
this.stopDrag();
}
}
var winGame = false;
var alphaSpeed = 20;
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function () { this.isDown = true;};
mouseListener.onMouseUp = function () {
this.isDown = false;
//Game Logic Check Correct
for(var i=1; i<=5; i++){
//term match description
if(eval("content_mc.matching_desc_"+i).mc._currentframe == 2 && eval("content_mc.matching_term_"+i).mc._currentframe == 2){
if(eval("content_mc.matching_term_"+i)._currentframe == 1){
eval("content_mc.matching_term_"+i).gotoAndPlay(2);
eval("content_mc.matching_desc_"+i).gotoAndPlay(2);
}
}
//description match term
else if(eval("content_mc.matching_desc_"+i).mc._currentframe == 2 && eval("content_mc.matching_term_"+i).mc._currentframe == 2){
if(eval("content_mc.matching_desc_"+i)._currentframe == 1){
eval("content_mc.matching_term_"+i).gotoAndPlay(2);
eval("content_mc.matching_desc_"+i).gotoAndPlay(2);
}
}
}
};
Mouse.addListener(mouseListener);
this.onEnterFrame = function(){
//display terms at start
if(content_mc.matching_term_1._alpha < 100){
content_mc.matching_term_1._alpha +=alphaSpeed;
}
if(content_mc.matching_term_1._alpha >= 100){
if(content_mc.matching_term_2._alpha < 100){
content_mc.matching_term_2._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_2._alpha >= 100){
if(content_mc.matching_term_3._alpha < 100){
content_mc.matching_term_3._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_3._alpha >= 100){
if(content_mc.matching_term_4._alpha < 100){
content_mc.matching_term_4._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_4._alpha >= 100){
if(content_mc.matching_term_5._alpha < 100){
content_mc.matching_term_5._alpha +=alphaSpeed;
}
}
//display description at start
if(content_mc.matching_term_5._alpha >= 100){
if(content_mc.matching_desc_1._alpha < 100){
content_mc.matching_desc_1._alpha +=alphaSpeed;
}
if(content_mc.matching_desc_1._alpha >= 100){
if(content_mc.matching_desc_2._alpha < 100){
content_mc.matching_desc_2._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_2._alpha >= 100){
if(content_mc.matching_desc_3._alpha < 100){
content_mc.matching_desc_3._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_3._alpha >= 100){
if(content_mc.matching_desc_4._alpha < 100){
content_mc.matching_desc_4._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_4._alpha >= 100){
if(content_mc.matching_desc_5._alpha < 100){
content_mc.matching_desc_5._alpha +=alphaSpeed;
}
}
/*if(content_mc.matching_desc_5._alpha >= 100){
delete this.onEnterFrame;
}*/
}
//Roll over effect
for(var i=1; i<=5; i++){
if(eval("content_mc.matching_term_"+i).hitTest(this._xmouse, this._ymouse)){
eval("content_mc.matching_term_"+i).mc.gotoAndStop(2);
}
else{
eval("content_mc.matching_term_"+i).mc.gotoAndStop(1);
}
if(eval("content_mc.matching_desc_"+i).hitTest(this._xmouse, this._ymouse)){
eval("content_mc.matching_desc_"+i).mc.gotoAndStop(2);
}
else{
eval("content_mc.matching_desc_"+i).mc.gotoAndStop(1);
}
}
//remove the matched movieclips
for(var i=1; i<=5; i++){
if(eval("content_mc.matching_term_"+i)._currentframe == 10){
eval("content_mc.matching_term_"+i)._y = -1000;
}
if(eval("content_mc.matching_desc_"+i)._currentframe == 10){
eval("content_mc.matching_desc_"+i)._y = -1000;
}
}
//Win Game
for(var i=1; i<=5; i++){
if(eval("content_mc.matching_desc_"+i)._currentframe == 10){
winGame = true;
}
else{
winGame = false;
return;
}
}
if(winGame == true){
this.gotoAndPlay("endRound1");
}
}
I have done the 3.0 like this: (but turns out the I cannot do the drag n drop)
stop();
var randomPositionFrame = int(Math.random()*9)+1;
content_mc.gotoAndStop(randomPositionFrame);
for(var i=1; i<=5; i++){
this["content_mc.matching_term_"+i]._alpha = 0;
this["content_mc.matching_term_"+i].addEventListener(MouseEvent.MOUSE_DOWN,function():void {
if(this._currentframe == 1){
this.startDrag();
}
}
);
this["content_mc.matching_term_"+i].addEventListener(MouseEvent.MOUSE_UP,function():void {
stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp, false, 0, true);
);
this["content_mc.matching_desc_"+i]._alpha = 0;
this["content_mc.matching_desc_"+i].addEventListener(MouseEvent.MOUSE_DOWN,function():void {
if(this._currentframe == 1){
this.startDrag();
}
}
);
this["content_mc.matching_desc_"+i].addEventListener(MouseEvent.MOUSE_UP,function():void {
stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp, false, 0, true);
}
);
}
function doMouseUp($evt:MouseEvent):void
{
this.stopDrag();
}
var winGame = false;
var alphaSpeed = 20;
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function () { this.isDown = true;};
mouseListener.onMouseUp = function () {
this.isDown = false;
//Game Logic Check Correct
for(var k=1; k<=5; k++){
//term match description
if(this["content_mc.matching_desc_"+k].mc._currentframe == 2 && this["content_mc.matching_term_"+k].mc._currentframe == 2){
if(this["content_mc.matching_term_"+k]._currentframe == 1){
this["content_mc.matching_term_"+k].gotoAndPlay(2);
this["content_mc.matching_desc_"+k].gotoAndPlay(2);
}
}
//description match term
else if(this["content_mc.matching_desc_"+k].mc._currentframe == 2 && this["content_mc.matching_term_"+k].mc._currentframe == 2){
if(this["content_mc.matching_desc_"+k]._currentframe == 1){
this["content_mc.matching_term_"+k].gotoAndPlay(2);
this["content_mc.matching_desc_"+k].gotoAndPlay(2);
}
}
}
};
this.Mouse.addListener(mouseListener);
this.addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
//display terms at start
if(content_mc.matching_term_1._alpha < 100){
content_mc.matching_term_1._alpha +=alphaSpeed;
}
if(content_mc.matching_term_1._alpha >= 100){
if(content_mc.matching_term_2._alpha < 100){
content_mc.matching_term_2._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_2._alpha >= 100){
if(content_mc.matching_term_3._alpha < 100){
content_mc.matching_term_3._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_3._alpha >= 100){
if(content_mc.matching_term_4._alpha < 100){
content_mc.matching_term_4._alpha +=alphaSpeed;
}
}
if(content_mc.matching_term_4._alpha >= 100){
if(content_mc.matching_term_5._alpha < 100){
content_mc.matching_term_5._alpha +=alphaSpeed;
}
}
//display description at start
if(content_mc.matching_term_5._alpha >= 100){
if(content_mc.matching_desc_1._alpha < 100){
content_mc.matching_desc_1._alpha +=alphaSpeed;
}
if(content_mc.matching_desc_1._alpha >= 100){
if(content_mc.matching_desc_2._alpha < 100){
content_mc.matching_desc_2._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_2._alpha >= 100){
if(content_mc.matching_desc_3._alpha < 100){
content_mc.matching_desc_3._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_3._alpha >= 100){
if(content_mc.matching_desc_4._alpha < 100){
content_mc.matching_desc_4._alpha +=alphaSpeed;
}
}
if(content_mc.matching_desc_4._alpha >= 100){
if(content_mc.matching_desc_5._alpha < 100){
content_mc.matching_desc_5._alpha +=alphaSpeed;
}
}
/*if(content_mc.matching_desc_5._alpha >= 100){
delete this.onEnterFrame;
}*/
}
//Roll over effect
for(var i=1; i<=5; i++){
if(this["content_mc.matching_term_"+i].hitTest(mouseX, mouseY)){
this["content_mc.matching_term_"+i].mc.gotoAndStop(2);
}
else{
this["content_mc.matching_term_"+i].mc.gotoAndStop(1);
}
if(this["content_mc.matching_desc_"+i].hitTest(mouseX, mouseY)){
this["content_mc.matching_desc_"+i].mc.gotoAndStop(2);
}
else{
this["content_mc.matching_desc_"+i].mc.gotoAndStop(1);
}
}
//remove the matched movieclips
for(var a=1; a<=5; a++){
if(this["content_mc.matching_term_"+a]._currentframe == 10){
this["content_mc.matching_term_"+a]._y = -1000;
}
if(this["content_mc.matching_desc_"+a]._currentframe == 10){
this["content_mc.matching_desc_"+a]._y = -1000;
}
}
//Win Game
for(var n=1; n<=5; n++){
if(this["content_mc.matching_desc_"+n]._currentframe == 10){
winGame = true;
}
else{
winGame = false;
return;
}
}
if(winGame == true){
this.gotoAndPlay("endRound1");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…