Use preloader for individual frames?

I have followed this video on how to build a preloader and I was able to incorporate it into my own site.  Now, I'm wondering now how to build a preloader for individual frames.  For example, I have a link called "Videos" that, when clicked, jumps to frame 10.  This is where I have all the videos visible in the main content area of my site.  However, I'd like to add a preloader so that as the videos load, visitors can see the progress.  Is there a way I can reuse the preloader.swf file I have already built for individual frames of my main site?
Here is the code for the preloader.swf file which consists of a single dynamic text field located in the center called preloaderTxt:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("WebsiteTest.swf"));
function loop(e:ProgressEvent):void
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    preloaderTxt.text = Math.ceil(perc*100).toString() + "%";
function done(e:Event):void
    removeChildAt(0);
    preloaderTxt = null;
    addChild(l);

(1)Java class name should begin with a capital letter. See: http://java.sun.com/docs/codeconv/
        JButton save = new JButton("Save");
        JButton save2 = new JButton("Save and add another");
        // ... etc. ...(2)Don't redeclare class members in a method as its local variable. Your class members become eternally null, a hellish null.
how to make them work when clicked on(3)Add action listener to them.

Similar Messages

  • How do i use jbutton for mutiple frames(2frames)???

    im an creating a movie database program and i have a problem with the jButtons on my second frame i dont know how to make them work when clicked on. i managed to make the jButtons work on my first frame but not on the second....
    here is that code so far----
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    * real2.java
    * Created on December 7, 2007, 9:00 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author J
    public class real2 extends JPanel  implements ActionListener{
        private JButton addnew;
        private JButton help;
        private JButton exit;
        private JFrame frame1;
        private JButton save;
        private JButton cancel;
        private JButton save2;
        private JLabel moviename;
        private JTextField moviename2;
        private JLabel director;
        private JTextField director2;
        private JLabel year;
        private JTextField year2;
        private JLabel genre;
        private JTextField genre2;
        private JLabel plot;
        private JTextField plot2;
        private JLabel rating;
        private JTextField rating2;
        /** Creates a new instance of real2 */
        public real2() {
            super(new GridBagLayout());
            //Create the Buttons.
            addnew = new JButton("Add New");
            addnew.addActionListener(this);
            addnew.setMnemonic(KeyEvent.VK_E);
            addnew.setActionCommand("Add New");
            help = new JButton("Help");
            help.addActionListener(this);
            help.setActionCommand("Help");
            exit = new JButton("Exit");
            exit.addActionListener(this);
            exit.setActionCommand("Exit");
           String[] columnNames = {"First Name",
                                    "Last Name",
                                    "Sport",
                                    "# of Years",
                                    "Vegetarian"};
            Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)}
            final JTable table = new JTable(data, columnNames);
            table.setPreferredScrollableViewportSize(new Dimension(600, 100));
            table.setFillsViewportHeight(true);
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            add(scrollPane);
            GridBagConstraints c = new GridBagConstraints();
            c.weightx = 1;
            c.gridx = 0;
            c.gridy = 1;
            add(addnew, c);
            c.gridx = 0;
            c.gridy = 2;
            add(help, c);
            c.gridx = 0;
            c.gridy = 3;
            add(exit, c);
        public static void addComponentsToPane(Container pane){
            pane.setLayout(null);
            //creating the components for the new frame
            JButton save = new JButton("Save");
            JButton save2 = new JButton("Save and add another");
            JButton cancel = new JButton("Cancel");
            JLabel moviename= new JLabel("Movie Name");
            JTextField moviename2 = new JTextField(8);
            JLabel director = new JLabel("Director");
            JTextField director2 = new JTextField(8);
            JLabel genre = new JLabel("Genre");
            JTextField genre2 = new JTextField(8);
            JLabel year = new JLabel("year");
            JTextField year2 = new JTextField(8);
            JLabel plot = new JLabel("Plot");
            JTextField plot2 = new JTextField(8);
            JLabel rating = new JLabel("Rating(of 10)");
            JTextField rating2 = new JTextField(8);
            //adding components to new frame
            pane.add(save);
            pane.add(save2);
            pane.add(cancel);
            pane.add(moviename);
            pane.add(moviename2);
            pane.add(director);
            pane.add(director2);
            pane.add(genre);
            pane.add(genre2);
            pane.add(year);
            pane.add(year2);
            pane.add(plot);
            pane.add(plot2);
            pane.add(rating);
            pane.add(rating2);
            //setting positions of components for new frame
                Insets insets = pane.getInsets();
                Dimension size = save.getPreferredSize();
                save.setBounds(100 , 50 ,
                         size.width, size.height);
                 size = save2.getPreferredSize();
                save2.setBounds(200 , 50 ,
                         size.width, size.height);
                 size = cancel.getPreferredSize();
                cancel.setBounds(400 , 50 ,
                         size.width, size.height);
                 size = moviename.getPreferredSize();
                moviename.setBounds(100 , 100 ,
                         size.width, size.height);
                size = moviename2.getPreferredSize();
                moviename2.setBounds(200 , 100 ,
                         size.width, size.height);
                 size = director.getPreferredSize();
                director.setBounds(100, 150 ,
                         size.width, size.height);
                 size = director2.getPreferredSize();
                director2.setBounds(200 , 150 ,
                         size.width, size.height);
                size = genre.getPreferredSize();
                genre.setBounds(100 , 200 ,
                         size.width, size.height);
                 size = genre2.getPreferredSize();
                genre2.setBounds(200 , 200 ,
                         size.width, size.height);
                 size = year.getPreferredSize();
                year.setBounds(100 , 250 ,
                         size.width, size.height);
                size = year2.getPreferredSize();
                year2.setBounds(200 , 250 ,
                         size.width, size.height);
                 size = plot.getPreferredSize();
                plot.setBounds(100 , 300 ,
                         size.width, size.height);
                 size = plot2.getPreferredSize();
                plot2.setBounds(200 , 300 ,
                         size.width, size.height);
                size = rating.getPreferredSize();
                rating.setBounds(100 , 350 ,
                         size.width, size.height);
                 size = rating2.getPreferredSize();
                rating2.setBounds(200 , 350 ,
                         size.width, size.height);
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            frame.add(new real2());
            //Display the window.
            frame.setSize(600, 360);
            frame.setVisible(true);
            frame.pack();
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        public void actionPerformed(ActionEvent e) {
            if ("Add New".equals(e.getActionCommand())){
               frame1 = new JFrame("add");
               frame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
               addComponentsToPane(frame1.getContentPane());
               frame1.setSize(600, 500);
               frame1.setVisible(true);
                //disableing first frame etc:-
                if (frame1.isShowing()){
                addnew.setEnabled(false);
                help.setEnabled(false);
                exit.setEnabled(true);
                frame1.setVisible(true);
               }else{
                addnew.setEnabled(true);
                help.setEnabled(true);
                exit.setEnabled(true);           
            if ("Exit".equals(e.getActionCommand())){
                System.exit(0);
            if ("Save".equals(e.getActionCommand())){
                // whatever i ask it to do it wont for example---
                help.setEnabled(true);
            if ("Save" == e.getSource()) {
                //i tried this way too but it dint work here either
                help.setEnabled(true);
    }so if someone could help me by either telling me what to type or by replacing what iv done wrong that would be great thanks...

    (1)Java class name should begin with a capital letter. See: http://java.sun.com/docs/codeconv/
            JButton save = new JButton("Save");
            JButton save2 = new JButton("Save and add another");
            // ... etc. ...(2)Don't redeclare class members in a method as its local variable. Your class members become eternally null, a hellish null.
    how to make them work when clicked on(3)Add action listener to them.

  • What is the best format to choose when converting mts files to fit well with iMovie? I am using iCoolsoft for conversions and can pick from almost any kind of formats to convert to. I don't want to get the black frames... what do you advice me to pick?

    I have lots of MTS files stored on an external hard drive that I want to use in my iMovie films. Now, as you know, iMovie doesn't like them. I have bought iCoolsoft for converting my video files into any format I want but now I've got another problem: what format is the best for iMove? Some of the formats I've tried are giving me a black frame around the video clips and some are bigger and other smaller but anyway I don't want them at all! Can anyone recommend what format to convert to to keep the original clip's size and no frames and still be liked by iMovie to be able to import them?
    Much thankful for any kind of support and reply on this one.
    Eva

    The format iMovie uses when you edit video after it's imported is Apple Intermediate Codec, it will have the file ending .mov but internally it's set so the Mac can edit individual frames easier and play them back easier at full speed. If you have the option of saving to QuickTime .mov see if there is a pulldown list of all the different "codecs", that's the style or flavor of compression applied to the video frames. If Apple Intermediate Codec (AIC) appears on that pull-down list choose that as your codec when you save to .mov.

  • Can separate apple ids be set up for individual family members that use different devices?  Several iPads are tied to one Apple ID (email address). Thank you.

    Can separate apple ids be set up for individual family members that use different devices (iPads & iPhones)?  Several family members are tied to one apple id (email address).  Thanks.

    How to use multiple iPods, iPads, or iPhones with one computer
    http://support.apple.com/kb/HT1495
    How to Share a Family iPad
    http://www.macworld.com/article/1163347/how_to_share_a_family_ipad.html
    Using iPhone, iPad, or iPod with multiple computers
    http://support.apple.com/kb/ht1202
    iOS & iCloud Tips: Sharing an Apple ID With Your Family
    http://www.macstories.net/stories/ios-5-icloud-tips-sharing-an-apple-id-with-you r-family/
    How To Best Use and Share Apple IDs across iPhones, iPads and iPods
    http://www.nerdsonsite.com/blog/2012/06/07/help-im-appleid-confused/
     Cheers, Tom

  • To use one SessionInfo for multiple frames

    how to use one SessionInfo for master frame and other frame the detail
    Thanks for your reply.

    You can instantiate the SessionInfo and other dataproducer objects in frame1 and bind them to controls in the first and second frames.
    If you plan to change/execute queries pass the sessionInfo instance to the second frame.
    Hope this helps.
    Sathish
    null

  • Can I purchase Adobe photoshop cc INDIVIDUAL subscription and use it for commercial purpose? Or is it meant for non-commercial usage only?

    If I run a small studio with only 3 people, and purchase photoshop CC with individual subscription, can I use it for my studio? Why I ask this is because CC individual license (single app) is cheaper than a subscription for small/medium sized businesses (single app).
    Thanks in advance.

    Hi rohit.c
    Yes, that's fine - there is no restriction on using an individual subscription commercially.
    The small business teams plans are more expensive as you get additional storage and tools to manage license deployment.
    Kind regards
    Bev

  • Capture individual frames for export to photoshop

    Hi all:
    New to i movie. I have not upgraded to 06 version. I would like to capture individual frames for export to photoshop for cleanup and output as a print. Can I do this in i movie? Do I need a particular version? Is it hard to do?
    Thanks
    DAU

    follow Matthew's advice
    in case, your nic is a German acronym:
    in iM, there's as in any Apple App an integrated "help" (=Hilfe) feature
    avoids being DAU...

  • I'm trying to crop individual frames. Can this be done without the crop being applied to the entire clip? Using imovie 11

    I'm trying to crop individual frames. Can this be done without the crop being applied to the entire clip? Using imovie 11

    use the cmd-B(lade) command to split your single clip into individual ones

  • Exporting animation using Save for Web and Devices problem

    The animation plays as it should when the "Play" button is pressed at the bottom of the "Save for Web and Devices" Menu , but when I Preview it the individual frames don't disappear once they've shown , so you can see them all at the end of the animation . This is also how they save as a .gif ( although using the "Save as html" option reverts to looking as it should , each frame appearing and disappearing in turn) How do I save as gif without this happening?Many thanks for any help

    Thanks!  It was under the object - slice.  You've saved my sanity

  • How do I Clone dust spots from video across footage? I can do on individual frames but don't know ho

    How do I Clone dust spots from video across footage in CC? I can do on individual frames but don't know how to batch process .
    How do I save it after? Render?

    To fill in the void in the background, you can use the clone tool. However, for a large area that may not work well.
    A good alternative is to use a "digital patch". With the rectangular marquee tool , select a pleasing substitute from somewhere else in the picture (not a fire hydrant!),  then place this on its own layer (CTRL+J), and with the move tool position the patch and resize it if indicated
    You should also explore the Recompose tool (ALT+CTRL+R) which may work well for your purpose.

  • Using iweb for school website

    Hi
    This may have been answered before but I cant find it in the discussion. I want to set up a website for a very small school (24 students)using iweb. Do I have to use Apple for the ISP and if so is it the same rate as for a private individual?
    Anyone out there done the same thing? I have been using the moogle style and they are unbelievably complicated for someone like me! Iweb seems to solve those tech problems and I would love to use it.
    Thanks

    It is extremely easy to produce a site like this within iWeb. Just start with a white template so that you can design is yourself as they have done.
    To get the colours, what they have done and you can do is create a text box and then use either colour fill or gradient fill to achieve the contrast in colours. They have then placed photos and their logos over this. You could even achieve the same effect with a shape too with a rounded or a square edge that is colour or gradient filled.
    For the navigation bars, all you need do is to go to the Inspector and hide the page template nav bar and create your own as they have done. They have probably created theirs by using either shapes or text boxes that are again colour/gradient filled. You can then enhance the look by using picture frames to make them stand out more. Don't forget to hyperlink them though. The other nav bar is just done using different text styles and colours.
    It is really as simple as that and to make it even more effective you can change the colour of the page background and also the browser background for even more effect. Just open Inspector and go to Page Layout where all these changes can be made.

  • Preloader for External file Template question

    I used the CS5 Flash templates>sample files>preloader for external file, to create my preloader.
    The problem is that when the preloader is done and my SWF is loaded, my SWF has already started playing.
    It is an animation that builds for 200 frames then buttons appear. By the time the SWF appears it has already gotten to the button frame.
    Depending on connection speed I have caught the animation building.
    Is there some action script I should put in my preloader or the first frame of my SWF to pause play?
    Here is the preloader action:
    var contentLoader:Loader;
    loadContent("stage002.swf");
    function loadContent(url:String):void {
        contentLoader = new Loader();
        contentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
        contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded);
        contentLoader.load(new URLRequest(url));
    function contentLoaded(evt:Event):void {
        //Optionally change to a clip holder and set progressbar visibility.
        addChild(contentLoader);
    function loading(evt:ProgressEvent):void {
        var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
        setBarProgress(loaded);
    function setBarProgress(value:Number) {
        progressbar.bar.scaleX = value;
    Thanks in advance!

    put a stop() on the first frame of your external swf in an otherwise empty first frame.  when preloading is complete apply a play() to your loader's content cast as a movieclip:
    function contentLoaded(evt:Event):void {
        //Optionally change to a clip holder and set progressbar visibility.
        addChild(contentLoader);
    MovieClip(contentLoader.content).play();

  • Time of Individual Frame in IPhoto:  Redux Clarification

    Cannot adjust time of individual frame in slideshow IN IPHOTO 08 itself. Time choice "frozen' at the standard 3 secs setting for the rest of the slideshow. The button in 'ADJUST' selection doesn't respond to mouse click.
    Thanks

    Welcome to the Apple Discussions. Try the following: close iPhoto, delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your User/Library/Preferences folder, launch iPhoto and see if that helps.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier versions) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. There are versions that are compatible with iPhoto 5, 6, 7 and 8 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    NOTE: iPhoto 8's new option in the library rebuild pane, "Rebuild the iPhoto Library Database from automatic backup" may make this tip obsolete. We'll know when users have occasion to use it and see if that's the case.

  • Preloader not on frame 1

    ok,so this is probably a stupidly simple fix, BUT - i have tinkered with it for a few hours now and im getting no where....
    i have my site tween in a graphic ( my logo ), and then the preloader pops up......
    the preloader is on frame 15 inside its own MC....
    inside the MC is another MC named loadBar, and here is the code:
    function loadProgress(root:ProgressEvent):void {
    var percent:Number = Math.floor( (root.bytesLoaded*100)/root.bytesTotal );
    loadBar.width = percent * 3;
    function loadComplete(e:Event):void {
    loadBar.width = 300;
    MovieClip(root).gotoAndPlay("begin");
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
    loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    now, if you have the MC that has the preloader on frame 1, it works....but since its on frame 15, its not doing anything.....
    what am i overlooking? im sure this question is on the newbie level  -  any help or direction is appreciated...
    as always - thanks!
    wr3ck

    you're not out of luck.
    there's just no point to having a preloader appear long after everything's loaded.  you can use the following if it makes you feel better:
    var t:Timer=new Timer(500,1);
    t.addEventListener(TimerEvent.TIMER,f);
    t.start();
    function f(e:Event){
        MovieClip(root).gotoAndPlay("begin");
    function loadProgress(e:ProgressEvent):void {
        var percent:Number = Math.floor(  (e.bytesLoaded*100)/e.bytesTotal );
        t.stop();
        loadBar.width  = percent * 3;
    function loadComplete(e:Event):void {
        loadBar.width  = 300;
        MovieClip(root).gotoAndPlay("begin");
    this.parent.loaderInfo.addEventListener(ProgressEvent.PROGRESS,  loadProgress);this.parent.loaderInfo.addEventListener(Event.COMPLETE,  loadComplete);

  • INdividual Frames disappear

    I am having problems with the individual frames on the
    timeline disappearing. I have reset the settings multiple times and
    cannot find any settings to put the individual frames back on. It
    seems like a system wide preference because all users on the
    machine have the same issue. Can anyone help?

    A few things:
    How much time are you willing to devote to finding a precise frame among the hundred of thousands that would be generated in single 12-hour period?  Actually, it would be 1,294,704 in 12 hours; I did the arithmetic.  Wouldn't the closest second be adequate?
    Virtual Dub?  For your ends, I say, "Ugh!"
    Attaching a camera to a tree isn't a bad idea; attaching a camera to a sapling or a very young tree is a different story.  You need a stable mount.
    Apparently the exposure of the image isn't a very big concern, which is fine if it's okay with you.
    In AE, you can run video backwards.  You can use Time Remapping, or you can go to the Stretch panel and set it to negative 100.  You'd have to move the clip in the timeline if you use it.
    All in all, I get the notion that you're trying to use AE for something it wasn't designed to do.  It's primarily for effects and compositing of images shot for commercial video/film production. 
    Engineers, while a being a most admirable group of individuals, aren't necessarily the prime users of the application.  You might want to investigate other avenues.
    Now, I hope for your sake that I'm all wet in my remarks.  I hope other people have better solutions than mine for your situation.  Time will tell.

Maybe you are looking for

  • IDOC : Message Function 003: Delete Object contains message to be deleted.

    Hi, I am trying to process a Customer master Icreation DOC (OILDEB06) which has a Message function 003: with the description Delete Object contains message to be deleted. I am testing my IDOC, when should I be using this message function. If you can

  • Telephone number format in Contacts

    Telephone #s in my address book are formatted (123) 456-7890.  Since almost all calls now require all 10 digits, I prefer 123-456-7890.  I don't know why it always converts to this setting -- and I don't see any place in Preferences to change it.

  • Can't buy just one month subscription...

    Hello, I'm trying to buy one month subscription to Poland landline but I can't, instead it gives me three month subscription that I don't really need... Anyone know how to make it just for one month? I tried another countries and it shows one month s

  • Importing people tags from PS Elements 11 to Lightroom 4

    On first use of Lightroom 4, some people tags from PS elements 11 were not imported on the conversion, while others were.  Is there a fix for this?

  • Enable Profile (ACR) and Filter Lens Corrections does not recognize Lens

    I did several searches and couldn't find this so it may be a new question. I'm running into it in both CS5 (Camera Raw and Filter > Lens Corrections) and Lightroom 3.3 (Develop- Enable Profile). I'm asking here since I figure if I can fix CS5, I'll k