Please someone help me with this code..

hi, i have a big problem trying to figure out how to do this, i get this code somewhere in the net, so it's not me who code this, that's why i got this problem.
this is a MIDlet games, something like gallaga. i like to add some features like the UP and DOWN movement and also i have a problem with his "fire", i can only shoot once after the fire image is gone in the screen, what i liked to have is even i pressed the fire button and press it again the fire will not gone, what i mean continues fire if i pressed everytime the fire button.
i will post the code here so you can see it and give me some feedback. i need this badly, hoping to all you guys! thanks..for this forum.
----CODE BEGIN ---------------
import java.io.IOException;
import java.io.PrintStream;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
public class MobileGalaga extends MIDlet
implements CommandListener, Runnable
class ScoreScreen extends Canvas
public void paint(Graphics g)
g.setColor(0xffffff);
g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
g.setColor(0x160291);
g.setFont(MobileGalaga.fs);
g.drawString("Help", MobileGalaga.CENTERW, 2, 17);
g.setColor(0);
g.drawString("Use left/right and fire", MobileGalaga.CENTERW, 20, 17);
g.drawString("to destory the", MobileGalaga.CENTERW, 30, 17);
g.drawString("incoming alien MobileGalaga", MobileGalaga.CENTERW, 40, 17);
public void keyPressed(int i)
int j = getGameAction(i);
if(j == 8)
display.setCurrent(titlescreen);
ScoreScreen()
class TitleScreen extends Canvas
public void paint(Graphics g)
g.setColor(0xffffff);
g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
g.drawImage(MobileGalaga.logoimg, MobileGalaga.CENTERW, 15, 17);
g.setColor(0);
g.setFont(MobileGalaga.fs);
g.drawString("Press 5 to", MobileGalaga.CENTERW, 43, 17);
g.drawString("see help", MobileGalaga.CENTERW, 53, 17);
public void keyPressed(int i)
int j = getGameAction(i);
if(j == 8)
display.setCurrent(scorescreen);
TitleScreen()
class MainScreen extends Canvas
public void paint(Graphics g)
offg.setColor(0xffffff);
offg.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
for(int i = 0; i < MobileGalaga.slen; i++)
if(!MobileGalaga.dead)
offg.drawImage(MobileGalaga.alienimg[MobileGalaga.frame[i]], MobileGalaga.x[i], MobileGalaga.y[i], 17);
if(!MobileGalaga.playerdead)
offg.drawImage(MobileGalaga.playerimg, MobileGalaga.px, MobileGalaga.py, 17);
} else
if(MobileGalaga.explodeframe < 3)
offg.drawImage(MobileGalaga.explosionimg[MobileGalaga.explodeframe], MobileGalaga.px, MobileGalaga.py, 17);
MobileGalaga.explodeframe++;
if(!MobileGalaga.gameover)
MobileGalaga.playerpause++;
if(MobileGalaga.playerpause < 50)
MobileGalaga.playerpause++;
} else
MobileGalaga.playerdead = false;
MobileGalaga.playerpause = 0;
MobileGalaga.px = MobileGalaga.CENTERW;
offg.setColor(0);
offg.drawString(MobileGalaga.scorestr, MobileGalaga.WIDTH, 0, 24);
offg.drawImage(MobileGalaga.playerimg, 0, 0, 20);
offg.drawString(MobileGalaga.lives + "", 12, 0, 20);
if(MobileGalaga.laser)
offg.drawLine(MobileGalaga.laserx, MobileGalaga.lasery, MobileGalaga.laserx, MobileGalaga.lasery + 4);
if(MobileGalaga.showscores)
for(int j = 0; j < 5; j++)
if(j == MobileGalaga.rank)
offg.setColor(0xff0000);
else
offg.setColor(0);
offg.drawString((j + 1) + " .... " + getScoreStr(MobileGalaga.highscore[j]), MobileGalaga.CENTERW, 20 + j * 10, 17);
if(MobileGalaga.showmessage)
offg.setColor(0xff0000);
offg.drawString(MobileGalaga.msg, MobileGalaga.CENTERW, MobileGalaga.CENTERH, 17);
MobileGalaga.messagepause++;
if(MobileGalaga.messagepause > 20)
MobileGalaga.showmessage = false;
MobileGalaga.messagepause = 0;
if(MobileGalaga.gameover)
MobileGalaga.showscores = true;
else
if(MobileGalaga.wavecomplete)
initWave();
g.drawImage(offimg, 0, 0, 20);
public void keyPressed(int i)
int j = getGameAction(i);
if(j == 2)
MobileGalaga.playerLeft = true;
else
if(j == 5)
MobileGalaga.playerRight = true;
else
if(j == 8)
fireLaser();
public void keyReleased(int i)
int j = getGameAction(i);
if(j == 2)
MobileGalaga.playerLeft = false;
else
if(j == 5)
MobileGalaga.playerRight = false;
private Image offimg;
private Graphics offg;
public MainScreen()
offimg = Image.createImage(getWidth(), getHeight());
offg = offimg.getGraphics();
offg.setFont(MobileGalaga.fs);
public MobileGalaga()
rand = new Random();
display = Display.getDisplay(this);
mainscreen = new MainScreen();
titlescreen = new TitleScreen();
scorescreen = new ScoreScreen();
WIDTH = mainscreen.getWidth();
HEIGHT = mainscreen.getHeight();
CENTERW = WIDTH / 2;
CENTERH = HEIGHT / 2;
exitCommand = new Command("Exit", 7, 1);
playCommand = new Command("Play", 1, 1);
quitCommand = new Command("Quit", 1, 1);
againCommand = new Command("Again", 1, 1);
nullCommand = new Command("", 1, 1);
try
alienimg[0] = Image.createImage("/alien1.png");
alienimg[1] = Image.createImage("/alien2.png");
explosionimg[0] = Image.createImage("/explosion1.png");
explosionimg[1] = Image.createImage("/explosion2.png");
explosionimg[2] = Image.createImage("/explosion3.png");
playerimg = Image.createImage("/player.png");
logoimg = Image.createImage("/logo.png");
catch(IOException ioexception)
db("Couldn't get images!");
imgW = alienimg[0].getWidth();
imgH = alienimg[0].getHeight();
edgeH = imgW / 2;
edgeV = imgH / 2;
pimgW = playerimg.getWidth();
pimgH = playerimg.getHeight();
pedgeH = pimgW / 2;
pedgeV = pimgH / 2;
highscore = getHighScores();
public void run()
while(runner)
rp();
updatePos();
try
MobileGalaga _tmp = this;
Thread.sleep(75L);
catch(InterruptedException interruptedexception)
db("interrupted");
runner = false;
MobileGalaga _tmp1 = this;
Thread.yield();
public void startApp()
throws MIDletStateChangeException
display.setCurrent(titlescreen);
addBeginCommands(titlescreen, false);
addBeginCommands(scorescreen, false);
addPlayCommands(mainscreen, false);
public void pauseApp()
public void destroyApp(boolean flag)
runner = false;
th = null;
private void rp()
mainscreen.repaint();
private void startGame()
initGame();
if(th == null)
th = new Thread(this);
runner = true;
th.start();
private void initGame()
px = CENTERW;
py = HEIGHT - pedgeV - pimgH;
packcount = 0;
lives = 3;
score = 0;
scorestr = "000000";
rank = -1;
difficulty = 400;
wave = 1;
initWave();
private void initWave()
for(int i = 0; i < slen; i++)
frame[i] = i % 2;
x[i] = packX[i] = sposX[i];
y[i] = packY[i] = sposY[i];
dx[i] = packdx = alien_dx_right;
dy[i] = packdy = alien_dy_right;
dxcount[i] = dycount[i] = 0;
pmode[i] = 0;
flying[i] = false;
dead[i] = false;
playerLeft = false;
playerRight = false;
laser = false;
playerdead = false;
showscores = false;
showmessage = false;
gameover = false;
wavecomplete = false;
playerpause = 0;
messagepause = 0;
killed = 0;
private void updatePos()
if(playerLeft)
updatePlayerPos(-2);
else
if(playerRight)
updatePlayerPos(2);
fly = Math.abs(rand.nextInt() % difficulty);
if(fly < slen && !flying[fly] && !dead[fly])
if(x[fly] < CENTERW)
setDX(fly, alien_dx_flyright, 2);
setDY(fly, alien_dy_flyright, 2);
} else
setDX(fly, alien_dx_flyleft, 2);
setDY(fly, alien_dy_flyleft, 2);
flying[fly] = true;
for(int i = 0; i < slen; i++)
if(!dead[i])
if(!flying[i])
if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
changePackDir(alien_dx_left, alien_dy_left);
if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
changePackDir(alien_dx_right, alien_dy_right);
} else
if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
x[i] = packX[i];
y[i] = packY[i];
flying[i] = false;
setDX(i, packdx, 0);
setDY(i, packdy, 0);
if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
playerHit();
if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
alienHit(i);
for(int j = 0; j < slen; j++)
if(!dead[j])
if(framecount == 3)
frame[j] = frame[j] + 1 < 2 ? 1 : 0;
lastx = x[j];
lasty = y[j];
x[j] += dx[j][dxcount[j]];
y[j] += dy[j][dycount[j]];
if(pmode[j] == 0)
dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
} else
if(pmode[j] == 2)
dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
packX[j] += packdx[packcount];
packY[j] += packdy[packcount];
packcount = packcount + 1 < packlen ? packcount + 1 : 0;
framecount = framecount + 1 < 4 ? framecount + 1 : 0;
if(laser)
lasery -= 6;
if(lasery < 0)
laser = false;
private void setDX(int i, int ai[], int j)
if(i == -1)
for(int k = 0; k < slen; k++)
if(!flying[k])
dx[k] = ai;
dxcount[k] = 0;
pmode[k] = j;
} else
dx[i] = ai;
dxcount[i] = 0;
pmode[i] = j;
private void setDY(int i, int ai[], int j)
if(i == -1)
for(int k = 0; k < slen; k++)
if(!flying[k])
dy[k] = ai;
dycount[k] = 0;
pmode[k] = j;
} else
dy[i] = ai;
dycount[i] = 0;
pmode[i] = j;
private void changePackDir(int ai[], int ai1[])
setDX(-1, ai, 0);
setDY(-1, ai1, 0);
packdx = ai;
packdy = ai1;
packcount = 0;
private void updatePlayerPos(int i)
plastx = px;
px += i;
if(px + pedgeH > WIDTH || px - pedgeH < 0)
px = plastx;
private void fireLaser()
if(!laser)
laser = true;
laserx = px;
lasery = py;
private void alienHit(int i)
if(!playerdead)
dead[i] = true;
laser = false;
killed++;
if(flying[i])
score += 200;
else
score += 50;
if(killed == slen)
waveComplete();
scorestr = getScoreStr(score);
private void playerHit()
playerdead = true;
playerpause = 0;
explodeframe = 0;
lives--;
if(lives == 0)
gameOver();
private void waveComplete()
wavecomplete = true;
difficulty -= 100;
if(difficulty < 100)
difficulty = 100;
msg = "WAVE " + wave + " COMPLETE";
messagepause = 0;
showmessage = true;
wave++;
score += 1000 * wave;
scorestr = getScoreStr(score);
private void gameOver()
gameover = true;
msg = "GAME OVER";
for(int i = 0; i < 5; i++)
if(score < highscore[i])
continue;
for(int j = 4; j > i; j--)
highscore[j] = highscore[j - 1];
highscore[i] = score;
rank = i;
break;
setHighScores();
showmessage = true;
messagepause = 0;
addEndCommands(mainscreen, true);
private void addBeginCommands(Displayable displayable, boolean flag)
if(flag)
removeCommands();
displayable.addCommand(playCommand);
displayable.addCommand(exitCommand);
displayable.setCommandListener(this);
private void addPlayCommands(Displayable displayable, boolean flag)
if(flag)
removeCommands();
displayable.addCommand(nullCommand);
displayable.addCommand(quitCommand);
displayable.setCommandListener(this);
private void addEndCommands(Displayable displayable, boolean flag)
if(flag)
removeCommands();
displayable.addCommand(againCommand);
displayable.addCommand(quitCommand);
displayable.setCommandListener(this);
private void removeCommands()
Displayable displayable = display.getCurrent();
displayable.removeCommand(nullCommand);
displayable.removeCommand(quitCommand);
displayable.removeCommand(againCommand);
displayable.removeCommand(playCommand);
displayable.removeCommand(exitCommand);
public void commandAction(Command command, Displayable displayable)
if(command == playCommand)
display.setCurrent(mainscreen);
startGame();
if(command == quitCommand)
runner = false;
while(th.isAlive()) ;
th = null;
addPlayCommands(mainscreen, true);
display.setCurrent(titlescreen);
if(command == againCommand)
runner = false;
while(th.isAlive()) ;
th = null;
display.setCurrent(mainscreen);
addPlayCommands(mainscreen, true);
startGame();
if(command == exitCommand)
destroyApp(false);
notifyDestroyed();
private int[] getHighScores()
int ai[] = new int[5];
ai[0] = 5000;
ai[1] = 4000;
ai[2] = 3000;
ai[3] = 2000;
ai[4] = 1000;
byte abyte0[][] = new byte[5][6];
try
hsdata = RecordStore.openRecordStore("MobileGalaga", true);
int i = hsdata.getNumRecords();
if(i == 0)
for(int j = 0; j < 5; j++)
abyte0[j] = Integer.toString(ai[j]).getBytes();
hsdata.addRecord(abyte0[j], 0, abyte0[j].length);
} else
for(int k = 0; k < 5; k++)
abyte0[k] = hsdata.getRecord(k + 1);
String s = "";
for(int l = 0; l < abyte0[k].length; l++)
s = s + (char)abyte0[k][l] + "";
ai[k] = Integer.parseInt(s);
catch(RecordStoreException recordstoreexception)
db("problem with initialising highscore data\n" + recordstoreexception);
return ai;
private void setHighScores()
byte abyte0[][] = new byte[5][6];
try
hsdata = RecordStore.openRecordStore("MobileGalaga", true);
for(int i = 0; i < 5; i++)
abyte0[i] = Integer.toString(highscore[i]).getBytes();
hsdata.setRecord(i + 1, abyte0[i], 0, abyte0[i].length);
catch(RecordStoreException recordstoreexception)
db("problem with setting highscore data\n" + recordstoreexception);
private String getScoreStr(int i)
templen = 6 - (i + "").length();
tempstr = "";
for(int j = 0; j < templen; j++)
tempstr = tempstr + "0";
return tempstr + i;
public static void db(String s)
System.out.println(s);
public static void db(int i)
System.out.println(i + "");
private Display display;
private Command exitCommand;
private Command playCommand;
private Command quitCommand;
private Command againCommand;
private Command nullCommand;
private MainScreen mainscreen;
private TitleScreen titlescreen;
private ScoreScreen scorescreen;
private static int WIDTH;
private static int HEIGHT;
private static int CENTERW;
private static int CENTERH;
private boolean runner;
private Thread th;
private Random rand;
private static final int RED = 0xff0000;
private static final int ORANGE = 0xff9100;
private static final int YELLOW = 0xffff00;
private static final int WHITE = 0xffffff;
private static final int BLACK = 0;
private static final int BLUE = 0x160291;
private static Image alienimg[] = new Image[2];
private static Image explosionimg[] = new Image[3];
private static Image playerimg;
private static Image logoimg;
private static int imgH;
private static int imgW;
private static int pimgH;
private static int pimgW;
private static int edgeH;
private static int edgeV;
private static int pedgeH;
private static int pedgeV;
private static final Font fs = Font.getFont(64, 0, 8);
private static final Font fl = Font.getFont(64, 1, 16);
private static final int sposX[] = {
16, 28, 40, 52, 4, 16, 28, 40, 52, 64,
4, 16, 28, 40, 52, 64
private static final int sposY[] = {
14, 14, 14, 14, 26, 26, 26, 26, 26, 26,
38, 38, 38, 38, 38, 38
private static final int LOOP = 0;
private static final int ONCE = 1;
private static final int HOLD = 2;
private static final int move_none[] = {
0
private static final int alien_dx_right[] = {
1, 1, 1, 1, 1, 1, 1, 1
private static final int alien_dy_right[] = {
0, 0, 1, 1, 0, 0, -1, -1
private static final int alien_dx_left[] = {
-1, -1, -1, -1, -1, -1, -1, -1
private static final int alien_dy_left[] = {
0, 0, -1, -1, 0, 0, 1, 1
private static final int alien_dx_flyright[] = {
1, 1, 1, 0, -1, -1, -1, -1, -1, 0,
1, 1, 2, 3, 4, 5, 6
private static final int alien_dy_flyright[] = {
0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
1, 1, 2, 3, 4, 5, 6
private static final int alien_dx_flyleft[] = {
-1, -1, -1, 0, 1, 1, 1, 1, 1, 0,
-1, -1, -2, -3, -4, -5, -6
private static final int alien_dy_flyleft[] = {
0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
1, 1, 2, 3, 4, 5, 6
private static final int slen;
private static final int ailen;
private static final int packlen;
private static int pmode[];
private static int x[];
private static int y[];
private static int dx[][];
private static int dy[][];
private static int dxcount[];
private static int dycount[];
private static int frame[];
private static boolean flying[];
private static boolean dead[];
private static boolean exploding[];
private static int lastx;
private static int lasty;
private static int fly;
private static int packX[];
private static int packY[];
private static int packdx[];
private static int packdy[];
private static int packcount;
private static int framecount = 3;
private static int px;
private static int py;
private static int plastx;
private static int score;
private static String scorestr;
private static int lives;
private static int killed;
private static boolean playerdead;
private static int explodeframe;
private static int playerpause;
private static int rank;
private static boolean playerLeft;
private static boolean playerRight;
private static boolean laser;
private static int laserx;
private static int lasery;
private static RecordStore hsdata;
private static int highscore[] = new int[5];
private static boolean showmessage;
private static boolean showscores;
private static boolean gameover;
private static boolean wavecomplete;
private static int messagepause;
private static String msg;
private static int difficulty;
private static int wave;
private static String tempstr;
private static int templen;
static
slen = sposX.length;
ailen = alien_dx_flyright.length;
packlen = alien_dx_right.length;
pmode = new int[slen];
x = new int[slen];
y = new int[slen];
dx = new int[slen][ailen];
dy = new int[slen][ailen];
dxcount = new int[slen];
dycount = new int[slen];
frame = new int[slen];
flying = new boolean[slen];
dead = new boolean[slen];
exploding = new boolean[slen];
packX = new int[slen];
packY = new int[slen];
packdx = new int[packlen];
packdy = new int[packlen];
----END OF CODE ----------------

hi sorry if it's too big! i hope i can explain this very well (you know i only got this code in the net), if you try to run the program in emulator, the and lunch it will it will first display the title screen and if you hit the pressed key 5 it will display help,
so my problem is how to move UP and DOWN and also if i pressed the fire button it will continue to fire. here is the code.
//Code for the Left,Right,UP and Down movement and also the fire
public void keyPressed(int i)
int j = getGameAction(i);
if(j == 2)
MobileGalaga.playerLeft = true; //this is ok
else
if(j == 5)
MobileGalaga.playerRight = true; //this is ok
else
if(j==1)
MobileGalaga.playerUp = true; //i add this only, this has a problem
else
if(j==6)
MobileGalaga.playerDown = true; //i add this only, this has a problem
else
if(j == 8)
fireLaser(); //for the release of fire
//for the release of key pressed
public void keyReleased(int i)
int j = getGameAction(i);
if(j == 2)
MobileGalaga.playerLeft = false;
else
if(j == 5)
MobileGalaga.playerRight = false;
//Update the position base on key pressed
private void updatePos()
if(playerLeft)
updatePlayerPos(-5);
else
if(playerUp)
updatePlayerPos1(-4);
else
if(playerDown)
updatePlayerPos1(4);
else
if(playerRight)
updatePlayerPos(5);
fly = Math.abs(rand.nextInt() % difficulty);
if(fly < slen && !flying[fly] && !dead[fly])
if(x[fly] < CENTERW)
setDX(fly, alien_dx_flyright, 2);
setDY(fly, alien_dy_flyright, 2);
} else
setDX(fly, alien_dx_flyleft, 2);
setDY(fly, alien_dy_flyleft, 2);
flying[fly] = true;
for(int i = 0; i < slen; i++)
if(!dead)
if(!flying[i])
if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
changePackDir(alien_dx_left, alien_dy_left);
if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
changePackDir(alien_dx_right, alien_dy_right);
} else
if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
x[i] = packX[i];
y[i] = packY[i];
flying[i] = false;
setDX(i, packdx, 0);
setDY(i, packdy, 0);
if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
playerHit();
if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
alienHit(i);
for(int j = 0; j < slen; j++)
if(!dead[j])
if(framecount == 3)
frame[j] = frame[j] + 1 < 2 ? 1 : 0;
lastx = x[j];
lasty = y[j];
x[j] += dx[j][dxcount[j]];
y[j] += dy[j][dycount[j]];
if(pmode[j] == 0)
dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
} else
if(pmode[j] == 2)
dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
packX[j] += packdx[packcount];
packY[j] += packdy[packcount];
packcount = packcount + 1 < packlen ? packcount + 1 : 0;
framecount = framecount + 1 < 4 ? framecount + 1 : 0;
if(laser)
lasery -= 6;
if(lasery < 0 )
laser = false;
// this will move the object UP,DOWN,Left and Right
private void updatePlayerPos(int i)
plastx = px;
px += i;
if(px + pedgeH > WIDTH || px - pedgeH < 0)
px = plastx;
private void updatePlayerPos1(int i)
plastx = py;
py += i;
if(px + pedgeV > HEIGHT || px - pedgeV < 0)
px = plastx;
// This will fire, if you hit the fire button
private void fireLaser()
if(!laser)
laser = true;
laserx = px;
lasery = py;
sorry if it's too long i just want too explain this. if anyone like to see this and run so that you can see it also, i can send an email.
thanks,
alek

Similar Messages

  • Can someone help me with this code?

    Hi all,
    I have a Flash component that links to a gallery, and I
    understand that I can create buttons to point to multiple
    galleries. (waiting too long for support from the suppliers)
    The User Guide says that I can use the following to create
    the connection:
    myThumbnailer2.loadGallery(24);
    That won't work, and it says that I need to include it in an
    onclipevent. I have no idea what i am doing and I was hoping
    someone could tell me what to script to get the text button I
    created to run this.
    Help would really be appreciated.
    Hugh

    Hi Hugh,
    You are right in that you can link to other galleries using
    the ID number (but, I assume, only TN2Admin (fCMSPro gallery
    document) defined galleries) with the code supplied.
    I think this may help - I'm a newbie with actionscript and I
    know nothing about Flashloaded so I may be way off beam here,
    but....
    First define a variable, this will be used in the 'show'
    (that's show, not load) gallery element of your code:
    var galNum: Number;
    Make as many buttons as required to launch a gallery (you say
    "each button opening one of several galleries" so I assume you want
    1 gallery per button) and give each an instance name.
    You then write the relevant code for each button function
    (assuming once more that the buttons are in the same frame) using
    the instance name (I use a separate layer in the frame to write
    actionscript and try not to attach code directly to objects - which
    then leads me to say yes you can put all the different buttons code
    in one frame)....
    myLoadGalBtn1.onRelease = function () {
    myThumbnailer2.loadGallery(24);
    galNum = 24;
    myLoadGalBtn2.onRelease = function () {
    myThumbnailer2.loadGallery(25);
    galNum = 25;
    notice the buttons have different instance names (the 1 &
    2 at the end - but you can call them what you like).
    Then you can use other code supplied to actually show the
    gallery (using the variable generated in each button click). Some
    code from Flashloaded will be along the lines of:
    myThumbnailer2.showGallery(25);
    so my guess is you can replace the actual number with the
    variable galNum inside the brackets to use the number generated by
    whatever button was pressed, like:
    myThumbnailer2.showGallery(galNum);
    Cheers
    Kol

  • Could someone help me with this code??

    Hi!, I am really poor at Java, and was given this piece of code to fix. I have no idea why this compiles but does not run and have never dealt with packages either, so I would really appreciate it if someone could tell me what I could do to fix it!!
    package Arrays;
    import java.awt.*;
    import java.awt.event.*;
    *   This class demonstrates a simple application
    *   A rather primitive ATM machine (needs work)
    *   Quite similar to the CashRegister Applet
    public class VirtualATM extends Frame implements ActionListener
         // the "screen"
         TextArea  display = new TextArea(8, 20);
         // some local variables
         private String current    = new String("");
         private double amount     = 0d;
         private double balance = 5000.0;
         private int opCode;
         // op code constants
         static final int PINENTRY   = 0;
         static final int DEPOSIT    = 1;
         static final int WITHDRAWAL = 2;
         // button labels - an array
         String [] btnLabels =
             "1", "2", "3", "Deposit",
             "4", "5", "6", "Withdraw",
             "7", "8", "9", "New Customer",
             "0", ".","Enter","Quit"
    * Default constructor
    public VirtualATM()
         super();
    * Constructor with frame title
    public VirtualATM(String title)
         super(title);
         setSize(400, 400);
         // inner class to detect window closing and make sure
         // quit method is executed before exit, not vital in
         // this case but a good habit to get into
         addWindowListener(new WindowAdapter()
              public void windowClosing(WindowEvent e)
                   quit();
         // set up the display
         int nButtons = btnLabels.length;
         Panel keypad = new Panel();
         keypad.setLayout(new GridLayout(4, 4, 5, 5));
         Button[] keys = new Button[nButtons];
         for (int i = 0; i < nButtons; i++)
              keys[i] = new Button(btnLabels);
              keypad.add(keys[i]);
              keys[i].addActionListener(this);
              keys[i].setActionCommand(btnLabels[i]);
         setLayout(new GridLayout(2, 1, 10, 10));
         display.setEditable(false);
         add(display);
         add(keypad);
         setVisible(true);
         startup();
    * Check the button presses
    public void actionPerformed(ActionEvent e)
         String command = e.getActionCommand();
         char com = command.charAt(0);
         // see if the character is part of a number:
         if ((com >= '0') && (com <= '9') || (com == '.'))
              doNumber(com);
         else
              // check here for function buttons
              switch (com)
                   case 'D' :
                   current = "";
                        deposit();
                        break;
                   case 'W' :
                   current = "";
                        withdraw();
                        break;
                   case 'N' :
                        startup();
                        break;
                   case 'E' :
                        processOperation();
                        break;
                   case 'Q' :
                        quit();
                        break;
    * This method prompts for a deposit
    public void deposit()
         opCode = DEPOSIT;
         display.append("\nPlease enter amount to deposit: ");
    * This method processes number button presses
    * Could add PIN validation
    public void doNumber(char com)
         current += com;
         if (opCode == PINENTRY)
              display.append("*");
         else
              display.append("" + com);
    * This method does the processing!
    public void processOperation()
         amount = toDouble(current);
         switch (opCode)
              case PINENTRY :
                   display.setText("Please choose a transaction");
                   break;
              case DEPOSIT :
                   if (amount > 0.0)
                        balance += amount;
                        display.setText("Thank you, your new balance is: " + balance);
                   else
                        display.setText("You cannot deposit " + amount);
                   break;
              case WITHDRAWAL :
                   if (amount <= balance)
                        balance -= amount;
                        display.setText("Thank you, your new balance is: " + balance);
                   else
                        display.setText("You cannot withdraw " + amount);
                   break;
    * This method quits
    public void quit()
         System.exit(0);
    * This method sets up for a new customer
    public void startup()
         display.setText("Welcome to Virtual Banking with VOB\n\n");
         display.append("Please enter your PIN: ");
         amount = 0.0;
         current = "";
         balance = 5000.00;
         opCode = PINENTRY;
    * converts a string to a double
    private double toDouble(String s)
         double theValue = -1.0;
         try
              if (s != "")
                   Double d = new Double(s);
                   theValue = d.doubleValue();
         catch (NumberFormatException n)
              current = "";
         finally
              return theValue;
    * This method prompts for a withdrawal
    public void withdraw()
         opCode = WITHDRAWAL;
         display.append("\nPlease enter amount to withdraw: ");
    class main{
         * Initialises the Application
         * Creation date: (07-Dec-00 23:10:49)
         public static void main(String[] args)
              VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

    That sounds like a path or classpath issue issue. There are some instructions here for windows systems...
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
    Basically you want to set your path to where your java.exe file is.
    You can probably run it like this though (if you are in the dir where your ATM class is and you put the path where your jdk is installed):
    D:\jdk1.3\bin\java VirtualATM
    Here is the code, changed (note that this forum tends to screw up the code a little):
    package Arrays;
    import java.awt.*;
    import java.awt.event.*;
    * This class demonstrates a simple application
    * A rather primitive ATM machine (needs work)
    * Quite similar to the CashRegister Applet
    public class VirtualATM extends Frame implements ActionListener
    // the "screen"
    TextArea display = new TextArea(8, 20);
    // some local variables
    private String current = new String("");
    private double amount = 0d;
    private double balance = 5000.0;
    private int opCode;
    // op code constants
    static final int PINENTRY = 0;
    static final int DEPOSIT = 1;
    static final int WITHDRAWAL = 2;
    // button labels - an array
    String [] btnLabels =
    "1", "2", "3", "Deposit",
    "4", "5", "6", "Withdraw",
    "7", "8", "9", "New Customer",
    "0", ".","Enter","Quit"
    * Default constructor
    public VirtualATM()
    super();
    * Constructor with frame title
    public VirtualATM(String title)
    super(title);
    setSize(400, 400);
    // inner class to detect window closing and make sure
    // quit method is executed before exit, not vital in
    // this case but a good habit to get into
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    quit();
    // set up the display
    int nButtons = btnLabels.length;
    Panel keypad = new Panel();
    keypad.setLayout(new GridLayout(4, 4, 5, 5));
    Button[] keys = new Button[nButtons];
    for (int i = 0; i < nButtons; i++)
    keys[i] = new Button(btnLabels);
    keypad.add(keys[i]);
    keys[i].addActionListener(this);
    keys[i].setActionCommand(btnLabels[i]);
    setLayout(new GridLayout(2, 1, 10, 10));
    display.setEditable(false);
    add(display);
    add(keypad);
    setVisible(true);
    startup();
    * Check the button presses
    public void actionPerformed(ActionEvent e)
    String command = e.getActionCommand();
    char com = command.charAt(0);
    // see if the character is part of a number:
    if ((com >= '0') && (com <= '9') || (com == '.'))
    doNumber(com);
    else
    // check here for function buttons
    switch (com)
    case 'D' :
    current = "";
    deposit();
    break;
    case 'W' :
    current = "";
    withdraw();
    break;
    case 'N' :
    startup();
    break;
    case 'E' :
    processOperation();
    break;
    case 'Q' :
    quit();
    break;
    * This method prompts for a deposit
    public void deposit()
    opCode = DEPOSIT;
    display.append("\nPlease enter amount to deposit: ");
    * This method processes number button presses
    * Could add PIN validation
    public void doNumber(char com)
    current += com;
    if (opCode == PINENTRY)
    display.append("*");
    else
    display.append("" + com);
    * This method does the processing!
    public void processOperation()
    amount = toDouble(current);
    switch (opCode)
    case PINENTRY :
    display.setText("Please choose a transaction");
    break;
    case DEPOSIT :
    if (amount > 0.0)
    balance += amount;
    display.setText("Thank you, your new balance is: " + balance);
    else
    display.setText("You cannot deposit " + amount);
    break;
    case WITHDRAWAL :
    if (amount <= balance)
    balance -= amount;
    display.setText("Thank you, your new balance is: " + balance);
    else
    display.setText("You cannot withdraw " + amount);
    break;
    * This method quits
    public void quit()
    System.exit(0);
    * This method sets up for a new customer
    public void startup()
    display.setText("Welcome to Virtual Banking with VOB\n\n");
    display.append("Please enter your PIN: ");
    amount = 0.0;
    current = "";
    balance = 5000.00;
    opCode = PINENTRY;
    * converts a string to a double
    private double toDouble(String s)
    double theValue = -1.0;
    try
    if (s != "")
    Double d = new Double(s);
    theValue = d.doubleValue();
    catch (NumberFormatException n)
    current = "";
    finally
    return theValue;
    * This method prompts for a withdrawal
    public void withdraw()
    opCode = WITHDRAWAL;
    display.append("\nPlease enter amount to withdraw: ");
    * Initialises the Application
    * Creation date: (07-Dec-00 23:10:49)
    public static void main(String[] args)
    VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

  • Please someone help me with this or other wise im gonna return my ipod

    please a little help here. i've been trying this since last night and still i cant figure it out. my music videos don't have any sound at all. i've chequed the volume and the settings and still cant hear anything its driving me crazy!!

    Quicktime, Quicktime Pro and iTunes don't convert "muxed" ( muxed means multiplexed where the audio and video are stored on the same track) video files properly. It only plays the video and not the audio.
    See:iPod plays video but not audio.
    You need a 3rd party converter to convert the file with both audio and video.
    Search this forum for recommendations, but beware of spammers trying to sell you their own product.

  • Please! help me with this wrong code, where is mistake

    please! help me with this wrong code, where is mistake?
    import java.util.Stack;
    public class KnightsTour {
    Vars locs[];
    private int size, max=1, d=0, board[][];
    public KnightsTour(int x,int y, int newSize)
         size=newSize;
         locs=new Vars[size*size+1];
         for(int n=1;n<=size*size;n++)
              locs[n]=new Vars();
         board=new int[size+1][size+1];
         for(int n=1;n<=size;n++)
              for(int n2=1;n2<=size;n2++)
                   board[n][n2]=0;
         locs[max].x=x;
         locs[max].y=y;
         locs[max].d=1;
         board[x][y]=max;
         max++;
    class Vars{
         int x;
         int y;
         int d;
    public void GO()
         int n=0;
         while(max<=size*size)
              n++;
              d++;
              if(d>8)
                   max--;
                   board[locs[max].x][locs[max].y]=0;
                   d=locs[max].d+1;
              move();
         printBoard();
    public void move()
         int x=locs[max-1].x, y=locs[max-1].y;
         switch(d)
         case 1:x--;y-=2;break;
         case 2:x++;y-=2;break;
         case 3:x+=2;y--;break;
         case 4:x+=2;y++;break;
         case 5:x++;y+=2;break;
         case 6:x--;y+=2;break;
         case 7:x-=2;y++;break;
         case 8:x-=2;y--;break;
         //System.out.println(" X: "+x+" Y: "+y+" |"+max);
         if((x<1)||(x>size)||(y<1)||(y>size)){}
         else if(board[x][y]!=0){}
         else
              locs[max].x=x;
              locs[max].y=y;
              locs[max].d=d;
              board[x][y]=max;
              max++;
              d=0;
              //printBoard();
    public void printBoard()
         for(int n=1;n<=size;n++)
              for(int n2=1;n2<=size;n2++)
                   if(board[n2][n]<10)
                        System.out.print(board[n2][n]+" ");
                   else
                        System.out.print(board[n2][n]+" ");
              System.out.println();
         //System.out.println();
         System.out.println();
         public static void main (String[]args){
              KnightsTour k = new KnightsTour(1,1,8);
         }

    public class KnightsTour {
        Vars locs[];
        private int size,  max = 1,  d = 0,  board[][];
        public static void main (String[] args) {
            KnightsTour k = new KnightsTour (1, 1, 8);
            k.GO ();
        public KnightsTour (int x, int y, int newSize) {
            size = newSize;
            locs = new Vars[size * size + 1];
            for (int n = 1; n <= size * size; n++) {
                locs[n] = new Vars ();
            board = new int[size + 1][size + 1];
            for (int n = 1; n <= size; n++) {
                for (int n2 = 1; n2 <= size; n2++) {
                    board[n][n2] = 0;
            locs[max].x = x;
            locs[max].y = y;
            locs[max].d = 1;
            board[x][y] = max;
            max++;
        class Vars {
            int x;
            int y;
            int d;
        public void GO () {
            int n = 0;
            while (max <= size * size) {
                n++;
                d++;
                if (d > 8) {
                    max--;
                    board[locs[max].x][locs[max].y] = 0;
                    d = locs[max].d + 1;
                move ();
            printBoard ();
        public void move () {
            int x = locs[max - 1].x, y = locs[max - 1].y;
            switch (d) {
                case 1:
                    x--;
                    y -= 2;
                    break;
                case 2:
                    x++;
                    y -= 2;
                    break;
                case 3:
                    x += 2;
                    y--;
                    break;
                case 4:
                    x += 2;
                    y++;
                    break;
                case 5:
                    x++;
                    y += 2;
                    break;
                case 6:
                    x--;
                    y += 2;
                    break;
                case 7:
                    x -= 2;
                    y++;
                    break;
                case 8:
                    x -= 2;
                    y--;
                    break;
    //System.out.println(" X: "x" Y: "y" |"+max);
            if ((x < 1) || (x > size) || (y < 1) || (y > size)) {
            } else if (board[x][y] != 0) {
            } else {
                locs[max].x = x;
                locs[max].y = y;
                locs[max].d = d;
                board[x][y] = max;
                max++;
                d = 0;
    //printBoard();
        public void printBoard () {
            for (int n = 1; n <= size; n++) {
                for (int n2 = 1; n2 <= size; n2++) {
                    if (board[n2][n] < 10) {
                        System.out.print (board[n2][n] + " ");
                    } else {
                        System.out.print (board[n2][n] + " ");
                System.out.println ();
    //System.out.println();
            System.out.println ();
    }formatting ftw.
    If you call GO () you get in an infinite loop. max gets decreased, and it loops while max is smaller then or equal to size * size. Is your looping logic correct ?

  • I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    Hello zukafu, 
    Welcome to the forums. 
    In this case we can try to reload the software on the BlackBerry® smartphone to make sure it is running the latest version and there are no issues with the OS.
    Here is how to backup your BlackBerry smartphone http://bbry.lv/oPVWXc
    Once you have backed up your BlackBerry smartphone please follow the link below to complete a clean reload of the BlackBerry smartphone software.
    Link: http://www.blackberry.com/btsc/KB03621
    Once completed test it and proceed with a selective restore, here is how to restore http://bbry.lv/qgQxLo
    Thank you
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Can somebody help me with this code?

    Can anyone help me with this code? My problem is that i can't
    seem to position this form, i want to be able to center it
    vertically & horizontally in a div either using CSS or any
    other means.
    <div id="searchbar"><!--Search Bar -->
    <div id="searchcart">
    <div class="serchcartcont">
    <form action='
    http://www.romancart.com/search.asp'
    name="engine" target=searchwin id="engine">
    <input type=hidden value=????? name=storeid>
    <input type=text value='' name=searchterm>
    <input type=submit value='Go'> </form>
    </div>
    </div>
    <div class="searchcont">Search For
    Products:</div>
    </div><!-- End Search Bar -->
    Pleasssssseeeeeeee Help
    Thanks

    Hi,
    Your form is defined in a div named "serchcartcont", you can
    use attributes like position and align of the div to do what you
    want to do. But there are two more dives above this dive, you will
    have define the height width of these before you can center align
    the inner most div. If you are not defining the height & width
    then by default it decide it automatically to just fit the content
    in it.
    Hope this helps.
    Maneet
    LeXolution IT Services
    Web Development
    Company

  • I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Go to Settings>iTunes and App stores and sign out and sign back in
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.      

  • The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    FYI: It seems it was a network problem with my WinXP PC. After complete deletion and new installation of XP and iTunes my iPhone will be recognized correctly, Wifi synchronization works (mostly) fine.

  • HT5655 I followed all the instructions to update Flash Player, but the installation fails at around 90%, it says that there is an Application running (Safari) bit I actually close all Apps. already. can someone help me with this issue ?? Thanks

    I have followed the instructions to update Flash Player, the Installation Fails at about 90%, it says that there is an Application running (Safari) and it says to close all the apps. and start again ... but I already close all the Applications ... none is running ... can someone help me with this issue ??? Thanks ...

    Dear Dominic
    Brilliant reply. Simple English. Simple to follow instructions. And it worked immediately, first time.
    Why couldn't the Apple and Adobe corporations get their programming right first time? We spend billions of UK pounds and US dollars with them. They reply with incompetent programming such as this, and arrogance to their customers in issuing faulty systems without doing the most rudimentary checks.
    Anyway, I certainly shan't be buying another Apple as this is the most unreliable, most incomprehensible, most illogical and downright thoughtless shoddy piece of computer kit which I have ever owned. And all of it is rubbish ~ emails disappear, photos can't be organised properly, spreadsheets don't work, Pages is laborious… the list goes on and on...
    But thanks to you Dominic, I have been able to load Adoble Flashj… maybe eyou should get  a job at Apple, and set them all on the right course to how to work simply and correctly with customers.
    Thanks again,
    David

  • After the OS 6 update my speaker does not work. My music plays but no sound comes out. Can someone help me with this issue? I currently have the 4S.

    After the OS 6 update my speaker does not work. Volume control on the side does not adjust the volume either. My music plays but no sound comes out. Can someone help me with this issue? I've tried rebooting my phone but still no sound comes out. I currently have the 4S.

    try to activate and desactivate the airplne switch a couple of time

  • HT1494 hi....i  cant continuously play my music with my ipod nano....i tried a lot with the settings for wake time but still it is pausing the music path.Please anybody help me with this issue

    hi....i  cant continuously play my music with my ipod nano....i tried a lot with the settings for wake time but still it is pausing the music path.Please anybody help me with this issue

    Is this your problem?
    iPod nano (6th generation): Music stops when display turns off
    B-rock

  • TS2755 Whenever I send a message to another iPhone user via iMessage it is sending my Apple ID instead of my phone number.  Could someone help me with this??

    Whenever I send a message to another iPhone user via iMessage it is sending my Apple ID instead of my phone number. Could someone help me with this???

    Check this article: iOS: About Messages
    Additional Information
    You can change your iMessage Caller ID setting on iOS devices in Settings > Messages > Receive At > Caller ID. Note that the Caller ID setting is used only for new conversations. If you would like to change the address from which messages are sent, first change your Caller ID, and then delete the existing conversation and start a new one.
    iMessage responses will be sent from the address the recipient most recently messaged. For example, on iPhone you can receive messages sent to your Apple ID and phone number. A friend sends you a message to your Apple ID. Responses in this conversation will be sent from your Apple ID, even if your Caller ID is set to your phone number.

  • Yesterday for the first time i turned on my macpro 2011 model and i got a crazy gray screen with lines all over it ,so i held down the power button and turn off then restarted and all was ok could someone help me with this,what caused this shut down. werd

    yesterday for the first time i turned on my macpro 2011 model and i got a crazy gray screen with lines all over it ,so i held down the power button and turn off then restarted and all was ok could someone help me with this,what caused this shut down. werd

    Are the lines like psychedelic herringbone?  If yes, I had that happen once, it was something serious, like the
    Logic board. The good news is that it was fixed without any loss of data on the hard drive. Take it in to have Apple look at it ASAP.  I took it to TekServe at the time, they are very nice about preserving your data and user library when possible.
    Good luck and don't panic.

  • My fonts are changing in iWed after I publish. I need step by step instructions on how to go to my third party server and clear out all of my files and reload my whole website, the solution I saw posted by another. Please someone help me on this. Urgent

    My fonts are changing in iWed after I publish. I need step by step instructions on how to go to my third party server and clear out all of my files and reload my whole website, the solution I saw posted by another. Please someone help me on this. Urgent

    If your fonts are changing when viewed on other computers - epecially those running windows - you need to look at using web-safe fonts...
    http://www.iwebformusicians.com/iWeb/Fonts-Colors.html
    Also make sure you clear your browser cache before viewing you published files.

Maybe you are looking for

  • How do i control my kids access

    I want to be able to contol the times or when my kids have access to the internet on their ipads. Is there any way to set up times or limit access through the airport   express?

  • Database Structure Q:

    I'm designing a web application that acts as business management software for many small autobody shops.  This method was chosen because it creates a central point of administration for the software and I believe that a properly configured cluster of

  • Error in Date Field

    Hi all, We had a delta load failure yesterday due to an incorrect date filed in R/3. The date in R/3 was entered as 09/29/0606 instead of 09/29/2006. I guess there are more than one record that have this problem. I want to know if there is a possibil

  • Thunderbird and Firefox

    I'm not sure if I understand 100% of what I'm asking, but here it goes. I'm pulling Firefox 1.5 and Thunderbird 1.0.7 from the Arch repositories.  Now, in order to get Thunderbird to open URLs from e'mails using Firefox browser, I had to add the foll

  • Time Machine won't work with mountain lion

    Since upgrading my MacBook to Mountain Lion the Time Machine back up does not work The MacBook sees the TM and if I ask it to back up it "prepares the backup" but then after a while nothing happens.  The last recorded back up is before the update. We