Need a bit of help with a code

Hello adobe community!
i have been fiddling around with FLASH MX and have been making a game VERY slowly.
i've picked up alot since starting and have restarted making said game MANY MANY times =D...
But i have now got a copy that is neat and clean and works really well BUT i've come into a bit of a problem.
i have  _global.goldenticket = 0;   on my first frame along with other variables and i have made a single location where one can aquire a "goldenticket".
now things are starting to confuse me... ive added a button inside a movie clip which if clicked "should" check if i have a golden ticket and then allow me to jump to the frame specified...
on(release){
if(goldenticket=="1"){
money -= 50;
energy -=50;
_root.gotoAndPlay("enter");
}else{
this.enabled=false;
however the button doesnt seem to see my ticket (even tho ive added a dynamic textbox to keep track of how many i have, which is 1)
ive tried many different ways to go around this but i cannot seem to get it to work...
please someone help me... in relativly simple answers please =\ im only a few days into flash learning and codeing. but im enjoying what im doing so im learning quickly.
will have my face to the screen in waiting =D
Thank you to everyone who took a look at my thread!

THANK YOU!!!
REALLY quick response WITH lang i could easily understand...
mate thank you haha been wrapping my brain for hours on end with other things didnt even occure to me to slap _global infront.

Similar Messages

  • Need a bit of help with css and fullscreen

    I am currently doing a javaFX application for my university project, I have it everything nearly finished, but need to finish the css component to make the application "prettier" (I am not very good on graphic design to be honest). So if i could get a bit of help on this little issue I'd be very grateful.
    is there any way to make fullscreen (and if possible resizing window) to instead rearranging everything to actually do a fullscreen (like the games) and everything "grows accordingly (even though in games what it usually does is to change the screen resolution, is that possible to reproduce with javaFX?) also how to remove the message and the effect on click the "esc" key to exit the fullscreen mode?
    i know that removing the focus effect on an element is with the following (if a button)
    .button:focused{
         -fx-background-insets: 0;
    }but,is there any way to remove the effect on anything focused (TextField, Combo Box, ...)? (tried with a .textfield:focused but it did not work)
    also i wanted to produce the focused effect by this way but it didn't work, how should i do it? (in fact even if i try to put this line on the button:focused, the focused effect gets removed from there, because of the insets line)
    #highlight{
         -fx-background-insets: 2;
         -fx-background-color: yellow;
    public class controller extends StackPane implements Initializable{
         public void highlight(){
              this.getStyleClass().add("highlight");
    and last thing (for the moment) the .button seems to work for all the buttons, but trying another thing like .gridpane or .textfield or .scrollpane does not seem to work, is there any way to make it work or i should add "id" to all the elements and use the # instead?

    i wrote all them in the same thread becsause there were a total of 4 (and could had been more) separated by ----
    should i leave it how it is or open now 4 threads for each question?

  • Need a bit of help with Jumping in a game

    I making an action game (at least for the sake of this question) and when the user presses the spacebar the character jumps. The problem is, if the character is moving right or left, and jumps while he is moving, he will stop moving in mid-air (if the spacebar is released) and just drop straight down. Example:
    press right arrow key
    player moves right
    press space while pressing arrow key
    player jumps
    let go of spacebar
    player drops straight down (does not continue to move right) //Problem
    It's pretty simple code, actually:
    /* Move player left or right */
    if (pressedRight)
            player.x_pos += player.x_speed;
    else if (pressedLeft)
            player.x_pos -= player.x_speed;
    /* If spacebar is pressed */
    if (pressedSpace && !player.moveUp)
            player.moveUp = true;
            player.y_speed = player.INITIALSPEED;
    /* if you are in "jump mode" */                         
    if (player.moveUp)
            player.y_pos += player.y_speed;
            player.y_speed += .25;
            if (player.y_pos >= TheGround)
                      player.moveUp = false;
                      player.y_speed = 0;
    public boolean keyDown(Event e, int key)
            if(key==Event.LEFT)
                      pressedLeft = true;
            if(key==Event.RIGHT)
                      pressedRight=true;
            if(key==Event.UP)
                      pressedUp=true;
            if(key==Event.DOWN)
                      pressedDown=true;
            if (key ==  ' ')
                      pressedSpace = true;
            repaint();
            return true;
    public boolean keyUp(Event e, int key)
            pressedLeft=false;
            pressedRight = false;
            pressedSpace = false;
            repaint();
            return true;
    }

    Run this code and you'll see what I'm talking about:
    import java.awt.*;
    import java.applet.*;
    public class Testing extends Applet implements Runnable
        Thread runner;
        private Image Buffer;
        private Graphics gBuffer;
        final int theGround = 205;
         boolean pressedLeft, pressedRight, pressedSpace;
         final int width = 10, height = 10;
         final int INITIALSPEED = -5;
         double x_pos = 100;
         double y_pos = 190;
         boolean moveUp = false;
         double y_speed = 3;
         double x_speed = 3;
        //Init is called first, do any initialisation here
        public void init()
            //create graphics buffer, the size of the applet
            Buffer=createImage(size().width,size().height);
            gBuffer=Buffer.getGraphics();
        public void start()
            if (runner == null)
                runner = new Thread (this);
                runner.start();
        public void stop()
            if (runner != null)
                runner.stop();
                runner = null;
        public void run()
            while(true)
                 /* MAIN CODE*/
                //Thread sleeps for 15 milliseconds here
                try {runner.sleep(15);}
                catch (Exception e) { }
                //paint background blue
                gBuffer.setColor(Color.blue);
                gBuffer.fillRect(0,0,size().width,size().height);
                   if (pressedRight)
                        x_pos += 1;
                   else if (pressedLeft)
                        x_pos -= 1;
                   if (pressedSpace && !moveUp)
                        moveUp = true;
                        y_speed = INITIALSPEED;
                   if (moveUp)
                        y_pos += y_speed;
                        y_speed += .15;
                        if (y_pos + height + y_speed >= theGround)
                             moveUp = false;
                             y_speed = 0;
                Draw();
                repaint();
        //is needed to avoid erasing the background by Java
        public void update(Graphics g)
            paint(g);
        public void paint(Graphics g)
            g.drawImage (Buffer,0,0, this);
        public boolean keyDown(Event e, int key)
            if(key==Event.LEFT)
                pressedLeft = true;
            if(key==Event.RIGHT)
            pressedRight=true;
            if (key ==  ' ')
                 pressedSpace = true;
            repaint();
            return true;
        public boolean keyUp(Event e, int key)
            pressedLeft=false;
            pressedRight = false;
            pressedSpace = false;
            repaint();
            return true;
        public void Draw()
              gBuffer.setColor(Color.green);
              gBuffer.fillOval((int)x_pos,(int)y_pos,width,height);
              gBuffer.setColor(Color.yellow);
              gBuffer.drawLine(0, 200, 500, 200);
              gBuffer.drawString(("Move right/left, press space, and it will stop and fall straight down! Why?"), 10, 20);
              gBuffer.drawString(("Hold the spacebar down and it will work like it should."), 10, 30);
              gBuffer.drawString(("ALSO, move left or right then *QUICKLY* release and move in the opposite direction."), 10, 50);
                   gBuffer.drawString(("-- You should see it pause for a second. Why is that?"), 10, 60);
    }Sorry for some reason the tabs get messed up when I cut and pate it from JCreator. :P
    PLEASE HELP!
    Thanks in advance.

  • I need a "bit" of help with an 8 Puzzle

    My current situation is that I need to create a working 8 puzzle with Java using a GUI. What I've currently done is at http://nale.f2g.net/EightPuzzle.java . My main problem is that when running it I get a NullPointerException at the line containing tile[blankPos].setText(tile[ndx].getText()); in the swap method.

    I get a NPE when ever I use the scramble() method.
    The source is the line move(rand.nextInt(4)); .Your Random rand is not instantiated nowhere. Thus it is naturally null.
    Make rand in the constructor.
    Here's a simpler one. You could use random swap() calls for moving/shuffling/scrambling.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.util.Random;
    public class ObjectOrientedEightPuzzle extends JFrame implements MouseListener{
      private Piece[] tile;
      private Border etched = BorderFactory.createEtchedBorder();
      private Color tileColor = Color.GRAY;
      private Color blankColor = Color.GREEN;
      private String[] label = {"1", "2", "3", "4", "", "5", "6", "7", "8"};
      private JPanel pane;
      public ObjectOrientedEightPuzzle(){
        setTitle("ObjectOrientedEightPuzzle");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pane = (JPanel)getContentPane();
        pane.setLayout(new GridLayout(3,3));
        setResizable(false);
        setSize(400, 400);
        tile = new Piece[label.length];
        for(int ndx = 0; ndx < label.length; ndx++){
          tile[ndx] = new Piece(label[ndx], new Position(ndx));
          tile[ndx].addMouseListener(this);
          pane.add(tile[ndx]);
      public void mouseClicked(MouseEvent e){
        Piece p = (Piece)e.getSource();
        Piece blank = blankPos();
        swap(p, blank);
      public void mousePressed(MouseEvent e){
      public void mouseReleased(MouseEvent e){
      public void mouseEntered(MouseEvent e){
      public void mouseExited(MouseEvent e){
      private void swap(Piece clickp, Piece blankp){
        int i = -1;
        int[] pa;
        int b = blankp.getPosition().getPos();
        pa = clickp.getPosition().getNeighbor();
        for (int p = 0; p < pa.length; ++p){
          if (pa[p] == b){
            i = p;
            break;
        if (i != -1){
          blankp.setText(clickp.getText());
          clickp.setText("");
      private Piece blankPos(){
        int ndx;
        for(ndx = 0; ndx < label.length; ndx++){
          if(tile[ndx].getText().equals("")){
            break;
        return tile[ndx];
      public static void main(String[] args){
        ObjectOrientedEightPuzzle puzzle = new ObjectOrientedEightPuzzle();
        puzzle.setVisible(true);
      // represent the position in the array/grid
      class Position{ // 0 ... 8
        int pos;
        int[] neighbor;
        public Position(int p){
          setPos(p);
        public int getPos(){
          return pos;
        public void setPos(int p){
          pos = p;
          setNeighbor(pos);
        public int[] getNeighbor(){
          return neighbor;
        private void setNeighbor(int p){
          switch (p){
            case 0:
              neighbor = new int[2];
              neighbor[0] = 1;
              neighbor[1] = 3;
              break;
            case 1:
              neighbor = new int[3];
              neighbor[0] = 0;
              neighbor[1] = 2;
              neighbor[2] = 4;
              break;
            case 2:
              neighbor = new int[2];
              neighbor[0] = 1;
              neighbor[1] = 5;
              break;
            case 3:
              neighbor = new int[3];
              neighbor[0] = 0;
              neighbor[1] = 4;
              neighbor[2] = 6;
              break;
            case 4:
              neighbor = new int[4];
              neighbor[0] = 1;
              neighbor[1] = 3;
              neighbor[2] = 5;
              neighbor[3] = 7;
              break;
            case 5:
              neighbor = new int[3];
              neighbor[0] = 2;
              neighbor[1] = 4;
              neighbor[2] = 8;
              break;
            case 6:
              neighbor = new int[2];
              neighbor[0] = 3;
              neighbor[1] = 7;
              break;
            case 7:
              neighbor = new int[3];
              neighbor[0] = 4;
              neighbor[1] = 6;
              neighbor[2] = 8;
              break;
            case 8:
              neighbor = new int[2];
              neighbor[0] = 5;
              neighbor[1] = 7;
              break;
            default:
              throw new IllegalArgumentException(String.valueOf(p));
      // represent the piece of the game == a JLabel disguised
      class Piece extends JLabel{
        private int value;
        private Position pos;
        private String ptext;
        public Piece(String s, Position p){
          super(s);
          setBorder(etched);
          setVerticalAlignment(CENTER);
          setHorizontalAlignment(CENTER);
          setFont(new Font("Courier", Font.BOLD, 30));
          setOpaque(true);
          ptext = s;
          pos = p;
          if (s.equals("")){
            setBackground(blankColor);
          else{
            setBackground(tileColor);
          try{
            value = Integer.parseInt(s);
          catch (NumberFormatException e){
            value = -1;
        public int getValue(){
          return value;
        public Position getPosition(){
          return pos;
        public String getText(){
          return ptext;
        public void setText(String t){
          ptext = t;
          if (t.equals("")){
            setBackground(blankColor);
          else{
            setBackground(tileColor);
          super.setText(t);
        public void setValue(int val){
          value = val;
          ptext = String.valueOf(val);
          if (val < 0){
            ptext = "";
          setText(ptext);
          if (value > 0){
            setBackground(tileColor);
          else{
            setBackground(blankColor);
    }

  • Need a bit of help with some theory...

    I'm just looking over some past paers for my exam and I'm having trouble understanding exactly what this question is asking for:
    What is an Enterprise computer system? Give an example of an Enterprise system. Critically discuss two alternative development environments that could be used to develop such a system. Suggest which development environment you would choose to develop the example enterprise system you have suggested and why.
    I'm just sure exactly what it means by development enviroments, does it mean a program like JDeveloper? A couple of examples would be really handy
    Thanks

    Think of an Enterprise computer system as nothing more than a resouce pool. A pool of database connections, persistant database objects, mail sessions, messaging sessions. Basically any resouce a developer would need to develop any type of application.
    As for environments... the two I think of are Microsoft .NET and Sun's Java System Application Server Platform. Thay are basically the same in concept, microsoft just repackaged everything good about Java and called it .NET. .NET is (of course) dependant on the Microsoft OS platform, Sun/Java is not.

  • I need a bit of help with my 7600GT

    Alright.
    My motherboard doesn't have a VGA slot, and neither does this Video Card.  I understand that it is remedied with the adapters that are provided, but one must install the drivers for the DVI slots before one can do anything.  I can't get any output on my monitor with the adapters because I can't see what's going on to install the drivers.  I managed to install Windows by taking out my hard drive and putting it into another computer (SATA drive, btw) and I would have done the same with my video card if it weren't for the fact that no other computers in my house have PCI-E slots. 
    Is there any way to get the drivers onto this hard drive without having to search around town for a computer with both a SATA and a PCI-E slot?
    Thanks!

    iamquitethen00b,
    Moan Guide
    Richard

  • I need a bit of help with my iPhone 4...

    I just backed up my phone and I'm trying to update it to iOS 7.0.4. but when I updated my ipod, everything got deleted off of it. I don't want that to happen to my phone even though I know it probably will. If I restore my iPhone and then restore backup AFTER I update my phone, will I get everything back?
    Also, will everything actually be deleted or could I find them somewhere on my laptop?

    iamquitethen00b,
    Moan Guide
    Richard

  • Need a little bit of help with substring...

    Im very new at java programming, and need a bit of help with a problem:
    Here is what I have:
    System.out.print("Enter a string : ");
    Scanner scan = new Scanner (System.in);
    stringy = scan.nextLine();
    Now I want to split the string "stringy" like this: h:hi:hip:hipp:hippo
    I know this uses substring, but I can't figure out how to do it.
    Any help would be great, thanks!

    I know about the length method, what I dont knowis
    how to use the length and substring methodstogether
    to solve the problem i mentioned initially. There are three ingredients to perform this task:
    - String.length()
    - String.substring(int start, int end)
    - for-statement:
    http://java.sun.com/docs/books/tutorial/java/nutsandbo
    lts/for.html
    Pseudo code:IN <- input String from user
    LOOP FROM 0 -> IN.length()
    print IN.substring(?, ?)
    print ":"
    END LOOP
    Remember, Im very new. ;)Remember that by just handing you the solution, you
    will learn far less than finding things out by
    yourself.
    ; )Thanks a lot, i should be able to figure it out froom the pseudo code. :)

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • Need help with WMI code that will send output to db

    'm new to WMI code writing, so I need some help with writing code that we can store on our server. I want this code to run when a user logs into their computer
    and talks to our server. I also want the code to:
    * check the users computer and find all installed patches
    * the date the patches were installed
    * the serial number of the users computer
    * the computer name, os version, last boot up time, and mac address
    and then have all this output to a database file. At the command prompt I've tried:
    wmic qfe get description, hotfixid
    This does return the patch information I'm looking for, but how do I combine that line of code with:
    wmic os get version, csname, serialnumber, lastbootuptime
    and
    wmic nicconfig get macaddress
    and then get all this to output to a database file?

    Thank you for the links. I checked out http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx and
    found lots of good information. I also found a good command that will print information to a text file.
    Basically what I'm trying to do is retrieve a list of all installed updates (Windows updates and 3rd party updates). I do like that the below code because it gives me the KB numbers for the Windows updates. I need this information so my IT co-workers &
    I can keep track of which of our user computers need a patch/update installed and preferably which patch/update. The minimum we want to know is which patches / updates have been installed on which computer. If you wondering why we don't have Windows automatic
    updates enable, that's because we are not allowed to.   
    This is my code so far. 
    #if you want the computer name, use this command
    get-content env:computername
    $computer = get-content env:computername
    #list of installed patches
    Get-Hotfix -ComputerName $computer#create a text file listing this information
    Get-Hotfix > 'C:\users\little e\Documents\WMI help\PowerShell\printOutPatchList.txt'
    I know you don't want to tell me the code that will print this out to a database (regardless if it's Access or SQL), and that's find. But maybe you can tell me this. Is it possible to have the results of this sent to a database file or do I need to go into
    SQL and write code for SQL to go out and grab the data from an Excel file or txt file? If I'm understanding this stuff so far, then I suspect that it can be done both ways, but the code needs to be written correctly for this to happen. If it's true, then which
    way is best (code in PowerShell to send information to SQL or SQL go get the information from the text file or Excel file)?

  • I need help with my code..

    hi guys. as the subject says I need help with my code
    the Q for my code is :
    write a program that reads a positive integer x and calculates and prints a floating point number y if :
    y = 1 ? 1/2 + 1/3 - ? + 1/x
    and this is my code
       This program that reads a positive integer x and calculates
       and prints a floating point number y if :
                 y = 1 - 1/2 + 1/3 - ? + 1/x
       import java.util.Scanner; // program uses class Scanner
        class Sh7q2
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int i = 1; // i is to control the loop
             int n = 2; // n is suppose to control the number sign
             int x; // a positive integer entered by the user
             int m;
             System.out.println("Enter a positive integer");
             x = input.nextInt();
             do
                m = (int) Math.pow( -1, n)/i;
                System.out.println(m);
                   n++;
                   i++;
             while ( m >= 1/x );
          } // end method main
       } // end class Sh7q2 when I compile it there is no error
    but in the run it tells me to enter a positive integer
    suppose i entered 5
    then the result is 1...
    can anyone tell me what's wrong with my code

       This program that reads a positive integer x and calculates
       and prints a floating point number y if :
                 y = 1 - 1/2 + 1/3 - ? + 1/x
       import java.util.Scanner; // program uses class Scanner
        class Sh7q2
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int i = 1; // i is to control the loop
             int n = 1; // n is suppose to control the number sign
             int x; // a positive integer entered by the user
             double m;
             int a = 1;
             double sum = 0;
             System.out.println("Enter a positive integer");
             x = input.nextInt();
             for ( i = 1; a <= x; i++)
                m =  Math.pow( -1, n+1)/i;
                sum  = sum + m;
                n++;
                a++;
             System.out.print("y = " + sum);
          } // end method main
       } // end class Sh7q2is it right :S

  • If I do a clean install on my MacBook Pro will I be able to re-install apps (FCP, Aperture, MS Office etc.) from a Time Machine backup, or will I need the original install DVDs with authorization codes?

    I have two questions...
    1) If I do a clean install on my MacBook Pro will I be able to re-install apps (FCP, Aperture, MS Office etc.) from a Time Machine backup, or will I need the original install DVDs with authorization codes? (because I don't have them)
    2) Has anyone ever seen anything like this before on their computers?
    The Apple Genius' were stumped by my laptop issues and said they'd never seen anything like it before and recommended I did a clean install. Below you can see my trash bin, and if you look at the "Empty" button it reads "N201" and then there's the "N39" to the left of it. You can also see these numbers over by the folder area--"SD5, SD6, SD7." But that's not all...
    When I right click on items I see the numbers again. Instead of "Open with" I get "N152" and there's an "N35" and "LB1" towards the bottom.
    I have no idea what's going on so I'm just going to do a clean install on my machine but I don't want to lose my apps. I don't have the original install DVDs for them anymore. If you have any suggestions please let me know. Thanks!

    You don't lose them.  You can always redownload them from the app store after you log back in with your Apple ID.
    "Buy, download, and even redownload.
    You can install apps on every Mac you use and even download them again. This is especially convenient when you buy a new Mac and want to load it with apps you already own."

  • Can you help with the code to publish Flash to my own domain.

    Thank you for your help, I publish the my site to my own domain, I do not use .Mac, I tested your code and ity works well on .Mac, can you help with the code to publish to my own domain.
    Thank you again

    You appear to have just collected a variety of code snippets and thrown them together, including a section of AS2 code ( gage.onRelease = function() {... )
    The suggestion I offered yesterday still stands.  You should find a tutorial regarding AS3 and the atan2 function.  Beyond that, what you show suggests this is a school assignment.  You should seek help from your fellow students and instructor if that is the case.

  • New to Programming, need your help with writing code for java in Xcode.

    Hey everyone! Sorry if I sound like a total idiot here with a bunch of developers but I could really use your help. I am in college and having a bit of problems with my intro to programming class. The class is entirely Java based and so, after having to use dos windows on my grandpas crappy laptop I found out about xcode. I downloaded and installed it but I am having problems seeing where exactly it is that I am to write my code for a normal java application. Any help would be greatly appreciated! I wrote it on the bottom of a bunch of code that looked strange to me. For relatively simple java programs I chose the java application template. Is there something here that I missed?

    The Java Application project template looks like it sets up an application and some kind of starting UI using Swing/AWT. I didn't look at it too indepth, but if you are in an introductory course this might be more than you need to complete your assignments. There doesn't seem to be blank Java template, so I don't know what you should use. Perhaps just a blank project you add your .java files to.
    To answer where to write code, you would write it in your .java files under the /src folder. Execution begins in
    public static void main(String args[]) {}
    in YourAppName.java, then creates an object based on your application class, and runs the code from there to display the UI.

  • Noob needs help with this code...

    Hi,
    I found this code in a nice tutorial and I wanna make slight
    adjustments to the code.
    Unfortunately my Action Script skills are very limited... ;)
    This is the code for a 'sliding menue', depending on which
    button u pressed it will 'slide' to the appropriate picture.
    Here's the code:
    var currentPosition:Number = large_pics.pic1._x;
    var startFlag:Boolean = false;
    menuSlide = function (input:MovieClip) {
    if (startFlag == false) {
    startFlag = true;
    var finalDestination:Number = input._x;
    var distanceMoved:Number = 0;
    var distanceToMove:Number =
    Math.abs(finalDestination-currentPosition);
    var finalSpeed:Number = .2;
    var currentSpeed:Number = 0;
    var dir:Number = 1;
    if (currentPosition<=finalDestination) {
    dir = -1;
    } else if (currentPosition>finalDestination) {
    dir = 1;
    this.onEnterFrame = function() {
    currentSpeed =
    Math.round((distanceToMove-distanceMoved+1)*finalSpeed);
    distanceMoved += currentSpeed;
    large_pics._x += dir*currentSpeed;
    if (Math.abs(distanceMoved-distanceToMove)<=1) {
    large_pics._x =
    mask_pics._x-currentPosition+dir*distanceToMove;
    currentPosition = input._x;
    startFlag = false;
    delete this.onEnterFrame;
    b1.onRelease = function() {
    menuSlide(large_pics.pic1);
    b2.onRelease = function() {
    menuSlide(large_pics.pic2);
    b3.onRelease = function() {
    menuSlide(large_pics.pic3);
    b4.onRelease = function() {
    menuSlide(large_pics.pic4);
    I need to adjust five things in this code...
    (1) I want this menue to slide vertically not horizontally.
    I changed the 'x' values in the code to 'y' which I thought
    would make it move vertically, but it doesn't work...
    (2) Is it possible that, whatever the distance is, the
    "sliding" time is always 2.2 sec ?
    (3) I need to implement code that after the final position is
    reached, the timeline jumps to a certain movieclip to a certain
    label - depending on what button was pressed of course...
    I tried to implement this code for button number two...
    b2.onRelease = function() {
    menuSlide(large_pics.pic2);
    if (currentPosition = finalDestination) {
    this.large_pics.pic2.gotoAndPlay("s1");
    --> sliding still works but it doesn't jump to the
    appropriate label...
    (4) I wanna add 'Next' & 'Previous' buttons to the slide
    show - what would be the code in this case scenario ?
    My first thought was something like that Flash checks which
    'pic' movieclip it is showing right now (pic1, pic2, pic3 etc.) and
    depending on what button u pressed u go to the y value of movieclip
    'picX + 1' (Next button) or 'picX - 1' (Previous button)...
    Is that possible ?
    (5) After implementing the Next & Previous buttons I need
    to make sure that when it reached the last pic movieclip it will
    not go further on the y value - because there is no more pic
    movieclip.
    Options are to either slide back to movieclip 'pic1' or
    simply do nothing any more on the next button...
    I know this is probably Kindergarten for you, but I have only
    slight ideas how to do this and no code knowledge to back it up...
    haha
    Thanx a lot for your help in advance !
    Always a pleasure to learn from u guys... ;)
    Mike

    Hi,
    I made some progress with the code thanx to the help of
    Simon, but there are still 2 things that need to be addressed...
    (1) I want the sliding time always to be 2.2 sec...
    here's my approach to it - just a theory but it might work:
    we need a speed that changes dynamically depending on the
    distance we have to travel...
    I don't know if that applies for Action Scrip but I recall
    from 6th grade, that...
    speed = distance / time
    --> we got the time (which is always 2.2 sec)
    --> we got the disctance
    (currentposition-finaldestination)
    --> this should automatically change the speed to the
    appropriate value
    Unfortunately I have no clue how the action script would look
    like (like I said my action script skills are very limited)...
    (2) Also, one other thing I need that is not implemented yet,
    is that when the final destination is reached it jumps to a certain
    label inside a certain movieclip - every time different for each
    button pressed - something like:
    if (currentPosition = finalDestination) {
    this.large_pics.pic2.gotoAndPlay("s1");
    that statement just doesn't work when I put it right under
    the function for each button...
    Thanx again for taking the time !!!
    Mike

Maybe you are looking for