Load a different image to stage

Hi there,
I am trying to place an image on the homepage of a website i
am building but i want the image to change every time the page
loads. could anyone give me an idea on how to set this up or know
of a good tutorial? my client is a photographer so they want to
display a different photo every time the page reloads. i also want
the anchor point of the image to be at the top left so the image
begins at the same place. Any ideas? thanks in advance.

Sure. The basic idea is simple. You want to load a random
image. Flash only provides one means of generating anything random
and it's the random() method of the Math class.
By itself, random() is only going to help you generate a
number. But if you take it one step further and append that number
result to ".jpg", what you'll get is a String pointing to the
filename of an image in this case 1.jpg. For instance
// Math.random() returns a 1 stored in a variable named pic
var myFile:String = pic + ".jpg";
Now you can use loadMovie, MovieClipLoader (both AS2) or the
Loader class (AS3) to load the file onto the stage. I'll show
MovieClipLoader and Loader
// MovieClipLoader - assumes images loading are in same
directory as swf
var myMCL:MovieClipLoader = new MovieClipLoader();
myMCL.loadClip( myFile );
// Loader - assumes same as above
var _ldr:Loader = new Loader();
addChild( _ldr );
_ldr.load( new URLRequest( myFile ) );
The only code you need to control is the Math.random() so
that you put an upper and lower bound on the returned result. You
can find help with that inside the Flash documentation.
Hope this helps.

Similar Messages

  • Cant load image to stage with loader

    thoughts?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderColor="#FFFFFF" creationComplete="init()"
         width="100%" height="100%">
    <mx:Script>
         <![CDATA[
             import flash.media.Sound;
             import flash.media.SoundChannel;
             import flash.net.URLRequest;
             import flash.display.Loader;
             private var song:SoundChannel;
             private var request:URLRequest = new URLRequest("Gun_44magnum.wav");
            private var soundFactory:Sound = new Sound();
            private var img:Loader = new Loader();
              private function init():void{
                   addEventListener(MouseEvent.CLICK, shootScreen);
                  soundFactory.load(request);
                  img.load(new URLRequest("bulletHole.jpg"));
                  img.contentLoaderInfo.addEventListener(Event.COMPLETE, shootScreen);
              private function shootScreen(e:Event):void{
              // song = soundFactory.play();
                   trace("loaded");
                   addChild(img);
         ]]>
    </mx:Script>
    </mx:WindowedApplication>
    error
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@157ea281 to mx.core.IUIComponent.
         at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:3259]
         at mx.core::Container/addChildAt()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2207]
         at mx.core::Container/addChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2140]
         at bangBang/shootScreen()[/Volumes/Files/Canulla/Brodeur/prof_dev/bangBang/src/bangBang.mxml:41]

    img.addEventListener(Event.added, loadImage);//img is your loader, loader is not image...
    func loadImage(e)
    var image:Image = new Image();
    image.source = e.currentTarget.content;
    addChild(image);

  • How to apply one animation to play 30 different images?

    I'm brand new to Edge Animate and I'm struggling to find the answer to this.
    I have an image that comes on to the screen from the left, then stops, then user clicks a button and the image exits stage right and next image needs to come on from stage left and do the exact same thing; user clicks same button as before, new image exits stage right and next image comes in stage left.
    This is repeated 30 times for 30 different images of drinks, so instead of animating every image is there a way to code it so i can get each image to automatically come on next after the user has clicked the button and the current image has exited?
    It's probably really straight forward but I just can't figure it out!

    Here is how I would do it but this is just me! Smarter people do other things.
    do no use the main timeline
    make one symbol with an out transition and an in transition of an empty div the size of your image or put the image in.
    add labels in and out
    if your images are all the same size you can load them in the same div as a background image or change your image to img instead of div a load the images
    load your images on a click event and play the symbol's labels
    var images = ['cat','dog','mouse','chicken','rabbit'];
    i=0;
    click event
    i++;
    sym.getSymbol('SymbolName').play('in');
    // as a background image of a div
    sym.getSymbol('SymbolName').$('imageContainerName').css({'background-image':'url("images/' +images[i]+'.jpg")';
    // as an img  (you need to change the div to img by selecting the image and changing div to img (top left of the left panel)
    sym.getSymbol('SymbolName').$('imageContainerName').attr('src','images/' + images[i]+'.jpg');
    You can also write the click event in composition ready:
    sym.$('button').click(function(){
    i++;
    sym.getSymbol('SymbolName').play('in');
    // as a background image of a div
    sym.getSymbol('SymbolName').$('imageContainerName').css({'background-image':'url("images/' +images[i]+'.jpg")';
    // as an img  (you need to change the div to img by selecting the image and changing div to img (top left of the left panel)
    sym.getSymbol('SymbolName').$('imageContainerName').attr('src','images/' + images[i]+'.jpg');
    You could also do that with a json file to load your images into your symbol:
    see rudimentary example i made a long time ago for a history course sample here: https://app.box.com/s/nadfi5pjmida4jplci6i
    Hope this makes sense.

  • Smooth load of enternal images

    Hey folks,
    I have a slideshow that I want to play fullscreen, but there
    are a lot of photos, so I don't want to load them all in at the
    start. However, when I load them on demand, the slideshow will
    freeze for a moment while they load in the background. I know there
    must be something I can do differently so that these can load in
    the background, and just fire an event when they're ready, but I
    can't seem to find what I'm looking for. Any ideas?
    - B

    BSpero:
    Without downloading all the images during the preload stage
    there isn't a 100% sure fire work around for preventing the freeze
    as a user clicks on an image however there is a possible
    compromise. You need to create an image loading queue class to
    manage the loading of the images in the background once the movie
    is displayed. The queue will progressively load the image assets in
    the background as the movie is playing. The queue needs to be
    designed to handle events from the user that will halt the current
    image being loaded and move the current non loaded image to the top
    of the queue. i.e.
    < load first image and display >
    < movie starts >
    < begin loading queue >
    user clicks image,
    < is image loaded ? >
    - If yes then display
    - If no then halt current loading image
    < search loader queue for matching image id >
    < load image >
    < once image loaded display then go back to beginning of
    queue and start >
    Hope this helps

  • How to load a PNG image from a location in CF card

    Hi,
    I am using WTK 2.5.2. I wanted to load a PNG image to Image object. The image is loaded when I have it in the classes folder. But I want to select different image from a different location. If I try to open an Image to createImage(String) from a different location, I get IOException.
    Please help me.
    Thanks
    Deekshit M

    I got the answer, I should be using Image.createImage(InputStream) API. It works fine.
    Thanks
    DM

  • CS5 Image Processor - One script, different image sizes and save locations

    Hello guys!
    is it possible to make one script to convert several images to different image sizes which should be saved in different locations?
    The xml structure is clear, but photoshop accepts only the second "script" if i load a test xml file with two scripts in it.
    Thanks a lot !!!
    Best Regards,
    Tobias

    Hey!
    i solved the problem with an action in which i changed the picture size 4 times (4 times saving for web included)
    its perfect for my needs!
    thanks anyway

  • Loading only last image

    This code is loading the xml correctly, populating the mainClipArray correctly, but only adding the last image to the stage.
    I think it is not waiting for completeClipLoad() to complete.  I tried removing :void from the function to see if waiting for a return would do it, but no luck.
    Any ideas?
    CODE:
    var myXML:XML;
    var xmlLoader:URLLoader = new URLLoader();
    var mainClipArray:Array = [];
    var counter:int = 0;
    var myLoader:Loader = new Loader();
    xmlLoader.load(new URLRequest("portfolio.xml"));
    xmlLoader.addEventListener(Event.COMPLETE, completeXMLLoad);
    function completeXMLLoad(e:Event):void{
        myXML = XML(e.target.data);
        var len:int = myXML.portfolio.unit.length();
        for(var i:int = 0; i<len; i++){
            counter = i;
            mainClipArray[i] = new pane();
            //Load small image
            var smallfilename = myXML.portfolio.unit[i].small.filename;
            myLoader.load(new URLRequest(smallfilename));
            myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeClipLoad);
            mainClipArray[i].x = i * 15;
            addChild(mainClipArray[i]);
    function completeClipLoad(e:Event):void{
        trace("made it in");
        mainClipArray[counter].addChild(myLoader);
        trace("added child");

    Delaying the progress isn't going to help if you still have only one loader.  I would say that you could move the var myLoader:Loader = new Loader(); line inside the loop so that you have a new loader instance for each loading occurence, but then you would also need to adjust the completeClipLoad function to use the event target (e.target) instead of "myLoader".  But that still wouldn't resolve matters completely because you have that counter variable that will be working as fast as the for loop, with the loop likely finishing before the first item gets loaded... and since your completeClipLoad also makes use of that variable, you'll end up with only the last pane object being used.
    If you want to control the order of loading and retain the code in the one place (the other suggestion offered above having the code inside the pane could also be a viable approach), then a better strategy is to to use a programmed loop rather than a for loop, where only one loading occurs at a time and the completion of one loading triggers the next to begin.  Something like (this is just an outline form)...
    counter = 0;
    imgArray;
    function completeXMLLoad(e:Event):void{
         ... // process all the xml into the imgAray
        loadSmallImage(); // start by loading the first image only
    function loadSmallImage(){
         // create loader instance
         // assign load complete listener
         // load imgArray[counter]
    function loadComplete(e:Event) {
         // process the loaded image in a new pane
         // increment counter
         // if counter is < imgArray.length -> loadSmallImage();

  • JDeveloper 11g just displays Loading... image only

    Hi,
    I am having problem in testing my web application. i m using JDeveloper 11g 11.1.1.0.0 and ADF faces.
    the problem occurs whenever i run my web application. the browser displays white page with Loading... image and keeps showing this image and nothing else happen.
    this happened when i build my web from scratch but when i used applications workspace that i downloaded from the tutorial websites the problem does not happen.
    any help would be appriciated.

    here is my Log file...... plz suggest any solution ....... i tried my application on different machine as well not working.....
    C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\DefaultDomain\bin\startWebLogic.cmd
    [waiting for the server to complete its initialization...]
    JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=48m -XX:MaxPermSize=192m
    WLS Start Mode=Development
    CLASSPATH=;C:\oracle\MIDDLE~1\patch_wls1030\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\oracle\MIDDLE~1\patch_jdev1111\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\oracle\MIDDLE~1\patch_cie660\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\oracle\MIDDLE~1\JDK160~1\lib\tools.jar;C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic_sp.jar;C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.jar;C:\oracle\MIDDLE~1\modules\features\weblogic.server.modules_10.3.0.0.jar;C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\webservices.jar;C:\oracle\MIDDLE~1\modules\ORGAPA~1.5/lib/ant-all.jar;C:\oracle\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar;C:\Oracle\Middleware\jdeveloper\modules\features\adf.share_11.1.1.jar;;C:\oracle\MIDDLE~1\WLSERV~1.3\common\eval\pointbase\lib\pbclient57.jar;C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar;;
    PATH=C:\oracle\MIDDLE~1\patch_wls1030\profiles\default\native;C:\oracle\MIDDLE~1\patch_jdev1111\profiles\default\native;C:\oracle\MIDDLE~1\patch_cie660\profiles\default\native;C:\oracle\MIDDLE~1\WLSERV~1.3\server\native\win\32;C:\oracle\MIDDLE~1\WLSERV~1.3\server\bin;C:\oracle\MIDDLE~1\modules\ORGAPA~1.5\bin;C:\oracle\MIDDLE~1\JDK160~1\jre\bin;C:\oracle\MIDDLE~1\JDK160~1\bin;C:\oracle\FRHome_1\jdk\jre\bin\classic;C:\oracle\FRHome_1\jdk\jre\bin;C:\oracle\FRHome_1\bin;C:\oracle\FRHome_1\jlib;C:\oracle\BIToolsHome_1\jdk\jre\bin\classic;C:\oracle\BIToolsHome_1\jdk\jre\bin;C:\oracle\BIToolsHome_1\jlib;C:\oracle\BIToolsHome_1\jre\1.4.2\bin\client;C:\oracle\BIToolsHome_1\jre\1.4.2\bin;C:\DevSuiteHome_1\jdk\jre\bin\classic;C:\DevSuiteHome_1\jdk\jre\bin;C:\DevSuiteHome_1\jdk\jre\bin\client;C:\DevSuiteHome_1\jlib;C:\DevSuiteHome_1\bin;C:\DevSuiteHome_1\jre\1.4.2\bin\client;C:\DevSuiteHome_1\jre\1.4.2\bin;C:\oracle\product\10.1.0\db_1\bin;C:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;C:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\oracle\MIDDLE~1\WLSERV~1.3\server\native\win\32\oci920_8
    * To start WebLogic Server, use a username and *
    * password assigned to an admin-level user. For *
    * server administration, use the WebLogic Server *
    * console at http:\\hostname:port\console *
    starting weblogic with Java version:
    java version "1.6.0_05"
    Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
    Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)
    Starting WLS with line:
    C:\oracle\MIDDLE~1\JDK160~1\bin\java -client -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=48m -XX:MaxPermSize=192m -Xverify:none -da -Dplatform.home=C:\oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=C:\oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=C:\oracle\MIDDLE~1\WLSERV~1.3\server -Ddomain.home=C:\oracle\MIDDLE~1\JDEVEL~1\system\SYSTEM~1.05\DEFAUL~1 -Doracle.home=C:\Oracle\Middleware\jdeveloper -Doracle.security.jps.config=C:\oracle\MIDDLE~1\JDEVEL~1\system\SYSTEM~1.05\DEFAUL~1\config\oracle\jps-config.xml -Doracle.dms.context=OFF -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=C:\oracle\MIDDLE~1\patch_wls1030\profiles\default\sysext_manifest_classpath;C:\oracle\MIDDLE~1\patch_jdev1111\profiles\default\sysext_manifest_classpath;C:\oracle\MIDDLE~1\patch_cie660\profiles\default\sysext_manifest_classpath -Dweblogic.Name=DefaultServer -Djava.security.policy=C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.policy weblogic.Server
    <Aug 4, 2009 7:36:58 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
    C:\oracle\Middleware\patch_wls1030\profiles\default\sysext_manifest_classpath\weblogic_ext_patch.jar;C:\oracle\Middleware\wlserver_10.3\L10N\beehive_ja.jar;C:\oracle\Middleware\wlserver_10.3\L10N\beehive_ko.jar;C:\oracle\Middleware\wlserver_10.3\L10N\beehive_zh_CN.jar;C:\oracle\Middleware\wlserver_10.3\L10N\beehive_zh_TW.jar;C:\oracle\Middleware\wlserver_10.3\L10N\p13n_wls_ja.jar;C:\oracle\Middleware\wlserver_10.3\L10N\p13n_wls_ko.jar;C:\oracle\Middleware\wlserver_10.3\L10N\p13n_wls_zh_CN.jar;C:\oracle\Middleware\wlserver_10.3\L10N\p13n_wls_zh_TW.jar;C:\oracle\Middleware\wlserver_10.3\L10N\testclient_ja.jar;C:\oracle\Middleware\wlserver_10.3\L10N\testclient_ko.jar;C:\oracle\Middleware\wlserver_10.3\L10N\testclient_zh_CN.jar;C:\oracle\Middleware\wlserver_10.3\L10N\testclient_zh_TW.jar;C:\oracle\Middleware\wlserver_10.3\L10N\tuxedocontrol_ja.jar;C:\oracle\Middleware\wlserver_10.3\L10N\tuxedocontrol_ko.jar;C:\oracle\Middleware\wlserver_10.3\L10N\tuxedocontrol_zh_CN.jar;C:\oracle\Middleware\wlserver_10.3\L10N\tuxedocontrol_zh_TW.jar;C:\oracle\Middleware\wlserver_10.3\L10N\workshop_ja.jar;C:\oracle\Middleware\wlserver_10.3\L10N\workshop_ko.jar;C:\oracle\Middleware\wlserver_10.3\L10N\workshop_zh_CN.jar;C:\oracle\Middleware\wlserver_10.3\L10N\workshop_zh_TW.jar>
    <Aug 4, 2009 7:36:59 AM GMT-06:00> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 10.0-b19 from Sun Microsystems Inc.>
    <Aug 4, 2009 7:36:59 AM GMT-06:00> <Info> <Management> <BEA-141107> <Version: WebLogic Server Temporary Patch for CR380042 Thu Sep 11 13:33:40 PDT 2008
    WebLogic Server Temporary Patch for 7372756 Fri Sep 12 17:05:44 EDT 2008
    WebLogic Server Temporary Patch for CR381265 Wed Oct 08 10:15:58 PDT 2008
    WebLogic Server Temporary Patch for CR380913 Wed Oct 15 13:24:22 PDT 2008
    WebLogic Server Temporary Patch for CR382965 Fri Nov 21 15:51:48 PST 2008
    WebLogic Server Temporary Patch for CR383260 Thu Nov 20 12:58:15 PST 2008
    WebLogic Server Temporary Patch for CR383202 Fri Nov 21 09:58:15 PST 2008
    WebLogic Server 10.3 Mon Aug 18 22:39:18 EDT 2008 1142987 >
    <Aug 4, 2009 7:37:01 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Aug 4, 2009 7:37:01 AM GMT-06:00> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
    <Aug 4, 2009 7:37:01 AM GMT-06:00> <Notice> <Log Management> <BEA-170019> <The server log file C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\DefaultDomain\servers\DefaultServer\logs\DefaultServer.log is opened. All server side log events will be written to this file.>
    <Aug 4, 2009 7:37:11 AM GMT-06:00> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
    <Aug 4, 2009 7:37:16 AM GMT-06:00> <Warning> <Deployer> <BEA-149617> <Non-critical internal application uddi was not deployed. Error: [Deployer:149158]No application files exist at 'C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\uddi.war'.>
    <Aug 4, 2009 7:37:16 AM GMT-06:00> <Warning> <Deployer> <BEA-149617> <Non-critical internal application uddiexplorer was not deployed. Error: [Deployer:149158]No application files exist at 'C:\oracle\MIDDLE~1\WLSERV~1.3\server\lib\uddiexplorer.war'.>
    <Aug 4, 2009 7:37:18 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
    <Aug 4, 2009 7:37:18 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:7101 for protocols iiop, t3, ldap, snmp, http.>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 192.168.1.30:7101 for protocols iiop, t3, ldap, snmp, http.>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "DefaultServer" for domain "DefaultDomain" running in Development Mode>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Warning> <Server> <BEA-002611> <Hostname "SPC", maps to multiple IP addresses: 192.168.1.30, 127.0.0.1>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Warning> <Server> <BEA-002611> <Hostname "localhost", maps to multiple IP addresses: 192.168.1.30, 127.0.0.1>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
    <Aug 4, 2009 7:37:20 AM GMT-06:00> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
    DefaultServer startup time: 31156 ms.
    DefaultServer started.
    [Running application Fusion_app on Server Instance DefaultServer...]
    Uploading credentials.
    ---- Deployment started. ---- Aug 4, 2009 7:37:27 AM
    Target platform is (Weblogic 10.3).
    Running dependency analysis...
    2009-08-04 07:37:28.234: Writing WAR file to C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\o.j2ee\drs\Fusion_app\Fusion_app-ViewController-webapp
    2009-08-04 07:37:28.359: Wrote WAR file to C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\o.j2ee\drs\Fusion_app\Fusion_app-ViewController-webapp
    2009-08-04 07:37:30.796: Writing EAR file to C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\o.j2ee\drs\Fusion_app
    2009-08-04 07:37:30.843: Wrote EAR file to C:\oracle\Middleware\jdeveloper\system\system11.1.1.0.31.52.05\o.j2ee\drs\Fusion_app
    Deploying Application...
    <Aug 4, 2009 7:37:35 AM GMT-06:00> <Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application Fusion_app is not versioned.>
    Aug 4, 2009 7:37:35 AM oracle.adf.share.config.ADFConfigFactory cleanUpApplicationState
    INFO: Cleaning up application state
    Aug 4, 2009 7:37:36 AM oracle.as.jmx.framework.PortableMBeanFactory setJMXFrameworkProviderClass
    INFO: JMX Portable Framework initialized with platform SPI "class oracle.as.jmx.framework.wls.spi.JMXFrameworkProviderImpl"
    Aug 4, 2009 7:38:08 AM oracle.adfinternal.view.faces.partition.FeatureUtils _addFeatures
    WARNING: A duplicate definition for the feature "AdfDvtGraph" has been found at zip:C:/oracle/Middleware/jdeveloper/system/system11.1.1.0.31.52.05/DefaultDomain/servers/DefaultServer/tmp/_WL_user/Fusion_app/vhyezh/war/WEB-INF/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 3. A feature with the same name was originally defined at zip:C:/oracle/Middleware/jdeveloper/dvt/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 3. This may indicate that multiple copies of the same jar file are present on the class path. Ignoring the new feature definition.
    Aug 4, 2009 7:38:08 AM oracle.adfinternal.view.faces.partition.FeatureUtils _addFeatures
    WARNING: A duplicate definition for the feature "AdfDvtGauge" has been found at zip:C:/oracle/Middleware/jdeveloper/system/system11.1.1.0.31.52.05/DefaultDomain/servers/DefaultServer/tmp/_WL_user/Fusion_app/vhyezh/war/WEB-INF/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 7. A feature with the same name was originally defined at zip:C:/oracle/Middleware/jdeveloper/dvt/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 7. This may indicate that multiple copies of the same jar file are present on the class path. Ignoring the new feature definition.
    Aug 4, 2009 7:38:08 AM oracle.adfinternal.view.faces.partition.FeatureUtils _addFeatures
    WARNING: A duplicate definition for the feature "AdfRichPivotTable" has been found at zip:C:/oracle/Middleware/jdeveloper/system/system11.1.1.0.31.52.05/DefaultDomain/servers/DefaultServer/tmp/_WL_user/Fusion_app/vhyezh/war/WEB-INF/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 11. A feature with the same name was originally defined at zip:C:/oracle/Middleware/jdeveloper/dvt/lib/dvt-faces.jar!/META-INF/adf-js-features.xml, line 11. This may indicate that multiple copies of the same jar file are present on the class path. Ignoring the new feature definition.
    Application Deployed Successfully.
    Elapsed time for deployment: 42 seconds
    ---- Deployment finished. ---- Aug 4, 2009 7:38:09 AM
    Run startup time: 43562 ms.
    [Application Fusion_app deployed to Server Instance DefaultServer]
    Target URL -- http://127.0.0.1:7101/Fusion_app-ViewController-context-root/faces/adf.task-flow?adf.tfId=orders-flow&adf.tfDoc=/WEB-INF/orders-flow.xml
    Aug 4, 2009 7:38:22 AM oracle.adfinternal.controller.faces.lifecycle.JSFLifecycleImpl setLifecycleContextBuilder
    WARNING: ADFc: Replacing the ADF Page Lifecycle implementation with 'oracle.adfinternal.controller.application.model.JSFDataBindingLifecycleContextBuilder'.
    Aug 4, 2009 7:38:22 AM oracle.adfinternal.controller.util.model.AdfmInterface initialize
    INFO: ADFc: BindingContext is present, using ADFm APIs for DataControlFrames.
    Aug 4, 2009 7:38:23 AM oracle.adfinternal.controller.metadata.provider.MdsMetadataResourceProvider <init>
    INFO: ADFc: Controller caching of MDS metadata resources ENABLED.
    <Aug 4, 2009 7:38:33 AM GMT-06:00> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@185aa63 - appName: 'Fusion_app', name: 'Fusion_app-ViewController-context-root', context-path: '/Fusion_app-ViewController-context-root', spec-version: '2.5', request: weblogic.servlet.internal.ServletRequestImpl@385e76[
    GET /Fusion_app-ViewController-context-root/faces/adf.task-flow?adf.tfId=orders-flow&adf.tfDoc=/WEB-INF/orders-flow.xml HTTP/1.1
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    ]] Root cause of ServletException.
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.sql.SQLDataException, msg=ORA-01882: timezone region not found
         at oracle.jbo.server.OracleSQLBuilderImpl.setSessionTimeZone(OracleSQLBuilderImpl.java:4957)
         at oracle.jbo.server.DBTransactionImpl.refreshConnectionMetadata(DBTransactionImpl.java:5054)
         at oracle.jbo.server.DBTransactionImpl.initTransaction(DBTransactionImpl.java:1280)
         at oracle.jbo.server.DBTransactionImpl.initTxn(DBTransactionImpl.java:6415)
         at oracle.jbo.server.DBTransactionImpl2.connect(DBTransactionImpl2.java:118)
         Truncated. see log file for complete stacktrace
    java.sql.SQLDataException: ORA-01882: timezone region not found
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:79)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:116)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:177)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         Truncated. see log file for complete stacktrace
    >
    <Aug 4, 2009 7:39:39 AM GMT-06:00> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@185aa63 - appName: 'Fusion_app', name: 'Fusion_app-ViewController-context-root', context-path: '/Fusion_app-ViewController-context-root', spec-version: '2.5', request: weblogic.servlet.internal.ServletRequestImpl@9d476e[
    GET /Fusion_app-ViewController-context-root/faces/adf.task-flow?adf.tfId=orders-flow&adf.tfDoc=/WEB-INF/orders-flow.xml HTTP/1.1
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Cookie: JSESSIONID=6TpJK45GLsdg1ZRfJdypDhC7ZgQzJybRrZLPWbd6WKdxpV1gv5yM!2087942931
    Cache-Control: max-age=0
    ]] Root cause of ServletException.
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.sql.SQLDataException, msg=ORA-01882: timezone region not found
         at oracle.jbo.server.OracleSQLBuilderImpl.setSessionTimeZone(OracleSQLBuilderImpl.java:4957)
         at oracle.jbo.server.DBTransactionImpl.refreshConnectionMetadata(DBTransactionImpl.java:5054)
         at oracle.jbo.server.DBTransactionImpl.initTransaction(DBTransactionImpl.java:1280)
         at oracle.jbo.server.DBTransactionImpl.initTxn(DBTransactionImpl.java:6415)
         at oracle.jbo.server.DBTransactionImpl2.connect(DBTransactionImpl2.java:118)
         Truncated. see log file for complete stacktrace
    java.sql.SQLDataException: ORA-01882: timezone region not found
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:79)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:116)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:177)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         Truncated. see log file for complete stacktrace
    >

  • Optimization on Load Time (Large Images and Sounds)

    Hi,
    I have an all flash website that works by having each portion of it to load and unload in the center of a frame based off the navigation chosen.  Load times on everything but one part of my site are ok.
    The dimensions of the part inside the frame are 968x674.  I know that's relatively large for a flash file, but that can't be changed at this point.
    Within the page there are objects that come up when you find an item on the screen.  Its a dialog box and it shows text, an image, and has a voice over that reads what the text says.  After you're done looking at it, there is an x-button to dismiss the window.  There are 15 of these and they are exported to the actionscript.  I add them in the actionscript via addChild.  I figured this is a huge spot that could be reconfigured, but I'm not sure if it would make much a difference.
    The other huge thing is there is a ton on the screen.  It starts you off in an environment, and when you click 3 different sections, it zooms into that portion allowing you to look for the items you're trying to find.
    There is also a man that talks and animates in the beginning and at the end.  We are planning on taking out the end part and putting a text box up.
    Here is the website..  its a propane safety site for kids.  I know its kind of a weird idea, but it works and people seem to like it.
    www.propanekids.com
    The two parts of the site we are trying to optimize is the main menu when you first are at the site, and the "Explore" section.  (Just click on the cloud on the front page.
    If someone could take the time to give me some new ideas of how I can get these loading times down, I would greatly appreciate it!
    Thanks

    Ok, who ever posted this message is hacking me  and i can't believe you guys are helping
    Date: Thu, 27 Jan 2011 11:07:28 -0700
    From: [email protected]
    To: [email protected]
    Subject: Optimization on Load Time (Large Images and Sounds)
    Hi,
    I have an all flash website that works by having each portion of it to load and unload in the center of a frame based off the navigation chosen.  Load times on everything but one part of my site are ok.
    The dimensions of the part inside the frame are 968x674.  I know that's relatively large for a flash file, but that can't be changed at this point.
    Within the page there are objects that come up when you find an item on the screen.  Its a dialog box and it shows text, an image, and has a voice over that reads what the text says.  After you're done looking at it, there is an x-button to dismiss the window.  There are 15 of these and they are exported to the actionscript.  I add them in the actionscript via addChild.  I figured this is a huge spot that could be reconfigured, but I'm not sure if it would make much a difference.
    The other huge thing is there is a ton on the screen.  It starts you off in an environment, and when you click 3 different sections, it zooms into that portion allowing you to look for the items you're trying to find.
    There is also a man that talks and animates in the beginning and at the end.  We are planning on taking out the end part and putting a text box up.
    Here is the website..  its a propane safety site for kids.  I know its kind of a weird idea, but it works and people seem to like it.
    http://www.propanekids.com
    The two parts of the site we are trying to optimize is the main menu when you first are at the site, and the "Explore" section.  (Just click on the cloud on the front page.
    If someone could take the time to give me some new ideas of how I can get these loading times down, I would greatly appreciate it!
    Thanks
    >

  • URGENT : Please HELP : Loading a first image too slow

    Hello,
    I want to load an image to save it just before in a JPG format so as to obtain finally a byte[] array of this JPG image result.
    So, to do it, I tried to load my Image from different ways but I have always a strange comportement... My problem come from the reading :
    First, I use the imageio classes...
    FileImageInputStream fiis = new FileImageInputStream(file);
    BufferedImage input = ImageIO.read(fiis);
    And then, I use the oldest method :
    Image image = new ImageIcon(file.getAbsolutePath()).getImage();
    BufferedImage input = new BufferedImage(image.getWidth(panel), image.getHeight(panel),BufferedImage.TYPE_INT_RGB);
    and also :
    Image image = new ImageIcon(file.getAbsolutePath()).getImage();
    BufferedImage input = toBufferedImage(picture);
    But finally, I understood my problem is that the first time I load an image (no matter the format, JPG, BMP, TIFF... or other) the loading phase is very slow and lasts at least 30 sec. But then, every loading that I do will gonna be really fast. (No more than 1 sec.) It's look like if the first time there was a kind of dinamical alocation or something like that.... but I tried to find some configuration parameters to set it... But without success. :-(
    If someone could have an idea to suggest me... it would help me very much.
    Thanks in advance for your help,
    Anthony

    Please someone can help me ?!? A suggestion ?
    I have tried today one more time to resolve this issue... but without success... Anything I do with the loading of an image... by imageio or other ways... it's still the same problem... the first time I load an image, it takes me 40 - 50 sec to load it and after this first load, it is very fast with others... and with every formats. It's not a question of format but of memory allocation, I think... but I'm not sure...
    PRECISION : I work with an applet, is there something to configurate to allocate some memories or another thing ?!?
    Thanks in advance for your help, I really need it just right now... I have to finish this job extremly fast !!!
    Regards,
    Anthony

  • Load multiple external images

    If you load say 3 external images in AS3 and want to run a function "useImages()" only once all three images have loaded what is the best way of listening for them to complete loading.
    EG;
    loader1.addEventListener(Eveent.COMPLETE, incLoader)
    loader2.addEventListener(Eveent.COMPLETE, incLoader)
    loader2.addEventListener(Eveent.COMPLETE, incLoader)
    function incLoader(event:Event)
         numLoaded ++
         if (numLoaded == 3)
                   useImages()
    There must be a better way than the above.
    Any feedback would be much appreciated
    Thanks

    Here's a set of functions I used to load pages into a flip page magazine app.  They keep track of how many pages are supposed to load and how many actually load.  I also used an XML file that the web people can update so that it loads different images.  You can add the loader objects in the loaders Array into any DisplayObjectContainer:
    var pageCount:int = 3;
    var pagesLoaded:int = 0;
    var loaders:Array = new Array;
    public function loadPage(aPage:String):void
      var pictLdr:Loader = new Loader();
      var pictURLReq:URLRequest = new URLRequest(aPage);
      pictLdr.load(pictURLReq);
      pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
      pictLdr.addEventListener(IOErrorEvent.IO_ERROR, pictErrorHandler);
      loaders.push(pictLdr);
      updateLoadText();
    private function imgLoaded(event:Event):void
      pagesLoaded++;
      addPagesToFlipBook();
    private function pictErrorHandler(event:IOErrorEvent):void
      var ldrInfo:LoaderInfo = LoaderInfo(event.target);
      loaders.splice(loaders.indexOf(ldrInfo.loader), 1);
      pageCount--;
      addPagesToFlipBook();
    private function updateLoadText():void
      errorText.text = "Loading image " + (pagesLoaded + 1) + " of " + pageCount + "..."
    private function addPagesToFlipBook():void
      updateLoadText();
      if (pagesLoaded == pageCount)
        ... do more stuff
    *edit* How do I create a code window for code?

  • How to apply alpah to BitmapFill when drawing image to stage??

    I'm just starting with AS3 from AS2, but understand basics of code, so bear with me.
    I got this code from www.kirupa.com; it writes an image to stage as a way of tile it.
    holidaytile is an instance of a Gif Image.
    But I want to change the Alpha so that my top layer shows through it, and I can't seem
    to figure out how to do that.
    import flash.display.BitmapData;
    var tile:BitmapData = BitmapData.loadBitmap("holidaytile");
    this.beginBitmapFill(tile);
    this.lineTo(Stage.width,0);
    this.lineTo(Stage.width, Stage.height);
    this.lineTo(0, Stage.height);
    this.lineTo(0, 0);
    this.endFill();
    Thanks if you can help, I'll keep looking
    Howard

    Well I created the Class using the import.flash.display.BitmapData
    then created a var: tile to hold the instance with var tile:BitmapData = BitmapData.loadBitmap("holidaytile");
    Then this.beginBitmapFill(tile);  I believe loads the Bitmap with the instance
    And the following code writes it all to stage
    this.lineTo(Stage.width,0);
    this.lineTo(Stage.width, Stage.height);
    this.lineTo(0, Stage.height);
    this.lineTo(0, 0);
    this.endFill();
    But where would I put the alpha control?? I've tried in a few places e.g
    BitmapFill.alpah = 0.5; But there is no change.
    Howard

  • Proportional Scaling external Image to stage

    Sounds confusing I know but basically I want to place some images on the stage and I want every image, whether big or small, portrait or landscape, to be scaled to about a quarter of the stage size.
    I have tried coding this myself and even tried many suggestions found on the web, but they all seem to do the same thing. The code either sizes every image to be equal in width and varying height, or scale every image to be equal in height with varying width.
    Say you have some images all the same size, but some in landscape orientation and some in portrait orientation. Most of the code I found for "proportional scaling" would scale the landscape images okay, but make the portrait images the same height as the others, so they looked alot smaller. Or the reverse was true.
    example:
    image.width = stage.stageWidth;
    image.height = stage.stageHeight;
    ( image.scaleX < image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
    This makes all the images fit on the stage all right, but they all have the same width. reversing the equality amkes all teh heights the same.
    If two images did not have the same width before they are scaled down, they should not have the smae width afterwards in my opinion.
    Sometimes I get some code that seems to work, then I change the stage size to check it and all the images did not scale to 1/4 of the stage new size when the FLA was run.
    I bet this is simple, but I have been working on it too long, y mind is in a knot!

    I loaded an array with a Loader and then used a random a variable to pick from the array using a variable that has the length of the array in it: here is the code, but the cut and paste does not wok that well.
    import com.greensock.TweenLite;
    var XMLURLLoader:URLLoader = new URLLoader();
    XMLURLLoader.load(new URLRequest("link to picasa photo rss feed"));
    XMLURLLoader.addEventListener(Event.COMPLETE, processXML);
    var media:Namespace=new Namespace("http://search.yahoo.com/mrss/"); imagesArray:Array = new Array();
    var imagesDateUploaded:Array = new Array();//The title properties of the XML File
    //var imagesWidth:Array = new Array();
    //var imagesHeight:Array = new Array();
    var imagesLength:uint;
    var imagesLoadedCount:int=0;//A counter, counts the images loaded
    var formatFont:Myriad = new Myriad();//This is the embedded font 
    var textformat:TextFormat = new TextFormat();//A TextFormat Object
    textformat.color=0xFFFFFF;
    textformat.font=formatFont.fontName;
    textformat.size=80;//Use the same size you used when embedding the font from the Library 
    var
    function processXML(event:Event):void {
    var XMLdata:XML=new XML(XMLURLLoader.data);
    imagesLength=XMLdata.channel.item.length();
    for (var i:uint=0; i < imagesLength; i++) {
      var loader:Loader = new Loader();
      loader.load(new URLRequest(String(XMLdata.channel.item[i].enclosure.@url)));
      imagesArray.push(loader);
      var imageDate:String=XMLdata.channel.item[i].pubDate.substr(6,10);
      imagesDateUploaded.push(imageDate);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imagesLoaded);//A listener to the function that will be executed when an image is loaded
    function imagesLoaded(event:Event):void {
    imagesLoadedCount++;//Adds one to the imagesLoaded variable
    if (imagesLength==imagesLoadedCount) {//When all images are loaded
      prepareImages();//This function is explained in the next step  
      var maxSize:Number=stage.stageWidth/2;
    function prepareImages():void {
    //These actions will be applied to all the images loaded so we use a "for" and the "images" array to do that
    var i:uint = Math.floor(Math.random()*imagesLength);
    trace(i);
      var container:Sprite = new Sprite();//A container that will store the image, frame, TextField, TextField background and shadow
      var frame:Sprite = new Sprite();//The Frame Sprite
      var infoArea:Sprite = new Sprite();//The TextField background
      var infoField:TextField = new TextField();//The TextField
      //build the frames
      frame.graphics.beginFill(0xFFFFFF);
      frame.graphics.drawRect(-20, -20, imagesArray[i].width + 40, imagesArray[i].height + 40);
      frame.graphics.endFill();
      //creates a black rectangle in the bottom part of the image, where the TextField will be.
      infoArea.graphics.beginFill(0x111111, 0.5);//.5 is alpha
      infoArea.graphics.drawRect(0, 0, imagesArray[i].width, 100);//100 = height 
      infoArea.graphics.endFill();
      infoArea.y=imagesArray[i].height-100;
      //The following code sets the TextField properties and adds its contents
      infoField.defaultTextFormat=textformat;
      infoField.embedFonts=true;//You have to add this to use the embedded font  
      infoField.antiAliasType=AntiAliasType.ADVANCED;//This property will display the text more clearly
      infoField.width=imagesArray[i].width-5;
      infoField.height=100;
      infoField.text=imagesDateUploaded[i];//The content, obtained from the XML and stored in the Array
      //The images will have a random position based on the center of the Stage area. We use Math for that.
      //add a shadow filter
      //Distance, angle, color, alpha, blur, strength, quality
      var shadowFilter:BitmapFilter=new DropShadowFilter(3,90,0x252525,1,2,2,1,15);
      var filterArray:Array=[shadowFilter];
      container.filters=filterArray;//Apply the filter
      //adding children to container
      infoArea.addChild(infoField);//Adds the TextField to the TextField Background  
      container.addChild(frame);//Adds the Frame to the Container
    var bd:BitmapData= new BitmapData(imagesArray[i].width, imagesArray[i].height);
    var bmp:Bitmap = new Bitmap(bd);
    bd.draw(imagesArray[i]);
    container.addChild(bmp);
    // using the loader from the array directly was causing problems like only showing once.
    //  container.addChild(imagesArray[i]);//Adds the Image on top of the Frame in the Container  
      infoArea.visible=true;//We set the image information to invisible by default  
      container.addChild(infoArea);//Adds the information area in top of everything
      //resize the images to no more than 1/2 the image width or height compared to stage
      if (container.width>container.height) {// horizontal asset
       container.width=maxSize;
       container.scaleY=container.scaleX;
      } else {// vertical asset
       container.height=maxSize;
       container.scaleX=container.scaleY;
      container.x = Math.floor(Math.random()*(1+stage.stageWidth - container.width-20))+20;
      container.y = Math.floor(Math.random()*(1+stage.stageHeight - container.height-20))+20;
      //the  plus and minus 20 keeps the image in the stage boundary. something wrong with the container width calculations
      this.addChild(container);//Lastly, we add the Container to the Stage
      container.alpha = 0;
    TweenLite.to(container,1,{alpha:1});
      trace("Just added child");
    var timer:Timer = new Timer(5000,1);
    timer.addEventListener (TimerEvent.TIMER, initTimer);
    timer.start();
    function initTimer(event:TimerEvent):void{
    trace("Timer started");
    prepareImages();
    timer.reset()

  • Loading up an image into a Jpanel!! HELP!!

    Hi,
    With regards to the following code, I was wondering if anyone could help me. I am in the early stages of making a basic Image Editing program, and have managed to implement the following code. The thing is, when you load up an image, it seems to always position it in the top left corner of the container - overwiting all menus, buttons placed underneath. Why is this??
    I need the image to appear in the JPanel/canvas below the toolbar and not on top of it!!
    I hope someone out there can help me!
    Thanks,
    a very confused girl :(
    SAMPLE CODE:-
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.ImageIO;
    import java.net.*;
    import javax.swing.filechooser.*;
    public class ImageMaker extends JFrame implements ActionListener
         String kBanner = "ImageMaker v1.0";
         JPanel contentPane;
         JButton loadButton;
         JToolBar toolBar;
         JMenuBar menuBar;
         JMenu fileMenu;
         JMenuItem fileOpenMenuItem;
         public BufferedImage mBufferedImage;
         public ImageMaker(String fileName)
              Container appWindow = getContentPane();
              setTitle(kBanner);
              appWindow.setLayout(new BorderLayout(5,5));
              menuBar = new JMenuBar();
              setJMenuBar(menuBar);
              fileMenu = new JMenu("File");
              menuBar.add(fileMenu);
              fileOpenMenuItem = new JMenuItem("Open");
              fileMenu.add(fileOpenMenuItem);
              fileOpenMenuItem.addActionListener(this);
              toolBar = new JToolBar();
              loadButton = new JButton("Open");
              loadButton.addActionListener(this);
              toolBar.add(loadButton);
              contentPane = new JPanel();
              appWindow.add( BorderLayout.NORTH, toolBar);
              appWindow.add( BorderLayout.SOUTH, contentPane);
         public void loadImage(String fileName)
              Image image = Toolkit.getDefaultToolkit().getImage(fileName);
              MediaTracker mt = new MediaTracker(this);
              mt.addImage(image, 0);
              try { mt.waitForID(0); }
              catch (InterruptedException ie) { return; }
              if (mt.isErrorID(0)) return;
              mBufferedImage = new BufferedImage(image.getWidth(null),
                                                         image.getHeight(null),
                                               BufferedImage.TYPE_INT_RGB);
              Graphics2D g2 = mBufferedImage.createGraphics();
              g2.drawImage(image, null, null);
              validate();
              repaint();
              setTitle(kBanner + ": " + fileName);
         public void paint(Graphics g)
              super.paint(g);
              if (mBufferedImage == null) return;
              Insets insets = getInsets();
              g.drawImage(mBufferedImage, insets.left, insets.top, null);
         public void actionPerformed(ActionEvent ae)
              JFileChooser fd = new JFileChooser();
              int returnVal=fd.showOpenDialog(ImageMaker.this);
              if(returnVal==JFileChooser.APPROVE_OPTION)
                        if (fd.getSelectedFile() == null)
                           { return; }
                        File file=fd.getSelectedFile();
                        String path=(String)file.getPath();
                        loadImage(path);
              JMenu men = (JMenu) ae.getSource();
              String label = (String) men.getText();
              JButton butt = (JButton) ae.getSource();
              String butt2 = (String) butt.getText();
              if (label.equals("Open"))
             else if (label.equals("Save"))
         }//end ActionListener
         public static void main(String[] args)
              String fileName = "default";
              if (args.length > 0) fileName = args[0];
              ImageMaker img=new ImageMaker(fileName);
              img.setSize(800,600);
              img.show();
    }

    Hi,
    Thank you for your help.
    I have done what you suggested and created this code below using the paintComponent.
    It compiles, but when i run it i get an error ("Uncaught error fetching image: java.lang.NullPointerExecption"). I was hoping you could advise me further as i am really struggling to get this basic app running propely.
    Thanks againfor your help.
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.ImageIO;
    import java.net.*;
    import javax.swing.filechooser.*;
    import javax.swing.plaf.basic.*;
    public class TLookupOp extends JFrame
    {     DisplayPanel displayPanel;
         JButton loadButton;
         public BufferedImage mBufferedImage;
         Graphics2D g2;
         String path;
         JFileChooser fd;
              public TLookupOp()
              {super("Test");
              Container container=getContentPane();
              container.setLayout(new BorderLayout(5,5));
              displayPanel=new DisplayPanel(path);
              container.add(displayPanel);
              JPanel panel=new JPanel();
              loadButton = new JButton("Open");
              loadButton.addActionListener(new ActionListener()
              {public void actionPerformed(ActionEvent ae)
                        fd = new JFileChooser();
                        int returnVal=fd.showOpenDialog(TLookupOp.this);
                        if(returnVal==JFileChooser.APPROVE_OPTION )
                                  if (fd.getSelectedFile() == null)
                                     { return; }
                                  File file=fd.getSelectedFile();
                                  path=(String)file.getPath();
                                  //displayPanel=new DisplayPanel(path);
                                  //displayPanel.loadImage(path);
             loadButton.setToolTipText("Click to load an image.");
              panel.add(loadButton);
              container.add( BorderLayout.NORTH, panel);
              addWindowListener(new WindowEventHandler());
              setSize(displayPanel.getWidth(),displayPanel.getHeight()+25);
              show();
              class WindowEventHandler extends WindowAdapter
              {public void windowClosing(WindowEvent e)
              {System.exit(0);
              public static void main(String[] args)
              {new TLookupOp();
    class DisplayPanel extends JPanel
    {Image image;
    BufferedImage mBufferedImage;
    Graphics2D g2;
    String filepath;
    DisplayPanel(String path)
    { filepath=path;
          loadImage(filepath);
    setSize(image.getWidth(this), image.getWidth(this));
    createBufferedImage();
    public void loadImage(String fileName)
              Image image = Toolkit.getDefaultToolkit().getImage(fileName);
              MediaTracker mt = new MediaTracker(this);
              mt.addImage(image, 0);
              try { mt.waitForID(0); }
              catch (InterruptedException ie) { return; }
              if (mt.isErrorID(0)) return;
    public void createBufferedImage()
    {mBufferedImage=new BufferedImage(image.getWidth(null),
                                                         image.getHeight(null),
                                               BufferedImage.TYPE_INT_RGB);
    g2 = mBufferedImage.createGraphics();
    g2.drawImage(image,0,0,this);
    public void paintComponent(Graphics g)
              super.paintComponent(g);
              Graphics2D g2D=(Graphics2D) g;
              g2D.drawImage(mBufferedImage,0,0,this);
    }

  • Question about loading and using Images.

    I know how to load an image and to draw it onto a canvas etc etc. However my question is to do with the efficiency of loading multiple images (possibly the same image!) and using them together. I have multiple objects, all instances of the same class, which all draw themselves onto a screen in different positions. However they all use the same 3 images (depending on an internal state).
    So if I create 5 of these objects and each object calls to load the same image using something along the lines of:
    url = this.getClass().getResource("MyImage.png");
    normalImage = Toolkit.getDefaultToolkit().getImage(url);Does this mean that in the memory there are 5 exactly the same copies of this image? Or does java do something clever and use one image that they would all reference? I suspect I will have 5 in memory but I wanted to ask about this before going and making an imageManager class where I load all the images and just use getMethods in that when drawing. I will not be preforming any transforms or anything on any of the images so they can all literally be the same image but simply drawn in multiple positions on the one canvas.
    (note: I am using active rendering to draw these images myself and then blit it to the screen ...).

    Use ImageIO rather than Toolkit--with Toolkit you need to use a MediaTracker to ensure you have your image loaded before you try to use it.
    If you load an image and then do this:
    MyImage1 = MyImage;
    MyImage2 = MyImage;
    MyImage3 = MyImage;
    There are 4 references to the Image in MyImage. If you don't specifically use a method that gives you a new Image, usually, you are getting a refrence to an image already loaded in memory.

Maybe you are looking for

  • Data is not updated in the database

    hi.. to all.. i'm using the following code ...... but the data is not updated in the database.. the output window get closed as soon as i clicked save button... i don't know wat's problem with the program... Plz help me.. to get resolve this problem.

  • Runtime Error in Hangman App

    Good evening all, I have written the following code for a CS assignment. All seems well except for a few issues with the alignment of the ASCII art but I am still tweaking it a bit. The major problem is if the user presses the enter button instead of

  • Help with zoom in on items in a List with a TileLayout + repositioning

    Hi, I'm new to flex and I'm implementing  a menu that zoom in on the hovered state. The zoom in works fine, but I've been  trying usuccesfully to reposioning the tiles on the borders, so the zoomed version of the tiles can be displayed inside of the

  • Help Ipod Menu is empty of song names but files acessible thru iPod Control

    Hi when I scroll to Ipod / Music / Artists etc. Nothing shows up. However when I view hidden folders and look in the Ipod_control/Music folder all the songs are still there listed in folders such as FE1 etc. I've checked for the Itunes DB file in the

  • Persistent bug in Photoshop CS5

    Is anyone having problems with loading a large number of files into  Photoshop cs5? I have a Mac Pro 2.8 8-core 2008 model, osx 10.6.4, and a gtx 285  graphics card and 16gb ram. Every time I try to open a large series of photos (not huge files but,