Copy link to clipboard
Copied
i did all of the instructions here (http://www.ehow.com/how_7355693_make-memory-game-flash.html) but i keep getting 5007:An actionscript file must have at least one externally visible definition whenever i press ctrl+enter. i'm guessing it has something to do with the code...
Copy link to clipboard
Copied
It sounds like you have created a class file that only has "private" elements and you have not provided anything "public" that the outside world can use to work with the class.
Copy link to clipboard
Copied
i would appreciate it very much if you could tell me how to make it public if you got any free time
Copy link to clipboard
Copied
You will help yourself if you show the code when you are asking for help with a code problem
Copy link to clipboard
Copied
it was provided in the link mentioned above but here is the code anyways:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class image_match extends Sprite {
private var first_tile:images;
private var second_tile:images;
private var pause_timer:Timer;
varimagedeck:Array = new Array(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8);
public function image_match() {
for (x=1; x<=4; x++) {
for (y=1; y<=4; y++) {
var random_card = Math.floor(Math.random()*imagedeck.length);
var tile:images = new images();
tile.col = imagedeck[random_card];
imagedeck.splice(random_card,1);
tile.gotoAndStop(9);
tile.x = (x-1)*82;
tile.y = (y-1)*82;
tile.addEventListener(MouseEvent.CLICK,tile_clicked);
addChild(tile);
}
}
}
public function tile_clicked(event:MouseEvent) {
var clicked:image = (event.currentTarget as image);
if (first_tile == null) {
first_tile = clicked;
first_tile.gotoAndStop(clicked.col);
}
else if (second_tile == null && first_tile != clicked) {
second_tile = clicked;
second_tile.gotoAndStop(clicked.col);
if (first_tile.col == second_tile.col) {
pause_timer = new Timer(1000,1);
pause_timer.addEventListener(TimerEvent.TIMER_COMPLETE,remove_tiles);
pause_timer.start();
}
else {
pause_timer = new Timer(1000,1);
pause_timer.addEventListener(TimerEvent.TIMER_COMPLETE,reset_tiles);
pause_timer.start();
}
}
}
public function reset_tiles(event:TimerEvent) {
first_tile.gotoAndStop(9);
second_tile.gotoAndStop(9);
first_tile = null;
second_tile = null;
pause_timer.removeEventListener(TimerEvent.TIMER_COMPLETE,reset_tiles);
}
public function remove_tiles(event:TimerEvent) {
removeChild(first_tile);
removeChild(second_tile);
first_tile = null;
second_tile = null;
pause_timer.removeEventListener(TimerEvent.TIMER_COMPLETE,remove_tiles);
}
}
}
Read more : http://www.ehow.com/how_7355693_make-memory-game-flash.html
Find more inspiration, events, and resources on the new Adobe Community
Explore Now