Beginner help with "next" arrow button

Hi,
I have a simple  video gallery set up connected to an xml file to load my assets (video  path, title, description).  Rather than using small thumbnails to change  the videos and corresponding info, I have two arrow buttons that should  change the videos in order back and forth.  (so 0 > 1 > 2 > 0  etc, and backwards with the left arrow)
My assets are  connected and I know this is simple and I have learned it but I am  having trouble with my assets changing to my button click events.  I was  thinking of using if statements (which work on the first 2 assets but  then fail after that).
protected function button1_clickHandler(event:MouseEvent):void
                if (myVideo.source == "assets/media/" + myData[0].path;
                myLabel1.text == myData[0].desc;
                titleLabel1.text == myData[0].title;)
                myVideo.source = "assets/media/" + myData[1].path;
                myLabel1.text = myData[1].desc;
                titleLabel1.text = myData[1].title;
in my head i was thinking of then using "else if" myData[1] then it changes to [2] like this:
else if (myVideo.source = "assets/media/" + myData[1].path;
                myLabel1.text = myData[1].desc;
                titleLabel1.text = myData[1].title;)
            { myVideo.source = "assets/media/" + myData[2].path;
                myLabel1.text = myData[2].desc;
                titleLabel1.text = myData[2].title; }
but i seem to be doing something wrong.
can anyone help me with the code to loop them all together?
thanks!

Yes, its ArrayCollection. It holds data. In your case, collection of videos.
    <mx:ArrayCollection id="myData">
        <mx:source>
            <mx:Array>
                <mx:Object source="Video1.mp4" title="Hello Friend" />
                <mx:Object source="Video2.mp4" title="Hw ru?" />
                <mx:Object source="Video3.mp4" title="Hv a nice day!" />
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>
Also you can use XML. Lets your XML data is like -
            private var myDataXML:XML =
                                    <data>
                                        <mydata>
                                            <source>video1.mp4/</source>
                                            <title>Hello Friend</title>
                                        </mydata>
                                        <mydata>
                                            <source>video2.mp4/</source>
                                            <title>How r u!</title>
                                        </mydata>
                                        <mydata>
                                            <source>video3.mp4/</source>
                                            <title>Have a nice day!!</title>
                                        </mydata>
                                    </data>;
Note: You can populate this XML  data from external XML file too.
Now, on button click,
            private function click_NextHandler(e:Event):void
                currentIndex++;
                if(currentIndex == myDataXML.mydata.length())
                    currentIndex = 0;
            myVideo.source       = "assets/media/" + myDataXML.mydata[currentIndex].source;
           titleLabel1.text     = myDataXML.mydata[currentIndex].title;            }
Hope it helps.
Thanks.
abhinav

Similar Messages

  • Please help with next/previous buttons.

    Hello all, I'm very new at this but I'm hoping you can help.
    I'm not a programmer but I've set up a site for my cartoons.
    Basically I have this Java double combo box set up for the archive section. From the first combo box, the user can select a range of strips to be viewed 1-30, 30-60 etc. From the, then propogated second list, the user can select a specific strip.
    This works fine.
    I've now written some code (untested) on the end of this, that calculates the 'next' strip and the 'previous' strip.
    My problem is, I don't know how to insert buttons to make said functions work!
    I'd like the user to be able to press either button and be zipped to the strip of their choice.
    If the combo's could be updated to show the choice, that would be cool too. Please have a look over at:
    http://theamoeba.ontheweb.com
    and select the 'Archive' item in the menu at the top of the screen to see what I mean.
    Many thanks in advance for anyone kind enough to help.
    The code is as follows.......
    <form name="doublecombo">
    <p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
    <option>Strips 1-30</option>
    <option>Strips 31-60</option>
    <option>Strips 61-90</option>
    <option>Strips 91-120</option>
    </select>
    <select name="stage2" size="1">
    <option value="AmoebaStrips/Strip0000.gif">Strip 1</option>
    <option value="AmoebaStrips/Strip0001.gif">Strip 2</option>
    <option value="AmoebaStrips/Strip0002.gif">Strip 3</option>
    (etc......)
    </select>
    <input type="button" name="test" value="Go!"
    onClick="go()">
    </p>
    <script>
    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group=new Array()
    group[0][0]=new Option("Strip 1","AmoebaStrips/Strip0000.gif")
    group[0][1]=new Option("Strip 2","AmoebaStrips/Strip0001.gif")
    (etc.....)
    group[1][0]=new Option("Strip 31","AmoebaStrips/Strip0030.gif")
    group[1][1]=new Option("Strip 32","AmoebaStrips/Strip0031.gif")
    (etc....)
    group[2][0]=new Option("Strip 61","AmoebaStrips/Strip0059.gif")
    group[2][1]=new Option("Strip 62","AmoebaStrips/Strip0060.gif")
    (etc...)
    group[3][0]=new Option("Strip 91","AmoebaStrips/Strip0089.gif")
    group[3][1]=new Option("Strip 92","AmoebaStrips/Strip0090.gif")
    (etc...)
    var temp=document.doublecombo.stage2
    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    temp.options[0].selected=true
    function go(){
    top.frames["mainFrame"].location=temp.options[temp.selectedIndex].value
    function getCurrentComicNum(selectEl) {
    var selected = selectEl.options[selectEl.selectedIndex].text;
    var currentNum = selected.substr(selected.indexOf("/"),selected.indexOf("."));
    return parseInt(selected.replace(/^0-9/gi,""));
    var baseURL = "AmoebaStrips/Strip";
    var fileType = ".gif";
    function nextComic(selectEl) {
    var thisComic = getCurrentComicNum(selectEl);
    thisComic++;
    thisComic.toString();
    while (thisComic.length<3) { thisComic = "0"+thisComic; }
    top.frames["mainFrame"].location = baseURL + thisComic + fileType;
    function prevComic(selectEl) {
    var thisComic = getCurrentComicNum(selectEl);
    thisComic--;
    thisComic.toString();
    while (thisComic.length<3) { thisComic = "0"+thisComic; }
    top.frames["mainFrame"].location = baseURL + thisComic + fileType;
    //-->
    </script>
    I apologise for the length of this mail but hopefully, you'll solve my problem.
    Cheers again.
    Paul (NooBee)

    Hello NooBee. Just to let you know this is a Java forum. This is not a JavaScript forum. The code you posted is JavaScript, not Java. I suggest you go to google and perform a search on JavaScript forums. You will probably find a good forum to post on.

  • Need help with Flash CS4 buttons/can't get buttons to control anything

    Hello,
    I need help with Flash CS4. I am making a banner with an animation (Image change into movie clip "3D Spiral") and added buttons but I cannot get the buttons to control the animation. Please help I am frustrated! If someone could help I would be most appreciated.

    Thank you.
    Regards,
    Michael J. Sheehan  allelois
    Date: Mon, 17 Aug 2009 18:48:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: Need help with Flash CS4 buttons/can't get buttons to control anything
    Hi there
    I'm not sure how you wound up where you did. But you wound up in the Adobe Captivate forums. Please stand by as I move your thread to the Flash forums.
    Cheers... Rick
    >

  • Help With Scrolling Menu / Button Rollovers

    First thank you to anyone who can answer and help with this
    question.
    http://paragon.sortismarketing.com
    - at this link I have created a site with a simple scrolling menu.
    Now what I want to happen is when you rollOver the buttons on the
    scrolling menu they get larger and then smaller again after you
    roll off them.
    I know how to do this with tweening in a non moving
    environment, by making them a movie clip instead of button. But for
    some reason when I did this in this case it screwed the menu all up
    and made it go crazy. Is there a way to do this with action script
    that isn't going to screw up the underlying code for the
    scrolling?

    You can use the below code also. As your mouse pointer goes
    over the down, it will scroll down.
    on(rollOver){
    scrolltext.scroll -= 1;

  • Help with creating highlighted buttons in DVDSP 3

    OK, I'm going nuts. I set up a "template" in iDVD using the "Brushed Metal Two" form. It has "arrow buttons" that "highlight" when selected in whatever color I set. They're a shadowed grey metal, like the background, when not selected.
    When I open this "template" in DVD Studio Pro 3.0, they arrows show up, but they lose their highlighting ability. I've tinkered with the settings in DVDSP, Button attributes, and have no even gone so far as to try designing my own buttons in Photoshop. Nothing is working. re: Photoshop, I don't know the program very well. Layers and all that is basically another language to me.
    In the end, I don't understand why everything I do in iDVD gets imported into DVDSP EXCEPT for the highlight fuction for the buttons. The "button" shows up, but it loses the ability to be highlighted.
    Anyone have any thoughts?
    Chip Tredo - Dallas

    iDVD templates will not import properly into DVD SP depending on the version of iDVD, DVD SP 3 will be further back than this
    http://discussions.apple.com/thread.jspa?messageID=4650585&#4650585
    DVD SP 4 can do iDVD before iDVD 5, do not recall the ones for DVD SP 3
    If you go to the menus section here
    http://dvdstepbystep.com/
    There is some info on making buttons including using Photoshop look at
    http://dvdstepbystep.com/qm.php
    http://dvdstepbystep.com/newmap.php
    http://dvdstepbystep.com/motion.php
    http://dvdstepbystep.com/useelements.php (using elements from DVD SP, you can also access iDVD elements the same way)
    http://dvdstepbystep.com/buttons07.php
    http://dvdstepbystep.com/buttons07m.php

  • Help with Find / Replace button title tag contents (text)

    Hi there,
    I designed my site with Sitegrinder (Medialab) –
    Currently all the title tags generated for buttons are the same as
    the actual html page name.
    The problem with this is that the tooltip which appears in
    browsers when you hover over the button with the mouse gives you
    the page name. Instead I want to use these tooltips to give the
    user an indication of what the function of the button is.
    An example: A zoom button above an image: Currenty the
    tootlip says “zoom imagename pagename” – Instead
    it should say “click here to zoom”.
    I need help to get the Dreamweaver Find and Replace tool to
    batch replace these tags for me for about a 100 pages.
    Here is an example of the code:
    <body>
    <div id="id1zoomimpastooilweddingbutton"><a
    href="zoomimpastooilwedding.html"
    title="zoomimpastooilwedding"></a></div>
    I only want to replace the text in the title tag - Since the
    text “zoom” appears several times in the body, I
    can’t get the Find tool to pick up and Replace the occurrence
    of “zoom” in the title only…….
    Options I’ve tried:
    Search Current document: Search for: “specific
    tag”: “title”, “containing”:
    “text” = zoom (I’ve tried this with
    “zoomimpastooilwedding” and zoom[^”]* with no
    results
    I’ve also tried: Search for: “specific
    tag”: “body”, “containing”:
    “specific tag” “title”
    “containing”: “text” = zoom
    etc……………..
    I need help with what parameters to enter in order to find
    and replace all the text within the title tag with my own text
    Thanks very much!
    Anton

    You have ~ 100 pages, each of which has images with title
    attributes (not
    tags), all of which BEGIN with the letters "zoom"?
    What do you want to replace that text with? Wouldn't it be
    different for
    each button? Or do you mean that you would do multiple
    sitewide searches,
    one for each button? This illustrates how wrong it is to not
    use DW
    Templates or server-side includes to simplify the management
    of your
    navigation elements....
    Did you ask Medialabs if it would be possible to specify this
    before
    generating the HTML?
    How did you like working with SiteGrinder? It looks like a
    nice product to
    me, although I'm not fond of the final results code-wise....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "unison123" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hi there,
    >
    > I designed my site with Sitegrinder (Medialab) ?
    Currently all the title
    > tags
    > generated for buttons are the same as the actual html
    page name.
    >
    > The problem with this is that the tooltip which appears
    in browsers when
    > you
    > hover over the button with the mouse gives you the page
    name. Instead I
    > want to
    > use these tooltips to give the user an indication of
    what the function of
    > the
    > button is.
    >
    > An example: A zoom button above an image: Currenty the
    tootlip says ?zoom
    > imagename pagename? ? Instead it should say ?click here
    to zoom?.
    >
    > I need help to get the Dreamweaver Find and Replace tool
    to batch replace
    > these tags for me for about a 100 pages.
    >
    > Here is an example of the code:
    >
    > <body>
    > <div id="id1zoomimpastooilweddingbutton"><a
    > href="zoomimpastooilwedding.html"
    > title="zoomimpastooilwedding"></a></div>
    >
    > I only want to replace the text in the title tag - Since
    the text ?zoom?
    > appears several times in the body, I can?t get the Find
    tool to pick up
    > and
    > Replace the occurrence of ?zoom? in the title only??.
    >
    > Options I?ve tried:
    >
    > Search Current document: Search for: ?specific tag?:
    ?title?,
    > ?containing?:
    > ?text? = zoom (I?ve tried this with
    ?zoomimpastooilwedding? and zoom[^?]*
    > with
    > no results
    >
    > I?ve also tried: Search for: ?specific tag?: ?body?,
    ?containing?:
    > ?specific
    > tag? ?title? ?containing?: ?text? = zoom etc?????..
    >
    > I need help with what parameters to enter in order to
    find and replace all
    > the
    > text within the title tag with my own text
    >
    > Thanks very much!
    >
    > Anton
    >
    >

  • Ipod touch help with missing accept button for terms and conditions

    I want to update my apps but when I try it tells me that i first have to accept the new terms and conditions, however, there is no accept button to click.
    I have tried the other option to have it sent by e-mail but when I open the e-mail it's still the same with no accept button.
    I went into settings and allowed cookies on safari.
    I have an ipod touch 4th gen with ios 6.1.3.  I am also not able to buy any apps, music , etc.
    Someone PLEASE help!!!!

    Under Safari settings I have also "cleared history" and "cleared cookies and data"
    I have also given the i-pod both a restart, and a hard restart (holding the power and home buttons until the apple appears)
    "private browsing" is set to off.  "block pop-ups" is off too.

  • Next arrow buttons not functioning

    Hi All,
    I have report where we use hierarchy column, when i expand the + sign in the report, it shows as - but only 25 values are visible, now when i press on next arrow symbol, its not working. I am using conditions in the section of the dashboard
    Thanks,
    Sreekanth

    hey, i got the navigation arrows functional, the problem was i was having a narrative view which actually was deleted from left bottom corner but some how it still remained in Compound view, after deleting it from compound layout, they are working

  • Help with the hold button on my ipod

    First, my ipod was starting to act up so I went onto the apple website and reset the ipod using what they told me to do (hold the menu and the center button at the same time) which of course I lost everything. Well when it came back on I plugged it into my computer and it recognized it and everything, acted like it was syncing my music and videos and when I unplugged it, only the names of the artist and songs were on it, 3 songs actaully went thru corrently, one of them for some reason was cut short the other was somehow mixed in with another song. I thought it was my computer so I tried it with my mother's laptop. It did the same thing. Then it decided it wouldn't turn on for anything, I plugged it into the charger and now it charges and comes on but the hold button won't go off, I've tried flicking the switch tons of times, I've tried resetting it, but with the hold button on I can't do anything. How can I get the hold button off. The warrenty is expired on it, is there a way I could take it back to apple for a new one or a refurbished one, for free? Or would I have to pay like $150 for it? Is there a way I could fix it at home?

    it might be a malfunction in your device. you might ave to send it to repairation
    1.ave you try resetting it or restoring it?
    2. did your hold boutons whas working beffor?

  • Help with using same buttons on timeline

    This is really basic,
    I've got 3 buttons on the main timeline, which is 25 frames. All my actions are on frame 14.
    Three buttons work on frame 15. But these same 3 buttons stop working on frame 17  - why?
    Please visit link below:
    http://www.simplecelebrations.info

    If your code is on frame 14 and your buttons are on frame 15, those buttons can't work unless they were on frame 14 first.  If you place new instances of these buttons on frame 17 but do not assign code for them, they will not work.  When you assign code to objects, such as buttons, they need to be present when that code executes.  So if you execute that code in frame 14, and the buttons are in frame 17, they are not present when that code executes so they cannot work.
    What you may find easier to deal with might be to have the buttons span the timeline where they are needed, meaning they have a keyframe at frame 14 where they get coded, and that extends as far down the timeline as you know those buttons need to be accessible.  You do not create new keyframes of them.  Then, if you need to hide the buttons for any reason, then you hide them by setting their visible property to be false. And if you need to display them again, you set it to true.
    There is not issue with having different buttons command the same thing, but if you are going to do that, then the different buttons should share the same function.  When I want to share a function or other code, such as variables, I always create a layer that I dedicate to the entire timeline.  It extends from frame 1 thru the last frame of the timeline.  All code on this layer is in frame 1. Any code on this layer is then accessible by anything along the timeline.  Then, as needed, I will have another actions layer that deals with frame level actions.
    So what I would do in your case, if you want to use different instances of the same buttons, would be to have the shared layer hold my event handler functions.  Then in my frame level actions layer I would have keyframes where I have the buttons and assign my event listners in those frames.  So if I had identical buttons in frames 15 and 17, but they were different instances, then in frame 15 I would have the same event listener assignments as I do in frame 17.  These listeners would be calling on the same functions that I have in that shared actionscript layer.
    // frame 15 code of frame level actions layer
    stop();
    btn1.addEventListener(MouseEvent.CLICK,go15);
    btn2.addEventListener(MouseEvent.CLICK,go18);
    btn3.addEventListener(MouseEvent.CLICK,go19);
    btn4.addEventListener(MouseEvent.CLICK,go20);
    btnb.addEventListener(MouseEvent.CLICK,go15);
    btnc.addEventListener(MouseEvent.CLICK,go17);
    // frame 17 code of frame level actions layer
    stop();
    btn1.addEventListener(MouseEvent.CLICK,go15);
    btn2.addEventListener(MouseEvent.CLICK,go18);
    btn3.addEventListener(MouseEvent.CLICK,go19);
    btn4.addEventListener(MouseEvent.CLICK,go20);
    btnb.addEventListener(MouseEvent.CLICK,go15);
    btnc.addEventListener(MouseEvent.CLICK,go17);
    frame 1 of shared actionscript layer...
    function go15(e:MouseEvent):void
    gotoAndStop(15);
    function go18(e:MouseEvent):void
    gotoAndStop(18);
    function go19(e:MouseEvent):void
    gotoAndStop (19);
    function go20(e:MouseEvent):void
    gotoAndStop (20);
    function go17(e:MouseEvent):void
    gotoAndStop (17);

  • Help with Inventory Program Buttons & images

    I'm supposed to have buttons that move between the items in my program individually showing them one by one and also going to the first item when the last one is reached and vice versa, but I cannot get the buttons to to show even show up. I'm also having problems getting any type of image to show up. Any help on this would be appreciated.
    My code is below
    import java.awt.GridLayout;
    import java.text.NumberFormat;
    import java.util.Arrays;
    import javax.swing.*;
    //Begin Main
    public class InventoryProject {
              @SuppressWarnings("unchecked")
              public static Product[] sortArray(Product myProducts[])
                   //Comparator comparator = null;
                   ProductComparator comparator = new ProductComparator();
                   Arrays.sort(myProducts, comparator);
                   return myProducts;
              public static double CalculateInventory(Product myProducts[])
                    double total = 0;
                 for (int i = 0; i < myProducts.length; i++)
                    total += myProducts.calculateInventory();
         return total;
         public static void main (String[] args) {
                   Product products[] = new Product.Supplier[5];
                   //Create 5 Product Objects
                   Product.Supplier invItem0 = new Product.Supplier("The Matrix (DVD)", 100001, 12, 15.99, "Warner Brothers");
                   Product.Supplier invItem1 = new Product.Supplier("The Matrix Reloaded (DVD)", 100002, 9, 17.99, "Warner Brothers");
                   Product.Supplier invItem2 = new Product.Supplier("The Matrix Revolutions (DVD)", 100003, 27, 18.99, "Warner Brothers");
                   Product.Supplier invItem3 = new Product.Supplier("300 (DVD)", 100004, 5, 18.99, "Warner Brothers");
                   Product.Supplier invItem4 = new Product.Supplier("Harry Potter and the Sorcerers Stone (DVD)", 100005, 10, 15.99, "Warner Brothers");
                   //products array
                   products[0] = invItem0;
                   products[1] = invItem1;
                   products[2] = invItem2;
                   products[3] = invItem3;
                   products[4] = invItem4;
                   products = sortArray(products);
                   // Output Product Object
    JTextArea textArea = new JTextArea();
    for (int a = 0; a < products.length; a++)
    textArea.append(products[a]+"\n");
    textArea.append("\nTotal value of the inventory is "+new java.text.DecimalFormat("$0.00").format(CalculateInventory(products))+"\n\n");
    JButton prevBtn = new JButton("Previous");
    prevBtn.setEnabled(false);
    JButton nextBtn = new JButton("Next");
    JPanel p = new JPanel(new GridLayout(1,2));
    p.add(prevBtn); p.add(nextBtn);
    JFrame frame = new JFrame();
    frame.getContentPane().add(new JScrollPane(textArea));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("DVD Inventory");
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    /*          for (int a = 0; a < products.length; a++)
                        System.out.println(products[a]); //use the toString method that you have defined in your Product class to print out the product information.
                   System.out.println("Total Value of The Inventory: " + nf.format (CalculateInventory(products)));
         private String name;
         private int number;
         private int unitCount;
         private double unitPrice;
    //     public String SupplierName;
    //     public static double calculateInventory;
         //Constructor
         public Product (String name, int number, int unitCount, double unitPrice)
              setName(name);
              setNumber(number);
              setUnitCount(unitCount);
              setUnitPrice(unitPrice);
    //     get and set methods for Number attribute
         public void setNumber(int itemnumber){
              number = itemnumber;
         public int getNumber(){
              return number;
    //     get and set methods for Name attribute
         public void setName(String names){
              name = names;
         public String getName(){
              return name;
    //     get and set methods for UnitCount attribute
         public void setUnitCount(int count){
              unitCount = count;
         public int getUnitCount(){
              return unitCount;
    //     get and set methods for UnitPrice attribute
         public void setUnitPrice(double price){
              unitPrice = price;
         public double getUnitPrice(){
              return unitPrice;
    //     get and set Total Inventory method
         public double calculateInventory()
              return getUnitPrice() * getUnitCount();
         public String toString () {
              return "Item Name: " + name + "\n" + "Item Inventory Number: " + number + "\n" + "Item Unit Count: " + unitCount + "\n" + "Item Unit Price: " + unitPrice + "\n" ;
         public void Supplier() {
              // TODO Auto-generated method stub
              return;
    //     public Supplier getSupplierName() {
    //     // TODO Auto-generated method stub
    //     return null;
         static class Supplier extends Product
              //private double restockFee;
              private String supplierName;
              NumberFormat nf = NumberFormat.getCurrencyInstance();
              public Supplier(String Name, int Number, int UnitCount, double UnitPrice, String SupplierName)
                   super(Name, Number, UnitCount, UnitPrice);
                   setSupplierName(SupplierName);
                   //setRestockFee(restockFee);
                   this.supplierName = SupplierName;
              //get and set methods for Supplier attribute
              public String setSupplierName(String supplier)
                   supplierName = supplier;
                   return supplierName;
              public String getSupplierName()
                   return supplierName;
              public double calculateRestockFee()
                   return (((getUnitPrice()) * (getUnitCount())) * 0.05);
              public double calculateInventory()
                   return ((getUnitPrice() * getUnitCount()));
              public String toString ()
                   return "Item Name: " + getName() + "\n" + "Item Inventory Number: " + getNumber() + "\n" + "Item Unit Count: " + getUnitCount()
                        + "\n" + "Item Unit Price: " + nf.format(getUnitPrice()) + "\n" + "Inventory Value: " + nf.format(calculateInventory()) + "\n"
                        + "Supplier Name: " + getSupplierName() + "\n" + "Restock Fee: " + nf.format(calculateRestockFee()) + "\n";
         public int compareTo(Product arg0)
              // TODO Auto-generated method stub
              return (this.name.compareTo(arg0.getName()));
    }public class ProductComparator implements java.util.Comparator
         public int compare(Object o1, Object o2)
                   if(o1 == null) return -1;
                   if(o2 == null) return 1;
                   Product p1 = (Product) o1;
                   Product p2 = (Product) o2;
                   String s1 = p1.getName();
                   String s2 = p2.getName();
                   int compVal = s1.compareTo(s2);
                   return compVal;

    The program does work because I can get the content of my array to show in a GUI the only problem is the buttons aren't showing up in the GUI which is what I'm having a problem with. I also tried adding the panel to the frame but it didn't do any good either so maybe I'm not doing it right although when I compile I get 0 errors. What's the link to the swing tutorial?
            JTextArea textArea = new JTextArea();
            for (int a = 0; a < products.length; a++)
                textArea.append(products[a]+"\n");
            textArea.append("\nTotal value of the inventory is "+new java.text.DecimalFormat("$0.00").format(CalculateInventory(products))+"\n\n");
            JButton prevBtn = new JButton("Previous");
            prevBtn.setEnabled(false);
            JButton nextBtn = new JButton("Next");
            JPanel panel1 = new JPanel(new GridLayout(1,2));
            panel1.add(prevBtn); panel1.add(nextBtn);
            JFrame frame = new JFrame();
            frame.getContentPane().add(new JScrollPane(textArea));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setTitle("DVD Inventory");
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.add(panel1);Edited by: Morepheus on May 20, 2009 12:55 AM
    Edited by: Morepheus on May 20, 2009 12:58 AM
    Edited by: Morepheus on May 20, 2009 1:00 AM

  • Gallery problem with next/prev buttons

    Hi,
    I'm working on a photo gallery and I have some weird things
    happening, hence the request for help!
    When the gallery opens, you can click on any picture, the
    main one then appears with various buttons:
    1. Click on the image and you go back to the thumbnails -
    fine
    2. Click on the cross button and it's the same - fine
    3. Don't click on the automatic gallery, it's no on yet! :)
    4. Click on previous and the previous image appears - fine
    5. Click on next and the next image appears - nope, that's
    where the problem is!
    For the previous button, I use this code:
    var previous = "none";
    if (_global.currentImage == 1) {
    previous = _global.photoNum;
    } else {
    previous = _global.currentImage-1;
    _global.currentImage is the number related to the thumbnail
    you have clicked.
    _global.photoNum is the total number of pictures
    After this code, there's all the code for the preloader and
    it ends by defining the new current image (
    _global.currentImage = previous;) and loading it (
    mcLoader.loadClip("images/photo"+previous+".jpg",
    _level0.images_mc.holder_mc);).
    The next button is based on the same code:
    var next = "none";
    if (_global.currentImage == _global.photoNum) {
    next = 1;
    } else {
    next = _global.currentImage+1;
    With at the end
    _global.currentImage = next; and
    mcLoader.loadClip("images/photo"+next+".jpg",
    _level0.images_mc.holder_mc);.
    Here is the problem, there are three situation you use the
    next button:
    1. On the thumbnails, you click any image. When the main
    image is loaded, you click first previous, have the new image
    loaded and then you click next. The next image is loaded and it
    works fine.
    2. On the thumbnails, you click the last image. When the main
    image is loaded, you click next. The next image (which is then the
    1st) is loaded and it works fine.
    3. On the thumbnails, you click any image. When the main
    image is loaded, you click next.
    Here is the problem: the next image is not loaded!
    You can see it here:
    www.theminnesotafats.com/gallery
    When you see that the picture is not loaded, you will have to
    refresh the page to make it work again.
    I hope that those explainations are not too long and that
    somebody could help me. Thanks!

    WHEN 'NEXT'.
          PERFORM scroll_end.
    WHEN 'PREVIOUS'.
         PERFORM scroll_left.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_7100  INPUT
    *&      Form  scroll_end
          text
         -->RT_COLUMNS text
    form scroll_end tables rt_columns type kkblo_t_columns.
      ENDFORM.
    *&      Form  scroll_left
          text
         -->RT_COLUMNS text
    form scroll_left tables rt_columns type kkblo_t_columns.
      ENDFORM.
    i've tried this....the previous error gone..but now i have another error said " the type kkblo_t_columns. is unknown ".
    really exhausting :P

  • Help with validating radio buttons

    I would like to set my radio button so they can only click it after they have entered text into the 2 previous text fields.  Can someone help me out with a script how to do that?
    Thanks

    Please try the following Script :
    // Function to enable form fields function
    EnableFormField (cFieldName) {
    // First acquire the field to be enabled
    var oFld = this.getField(cFieldName)
    // Next acquire the hidden field with the normal colors
    var oNmlFld = this.getField("NormalColorsFld");
    if(oFld) {
    // Make field interactive
    oFld.readonly = false;
    // Restore Normal Colors
    oFld.fillColor = oNmlFld.fillColor; oFld.borderColor = oNmlFld.borderColor; oFld.textColor = oNmlFld.textColor;
    // Function to disable form fields function
    DisableFormField(cFieldName) {
    // First acquire the field to be disabled
    var oFld = this.getField(cFieldName)
    if(oFld) {
    // Make field Read-Only
    oFld.readonly = true;
    // Set Grayed out colors
    oFld.fillColor = ["G", 0.75]; oFld.borderColor = ["G", 2/3]; oFld.textColor = ["G", 0.5];

  • HELP with animation for buttons (i tried to search for days for solution)

    Hellooo
    i've been trying to look at the threads here for a solution but i just can't find... can someone please help me???
    i'm designing a website in flash8... now i have created some buttons, and i want that when i click on the button stars will fly from them and there will be a sound... i have already created the animation of the stars seperatly and it's in the library, i have also the sound file.... i just can't remember how to put everything together.... can someone please remind me what to do step by step so when i'll press on the button the stars will be flying from the button and the sound will play??? pleaseeeeeeeee, it's very very important to me... i would be thankful <3

    hey!!! thank you, the sound is fixed,now the problem is with the stars.... i've been trying to do this soooooooo many times but i have really no idea why it's not working... i don't wantto give up... i don't know what i'm doing wrong.....grrrrrrrrrrrrrrrrrr

  • Help with images and buttons

    I was wondering if anyone could recommend a tutorial or point me in the right direction. I've been trying to figure out how to use buttons to add images (been using png from photoshop with alphachannel) to a canvas. I don't have any problems skinning the buttons nor putting in a single image, nor text. As far as getting the images to layer when the buttons are clicked then I'm pretty lost. Not sure if an array is best or if adding and removing them as children in another container would be any easier..

    I've been using flash builder beta 2. I was planning on embedding the images. I'm not sure if the help files and examples I am reading are not compatible or if I just have the syntax wrong. I haven't been able to find any examples that use embedded images and toggle visibility. I've used spark components. In design mode it puts the code in for a button when drag-dropped, then recommends using spark component instead. It seems that the only time that the images really do anything is when there's a spark component.
    I've never used flex before would it be easier to use wordpad and try compiling it with something other than flash builder?

Maybe you are looking for

  • Stock balances by month

    Hi All Is there a report one can run to get stock balances by month for the periods that have already passed Thanks Vishnu

  • My ipod touch is not charging and no power

    My ipod touch is not charging and has no power.How can I solve this problem?

  • Many Songs No Longer Sync From iTunes to my iPhone

    I look in the folders in iTunes Media/Music and they're still there, but they are no longer on my iPhone or iPad and I can no longer sync them to these devices. Some of these songs I've had on my devices for years. This started when I tried to update

  • Ipod cannot be used because the Apple Mobile Device Service is not Started

    Just received my Ipod touch this morning, PC recognises device and says that is is ready to use (however then it is not recognised in my computer) and upon start up of i tunes the following message is displayed. +This ipod cannot be used because the

  • Using Sockets with BufferedInputStream

    Hi, Many thanks in advance for any help or advice. I have been struggling with this for a while now. I have data comming in from a Socket. I create a BufferedInputStream like this: inputStream = new BufferedInputStream( socket.getInputStream() ); The