Dynamically Load Thumbnails To Horizontal Movieclip?

I'd like to dynamically load thumbnails into a horizontal movieclip at the bottom of an image gallery to then allow me to load an image by clicking the thumbnails. I found a tutorial to help me load the thumbnails to the stage but I am not sure how to load them into the thumbs movieclip. Here is the code I am using:
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("xml/murals.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void
    xml = XML(event.target.data);
    xmlList = xml.children();
    for(var i:int = 0; i < xmlList.length(); i++)
        imageLoader = new Loader();
        imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
        imageLoader.x = i * 175 + 25;     // <----- Also, I don't seem to understand how to space the thumbnails using this code.
        imageLoader.y = 5;
        addChild(imageLoader);
Thanks in advance!
-Dan

I wasn't sure if I should make a new discussion for this or not so I'm just going to post it here.
Alright. I finally found a tutorial that works for what I am trying to do. The thumbs load on a grid and when I click on the thumb they load in the loader. Now I am having trouble removing them. The tutorial has the remove function on the loaded large image so when you click that it removes itself. I would like so that when you click on the a thumb the current image will unload and the thumb that is clicked on will load but can't figure out how to get it to do that. I figured I'd just add a CLICK listener for the "removeFull" function to the "callFull" function but I think it cancels itself out.
Here is the code I am using: (the code to load and unload is toward the bottom)
stop();
var columns:Number = 2;
var my_x:Number = 25;
var my_y:Number = 75;
var my_thumb_width:Number = 65;
var my_thumb_height:Number = 65;
var my_images:XMLList;
var my_total:Number;
var container_mc:MovieClip;
var x_counter:Number = 0;
var y_counter:Number = 0;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("xml/gallery.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML (e:Event):void{
    var myXML:XML = new XML(e.target.data);
    my_images = myXML.IMAGE;
    my_total = my_images.length();
    createContainer();
    callThumbs();
function createContainer():void{
    container_mc = new MovieClip();
    container_mc.x = my_x;
    container_mc.y = my_y;
    addChild(container_mc);
//The large image loads when the thumb is clicked on.
    container_mc.addEventListener(MouseEvent.CLICK, callFull);
    container_mc.buttonMode = true;
function callThumbs():void{
    for (var i:Number = 0; i < my_total; i++){
        var thumb_url = my_images[i].@THUMB;;
        var thumb_loader = new Loader();
        thumb_loader.load(new URLRequest(thumb_url));
        thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
        thumb_loader.name = i;
        thumb_loader.x = (my_thumb_width+25)*x_counter;
        thumb_loader.y = (my_thumb_height+25)*y_counter;
        if (x_counter+1 < columns){
            x_counter++;
        } else {
            x_counter = 0;
            y_counter++;
function thumbLoaded(e:Event):void{
    var my_thumb:Loader = Loader(e.target.loader);
    container_mc.addChild(my_thumb);
//This function loads the large image.
function callFull(e:MouseEvent):void{
    var full_loader:Loader = new Loader();
    var full_url = my_images[e.target.name].@FULL;
    full_loader.load(new URLRequest(full_url));
    full_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);
//This function centers the large image in the gallery loader.
function fullLoaded(e:Event):void{
    var my_loader:Loader = Loader(e.target.loader);
    MovieClip(parent.parent).gallery.addChild(my_loader);
    my_loader.x = (MovieClip(parent.parent).gallery.width - my_loader.width)/2;
    my_loader.y = (MovieClip(parent.parent).gallery.height - my_loader.height)/2;
//The large image unloads when it is clicked on.
    my_loader.addEventListener(MouseEvent.CLICK,removeFull);
//This function removes the loaded image from the gallery loader.
function removeFull(e:MouseEvent):void{
    var my_loader:Loader = Loader (e.currentTarget);
    my_loader.unload();
    removeChild(my_loader);

Similar Messages

  • Load different thumbnails into different movieclips

    I'm creating a gallery and having a problem loading thumbnails into different MovieClips. I have all the MCs stored into an Array. I could load them if I wanted to type out:
    var thumbLoader1:Loader = new Loader();
    movieClipName1.addChild(thumbLoader1);
    but I would think there's a more dynamic way. Right now Im stuck at:
    var imageThumbNames:Array = new Array
    function photoLoaded(event:Event):void
        trace ("photo loaded");
        trace (xmlData.Person.length());
        imageThumbNames[photoNumberLoaded] = "image" + photoNumberLoaded;
        var image:Bitmap = event.target.content as Bitmap;
        image.smoothing = true;
        thumbHolderArray[photoNumberLoaded].addChild(image);
        if (photoNumberLoaded < xmlData.Person.length() && photoNumberLoaded < numberOfThumbs)
            photoNumberLoaded += 1;
            addThumbs();
    I tried switcing the var "image" with a name from the "imageThumbNames" array but that would've been too easy. Any help is greatly appreciated.

    var thumbLoader1:Loader = new Loader();
    movieClipName1.addChild(thumbLoader1);
    var imageThumbNames:Array = [your image files];  // populate in for-loop
    var photoNumberLoaded:uint=0;
    addThumbs();
    function photoLoaded(event:Event):void
        trace ("photo loaded");
        trace (xmlData.Person.length());
        //imageThumbNames[photoNumberLoaded] = "image" + photoNumberLoaded;
        var image:Bitmap = event.target.content as Bitmap;
        image.smoothing = true;
    //not sure if this is the right thing to add to add these loaders to
        thumbHolderArray[photoNumberLoaded].addChild(mc.getChildAt(0));
    photoNumberLoaded += 1;
        if (photoNumberLoaded < xmlData.Person.length() && photoNumberLoaded < numberOfThumbs)
            addThumbs();
    var mc:MovieClip=new MovieClip();
    function addThumbs(){
    mc["loader_"+photoNumberLoaded]=new Loader();
    var urlR:URLRequest=new URLRequest(imageThumbNames[photoNumberLoaded]);
    mc["loader_"+photoNumberLoaded].addEventListener(Event.COMPLETE,photoLoaded);
    mc["loader_"+photoNumberLoaded].load(urlR);

  • Get content of dynamically loaded movieclip

    Hey,
    After trying to no avail to get the totalframes of a dynamically loaded .swf in AS3 I've regressed to AS2.
    Now I can add the clip and get the totalframes of the content, no problem.
    THe problem is I cannot resize the content at all.
    I have no idea how to target the loaded content.
    Here's the code I'm using:
    var myXML:XML = new XML();
    var path:String;
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclm:MovieClipLoader = new MovieClipLoader();
    var mclL:Object = new Object();
    var frames:Number;
    var i:Number = 0;
    var mc:MovieClip = new MovieClip
    myXML.ignoreWhite=true;
    myXML.load("content.xml");
    holder_mc._alpha = 0;
    myXML.onLoad = function(xmlLoaded){
    menu();
    load();
    mclL.onLoadComplete = function() {
              frames = (MovieClip(holder_mc)._totalframes);
              if (frames == 1) {
                   image();
              else if (frames > 1) {
                   clip();
    load = function(){
         clearInterval(timer);
         path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
         mcl.loadClip(path, holder_mc);
         var tFiles:Number = myXML.firstChild.childNodes.length;
         if (i < tFiles){
              i++;
         else if (i == (tFiles)){
              i=0;
              load();
         mcl.addListener(mclL);     
    image = function() {     
         seconds=1000;
         holder_mc._alpha = 100;
         timer = setInterval(load, seconds);
    clip = function() {     
         holder_mc._alpha = 100;
         ftimer = setInterval(checkFrames, 100);
    checkFrames = function() {
              frame = (MovieClip(holder_mc)._currentframe);
              if (frame==(frames-1)){
                   clearInterval(ftimer);
                   load();
    menu = function(){
         var tFiles:Number = myXML.firstChild.childNodes.length;
         for (me=0; me < tFiles; me++){
         path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
         i++;
         _root.attachMovie("circle", "circle"+me, me, {_x:(me*30), _y:330});
         mclm.loadClip(path, ("circle"+me));     
    I need to resize the content both for the main holder_mc as well as for the menu elements.

    Thank you for the response.
    Unfortunately that didn't work.
    Even if I try to trace either target._width or holder_mc._width where you suggested I get 0 values.
    The only values I did manage to get was when I put the trace in the load() function but they were out of sync with the images being loaded.
    I even tried it on a simpler model:
    var myXML:XML = new XML();
    var path:String;
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclL:Object = new Object();
    var frames:Number;
    var i:Number = 0;
    var tFiles:Number;
    myXML.ignoreWhite=true;
    myXML.load("content.xml");
    myXML.onLoad = function(xmlLoaded){
    path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
    tFiles = myXML.firstChild.childNodes.length;
    loader();
    loader = function() {
         mcl.loadClip(path, holder_mc);
         mcl.addListener(mclL);
    mclL.onLoadComplete = function(target:MovieClip) {
         trace(target._width);
         trace(holder_mc._height);
    ..and I still get 0 values.

  • Dynamic Text w/in a movieClip

    OK, so simple test I loaded a text file on the first frame of
    my movie:
    LoadVariableNum("Houston.txt", 0);
    This text file begins with Houston_txt="yadda, yadda..."
    Then I created a text field: rep_txt
    this text field is dynamic, variable is vRep_txt.
    First tests with button actions work:
    on (release) {
    vRep_txt = Houston_txt;
    Now, I want to publish this movie and load it into another
    movieClip.
    How would I properly target the text field variable to load
    my text?
    I have not gotten this to work once loaded into the
    movieClip, and I don't feel like targeting a textField variable
    works:
    _root.viewer_mc.vRep_txt = Houston_txt
    Should I load my text file on the main timeline & assign
    _global.variables for which my buttons can assign to the textField
    as such:
    _root.viewer_mc.rep_txt = _global.vHoustonVariable_txt
    I'm testing like a fiend, and struggling.

    I'm attempting the same thing. I can load variables and call
    text easily within one movie, but when I publish the movie and call
    it into another... No luck.
    //on the main timeline
    loadVariablesNum("textfile.txt", 0);
    //on button
    on (release) {
    variable_txt = StartText;
    with StartText=[at the beginning of my text file]
    I don't know how to make this work from the main timeline, if
    the textField and buttons are within a movie clip called:
    frame_mc
    help.

  • Add event listeners to dynamically loaded symbols?

    Hi,
    I'm trying to dynamically load different MovieClips based on user input. Several of those clips have embedded url link symbols. How can I add event listeners to the url links if the dynamically loaded MovieClip does not have an instance name? Seems like I can (right?) apply an instance name when the clip is loading, but the event listener doesn't compile because the name is not there yet, so that seems out.
    Am I on right track?

    Are you saying that you will instnatiate this symbol several times and each time url for this link is going to be different?
    There are at list two ways to deal with it.
    1. Inside symbol you can dispatch a custom event once it is clicked:
    myLink.addeventListener(MouseEvent.CLICK, onClick);
    function onClick(e:MouseEvent):void {
         dispatchEvent(new Event("linkClick"));
    Wherever you instantiate the symbol (perhaps on timeline):
    var symbolInstance:MySymbol = new MySymbol();
    symbolInstance.addEventListener("linkClick", onLinkClick);
    function onLinkClick(e:Event):void {
         // do whatever
    Second way would be to pass url value into symbol instance itself and deal with with it on a symbol level. I personally prefere way 1.

  • How to dynamically load images into Flash

    I have a movie clip on the stage that I want to dynamically
    load images into (that constantly change), how would I go about
    doing this? Thanks.

    Use the Loader class to load in images.
    Then use addChild to add the Loader class into your MovieClip
    on the stage.
    As far as &amp;quot;constantly change&amp;quot; what
    do you mean by that? You could use setInterval, ther enterFrame
    event, or any other means to trigger a new image to be loaded into
    the Loader instance.
    Finally, you can use the Tween class to create some nice
    effects for the images (fade it, blur in, photo blend, masks,
    etc)

  • Get width and height of a dynamically loaded image once it's done loading?!

    hello : :
    well... i'm taking my first shots at flex after programming
    in flash for a year now. it's been fun and i've been picking up on
    things pretty well (or so i think), but i come across something
    today that i used to be able to do in my as2 programming and don't
    know how to do in as3...
    in flex, i'm loading an image into an image control (by using
    "myImgControl.load(urlString)"). i have a "complete" parameter on
    the image control that calls a function just fine after the image
    is loaded, but if i try and check the hight and width of the loaded
    image once it loads, it comes back as zero. how can i get the
    height and width of the image after it's loaded?!
    in flash/as2 i used to do this little trick/work-around i
    found in a forum (kirupa.com, i think) to find out the width and
    height once the loaded image listener checked the loading process
    and came back "complete"... in the code below, "imgLoader" is the
    movieClip the image was loaded using
    imgLoaderListener.loadClip(urlString, imgLoader).
    quote:
    iTot = imgLoader.getBytesTotal();
    iLoad = imgLoader.getBytesLoaded();
    if (iLoad == iTot && iTot > 4) {
    imgH = imgLoader._height;
    imgW = imgLoader._width;
    that all make sense?!
    basically, it's as simple as this: i need to find something
    similar to the above for as3 that will tell me the width and height
    of a dynamically loaded image after it's done loading...
    so there ya have it. i appreciate any help any of you can
    throw my way! thank you so much for even reading this!
    : : michael

    I assume you have probably already figured this out, but just
    in case, there should be an event to listen for after which you can
    get the height and width information successfully. I can't remember
    the exact name, however. Experiment and see which one works
    time-wise.

  • TotalFrames of dynamically loaded swf

    I've been trying for 2 days now to find the total number of frames of a dynamically loaded .swf.
    Here's an example code:
    var loader:Loader = new Loader;
    loader.load(new URLRequest("mop.swf"))
    master_mc.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, xmlLoadedF);
    function xmlLoadedF(event:Event):void
        trace(loader.content.totalFrames);
    I am truly puzzled.
    Any help would be greatly appreciated.

    I think this might be complicated by loading an AS2 movie into an AS3 document.
    The error message is telling you that there is no totalFrames property and in fact AS2 movies would have a _totalframes property.
    So you could try that.
    Also I'm not sure if event.currentTarget.content returns a MovieClip or a DisplayObject. If it is a DisplayObject (which is most likely) then it too wouldn't have  totalFrames property. So you might need to cast it as a MovieClip. Something like this:
    MovieClip(event.currentTarget.content).totalFrames
    And or it could be some combination of these two above issues? I don't know really, I'm just grasping at straws. But I don't see any way to know when a clip is done playing other than to compare its currentFrame to totalFrames.

  • How? load imgaes into a movieclip

    Hi,
    I like to load some images into movieclip using actionscript. I am doing this because I use flex not flash. Does anybody know how it can be done?

    No, that would end up loading over what you already load since you have only the one Loader.  A single Loader can only hold a single loaded file.  So in your loop you need to create new loaders for each image.  You would need to use something more like...
    var myArray:Array = ["img1.jpgh","img2.jpg","img3.jpg","img4.jpgh","img5.jpg"];
    var mc:MovieClip = new MovieClip();
    for(var i=0; i<myArray.length; i++){
         var loadit:Loader = new Loader();
         loadit.load(new URLRequest(myArray[i]));
         mc.addChild(loadit);
    addChild(mc);
    The setInterval code you showed at the end will not work, mainly because the MovieClip you created dynamically does not have anything in frames that you could gotoAndPlay.

  • Anyway to have JDeveloper dynamically load BC4J components in memory?

    We are dealing with a large BC4J based application that contains large amount of application modules. So far, 300 application modules and total 4000 BC4J objects have been created. The size of the application still keeps growing daily... may up to twenty times than what we are having right now.
    While the application size growing, some unusual problem comes out. The biggest problem is that it makes JDeveloper very sluggish. It takes 15 minutes to just open JDeveloper and may need a few minutes to open the application module editor. (FYI: in our team, most developers have 1G memory and 1.8G CPU or up.) This is probably still OK for right now, but it will become a big problem later when the project size grows.
    When we analysis the project structure, we know that most of time, developer does not need to load all the application modules. For example, we have a core package that contains about 30 application modules. This core package needs to be shared and should be loaded. But, the other nine packages contain about 30 application modules each do not need to be loaded into memory at the same time in most cases. Since BC4J is XML based, we could not find a way to just partially load those application modules, especially when there’s cross references between them.
    When we check the project.jpr file, looks like all BC4J objects are referenced there. We have 40K lines in our project.jpr file now. When open JDeveloper, we believe JDeveloper will try to load all referenced BC4J XML content into memory. This consumes 500M memory and makes the overall performance very sluggish. The situation may become even worse when the project size keeps growing. For example, we cannot have 5000M (5G) memory in a development machine for 3000 application modules.
    We do know that by checking out the "ScanSource Paths to Determins Project Contents" in the Input Paths of Project Settings, we can short the JDeveloper’s open time, but this will not give BC4J relationship information and some other useful information… Not a practical solution.
    So, any idea to make JDeveloper dynamically loaded BC4J based on need?
    We’ve tried a few ways. One is to partition the application into different project and import the core one into the other projects. Only open the project in workspace when need. But this is not officially documented by Oracle and we are not sure whether it is possible/correct or not. Another thought is to remove the NOT-CURRENTLY-USED package from the project. But JDeveloper only support file level remove.
    Any help on this dilemma will be highly appreciated.
    Thanks,
    Charles

    The package is the unit of loading in the IDE for ADF business components.
    To edit components, they must belong to the project.
    To refer to components in a read-only way, they can be imported. This allows other editable or read-only components to refer to them without allowing the imported components to be edited.
    Both editable and imported components need to be loaded in memory to use them, so you can save memory at design time by creating projects that leave out as many packages as possible.
    Is there a way we can get your existing project in house to study its design time performance?

  • Dynamic load of images in to established Timeline effect

    Is it possible to dynamicly load images in to an already
    established timeline effect?
    Steps I've done.
    Stuffed a JPG in to the library by draging and dropping it in
    to the SWFs library.
    Dropped the JPG on to the main stage
    Right clicked the image then going down to Timeline effects
    and choosing an effect.
    Completing any changes in effects dialogue box and then
    clicking OK.
    Play the movie, and pat myself on the back that it worked.
    So then, how can I get Actionscript to load an image
    dynamically in to that same Timeline effect and have it do the
    effect to that instead of the one found in the library?
    I'm using Flash MX Professional 2004.

    hii
    Can u mention the error message getting while the status become RED??
    As what I understand, this may be the issue of invalid characteristics inPSA Data Records or also there may be records that does not support the lower case or upper case data.
    So just check the data in PSA Level
    Thanks
    Neha

  • Spry Tabbed panels + Progressive Enhancement and Dynamic Loading of Content With Spry

    Is there any way to combine tabbed panels together with "Progressive Enhancement and Dynamic Loading of Content With Spry"?
    Visit: http://labs.adobe.com/technologies/spry/articles/best_practices/progressive_enhancement.ht ml#updatecontent
    And click on the "Using Spry.Utils.updateContent()"
    The 3rd example shows how to use a fade transition whenever the content changes.
    I already have tabbed panels. My menu contains buttons (on tabs) and my Content div contains the panels.
    Tabs code;
    <ul class="TabbedPanelsTabGroup">
              <li class="TabbedPanelsTab">
                   <table class="Button"  >
                        <tr>
                        <td style="padding-right:0px" title ="Home">
                        <a href="javascript:TabbedPanels1.showPanel(1);" title="Home" style="background-image:url(/Buttons/Home.png);width:172px;height:75px;display:block;"><br/></a>
                        </td>
                        </tr>
                   </table>
              </li>
    etc
    etc
    etc
    and the panel code:
    <div class="TabbedPanelsContent" id="Home">
         CONTENT
    </div>
    I hoped i can use the example code from the link into my tabbed panels.
    I thought this code:
    onclick="FadeAndUpdateContent('event', 'data/AquoThonFrag.html'); return false;"
    could be added to the tab code like this:
    <a href="javascript:TabbedPanels1.showPanel(1);" onclick="FadeAndUpdateContent('event', 'data/AquoThonFrag.html'); return false;" title="Home" style="background-image:url(/Buttons/Home.png);width:172px;height:75px;display:block;"><br/></a>
    But the content doesnt fade...
    I know i need to change the header etc.
    The following is from the link:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Aquo Events</title>
    <script src="../../../includes/SpryEffects.js" type="text/javascript"></script>
    <script src="../../../includes/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    <!--
    function FadeAndUpdateContent(ele, url)
    try {
         Spry.Effect.DoFade(ele,{ duration: 500, from: 100, to: 0, finish: function() {
              Spry.Utils.updateContent(ele, url, function() {
                        Spry.Effect.DoFade(ele,{ duration: 500, from: 0, to: 100 });
    }catch(e){ alert(e); }
    -->
    </script>
    <style type="text/css">
    /* IE HACK to prevent bad rendering when fading. */
    #event { background-color: white; }
    </style>
    </head>
    So i changed my header etc, put the SpryEffects.js and SpryData.js into position and nothing changed...
    Is there a way to keep my tabbed panel (or change as less as possible) and let
    A. The fade work
    B. The loading work.
    The problem now is that it loads all pages instead of only the home. Therefore i wanted this Progressive Enhancement.
    And the fading part is just because its nice...

    It doesnt show in the post but off course i changed this link;
    "data/AquoThonFrag.html"
    into;
    "javascript:TabbedPanels1.showPanel(1);"
    I must say i dont know if this even works...

  • How can you display a dynamically loaded vi to the Web Server?

    I am working with LabView 6.1 and the Web Server. I can call a subvi and have it display on a remote machine using a browser with no problem. But what I would like to do is dynamically load and run a vi and have it display on the remote computer using only a browser. I have tried a small example of a front panel that invokes the run vi method (and fp.open prop) on another vi when a button is pressed, but the invoked vi is displayed only on the local computer. Is there any way of viewing dynamically loaded vi's on a remote machine without having a copy of LabView running on it?

    If i understand your question correctly, you want to monitor vi that are dynamically loaded on a remote machine without having LabVIEW installed on the machine from witch you want the monitor. I don't think it's possible how ever a good reference book would be Internet applications in LabVIEW. You can find it on BARNES&NOBLE.
    Hope i could help

  • How to dynamically load jar files - limiting scope to that thread

    Dynamically loading jar files has been discussed a lot. I have read a quite a few posts, articles, and demo code for doing just that. However, I have yet to find a solution to my problem. Most people modify their system class loader and are happy. I have done that and was happy for a time. Occasionally, you will see reference to an application server or tomcat or some other large project that have successfully been able to load and unload jar files, allow for dynamic deployment of code, etc. However, I have not been able to achieve similar success; And my problem is much less complicated.
    I have an application that executes a thread to send a given file/message to a standard JMS Server Queue. Depending on the parameters selected by the user, this thread may need to communicate with one of a number of JMS Servers, ie. JBoss, WebLogic, EAServer, Glassfish, etc. All of which can be done with the same code, but each needs to load their own flavor of JMS Client Jar files. In this instance, spawning a separate JVM for each communication would work from a classloader perspective. However, I need to keep it in the family and run under the same JVM, albeit each JMS Server Connection will be created and maintained in separate Threads.
    I am close, I am doing the following...
    1. Creating a new URLClassLoader in the run() method of each thread.
    2. Set this threads contextClassLoader to the new URLClassLoader.
    3. Load the javax.jms.JMSException class with the URLClassLoader.loadClass() method.
    4. Create an initialContext object within this thread.
    Note: I read that the initialContext and subsequent conext lookup calls would use the Thread�s
    contextClassLoader for finding/loading classes.
    5. Perform context.lookup calls for a connectionFactory and Queue name.
    6. Create JMS Connection, etc. Send Message.
    Most of this seems to work. However, I am still getting a NoClassDefFoundError exception for the javax.jms.JMSException class ( Note step #3 - tried to cure unsuccessfully).
    If I include one of the JMS Client jar files ( ie wljmsclient.jar for weblogic ) in the classpath then it works for all the different JMS Servers, but I do not have confidence that each of the providers implemented these classes that now resolve the same way. It may work for now, but, I believe I am just lucky.
    Can anyone shine some light on this for me and all the others who have wanted to dynamically load classes/jar files on a per Thread basis?

    Thanks to everyone - I got it working!
    First, BenSchulz' s dumpClassLoader() method helped me to visualize the classLoader hierarchy. I am still not completely sure I understand why my initial class was always found by the systemClassLoader, but knowning that - was the step I needed to find the solution.
    Second, kdgregory suggested that I use a "glue class". I thought that I already was using a "glue class" because I did not have any JMSClient specific classes exposed to the rest of the application. They were all handled by my QueueAdmin class. However...
    The real problem turned out to be that my two isolating classes (the parent "MessageSender", and the child "QueueAdmin") were contained within the same jar file that was included in the classpath. This meant that no matter what I did the classes were loaded by the systemClassLoader. Isolating them in classes was just the first step. I had to remove them from my jar file and create another jar file just for those JMSClient specific classes. Then this jar file was only included int custom classLoader that I created when I wanted to instantiate a JMSClient session.
    I had to create an interface in the primary jar file that could be loaded by the systemClassLoader to provide the stubs for the individual methods that I needed to call in the MessageSender/QueueAdmin Classes. These JMSClient specific classes had to implement the interface so as to provide a relationship between the systemClassLoader classes and the custom classLoader classes.
    Finally, when I loaded and instantiated the JMSClient specific classes with the custom classLoader I had to cast them to the interface class in order to make the method calls necessary to send the messages to the individual JMS Servers.
    psuedu code/concept ....
    Primary Jar File   -  Included in ClassPath                                                      
    Class<?> cls = ClassLoader.loadClass( "JMSClient.MessageSender" )
    JMSClientInterface jmsClient = (JMSClientInterface) cls.newInstance()                            
    jmsClient.sendMessage()                                                                      
    JMSClient Jar File  -  Loaded by Custom ClassLoader Only
    MessageSender impliments Primary.JMSClientInterface{
        sendMessage() {
            Class<?> cls=ClassLoader.loadClass( "JMSClient.QueueAdmin" )
            QueueAdmin queueAdmin=(QueueAdmin) cls.newInstance()
            queueAdmin.JMSClientSpecificMethod()
        }

  • URLClassLoader + dynamically loading signed jar files

    I have an applet that does not know all of the jar files it will need to load at startup.
    I would like to dynamically load these signed jar files using the URLClassLoader, however it does not recognize these jar files as being signed and I get java.security.AccessControlException: access denied errors.
    Any suggestions?
    Thanks!

    Try this classloader for loading the jars, it should to the trick:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.URLStreamHandlerFactory;
    import java.security.AllPermission;
    import java.security.CodeSource;
    import java.security.PermissionCollection;
    import java.security.Permissions;
    public class AllPermissionsClassLoader extends URLClassLoader {
        public AllPermissionsClassLoader (URL[] urls) {
            super(urls);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent) {
            super(urls, parent);
            System.out.println(parent);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
            super(urls, parent, factory);
        protected PermissionCollection getPermissions (CodeSource codesource) {
            Permissions permissions = new Permissions();
            permissions.add(new AllPermission());
            return permissions;
    }

Maybe you are looking for

  • ICal Calendar sync with iCloud Calendar

    I am moving from Google calendar to iCal and need some help. I have imported my Google calendar into iCal, but now that I created new calendars (to make different events different colors) events are disappearing. For example - my Google calendar came

  • ITunes does not recognize my Nano

    Hello, When I open iTunes, the message "The software required for communicating with the iPod is not installed correctly. Please reinstall iTunes to install the iPod's software." Okay, I've downloaded the latest version of iTunes 7.4.1.2 and have tri

  • Crystal Reports 2010 shows error on 64 bit vista/7 machines

    Hello, <br/><br/> I search the threads before posting my problem. I saw number of threads similar to this but none of them is pointing towards solutions to my problem. Thus decided to create new one. I tried various things listed in old post to solve

  • Imix rating still not working

    Win XP, itunes 7.0.1, brand new dell c521 with latest drivers, obviously clean install. Italian itunes store. Same issue as with previous pc: imix rating screwed up. If I rate an imix 5 stars, it turns out to be 1. Anything from 4 stars to 1 gives a

  • Assign Keyword to multiple images

    The book which comes with the Aperture3 software says that you can assign a keyword to multiple images without having to assign it individually to each image. Using the keyword HUD I cannot get it to assign a keyword to all images in a stack or image