Dynamic MovieClip (Loader) Names

I have an array of data that I'm using to create thumbnails and labels.  I'm using "Loader" to load the thumbnails (sample code below) but what I'm wondering is how I can make the name of the loader dynamic so that each child gets named "image1, image2, ...".  I tried adding "[i]" after the "image" for each item in the code but it complained about missing semicolon before left bracket.
var image:Loader = new Loader();
var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png");
image.name = "image_"+[i];
image.load(target_image);
image.x = 80;
image.y = 60;
addChild(image);
I saw an example for MovieClip which looks like it's exactly what I want to do but it doesn't work for Loader (and I don't know if it works at all).  In the example I saw, the last line in the above code would be:
image.addChild(this["image"+i]);
Also, if I can't make the names of the loaders dynamic, how would I add event listeners to each of the thumbnails so that when one is clicked it executes code specific to that particular image (such as open up a large version of it).  Usually you have the listeners linked to the names of the children, but if you have 10 children named "image" then that makes it a bit tough.
Any help would be greatly appreciated.  Thanks!

you can do any one of a few things.  the two most commonly used techniques:
1.
var mc:MovieClip=new MovieClip();
addChild(mc);
mc["image"+i] = new Loader();
var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png"); mc["image"+i].load(target_image);
mc["image"+i].x = 80;
mc["image"+i].y = 60;
mc["image"+i].ivar = i;  // probably needed at some point
mc["image"+i].whateverProperty = whatever;  // this is the most flexible technique
mc["image"+i].addEventListener(MouseEvent.CLICK,clickF);
function clickF(e:MouseEvent){
//do something with e.currentTarget.ivar
//do something with e.currentTarget.whateverProperty
2.
var image:Loader = new Loader();
var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png");
image.name = i;  // this is more useful than the name you were using
image.load(target_image);
image.x = 80;
image.y = 60;
addChild(image);
image.addEventListener(MouseEvent.CLICK,clickF);
function clickF(e:MouseEvent){
//do something with e.currentTarget.name
//you can do most things with the above but this can sometimes be awkward.

Similar Messages

  • Dynamic class loading from String name

    Hello all,
    I have a question for dynamic class loading:
    If I have a String variable that represents a class name, how can i use it to make dynamically an object of the class tha the string variable represents?
    For example i have a string like this
    String classname="String";
    Using this i want to make a new String object .
    Can anyone tell me how can i do this(example plz)?

    I have worked out the code and this works fine:
    import java.lang.*;
    class dynamictestname{
         public dynamictestname() {
        public static Class test(String objname){
             try{
             Class theClass = Class.forName(objname);
                 return theClass;
            } catch (ClassNotFoundException e)
                throw new NoClassDefFoundError (e.getMessage());
         public static void main (String [] args){
              String classname="java.lang.String";
              Class thisClass=dynamictestname.test(classname);
              try{
              Object instance = thisClass.newInstance();
              }catch(InstantiationException e){
              }catch(IllegalAccessException ie){
    }The new problem i 've faced is that i can't instatiate a new object by the class i have created.I saw some examples with use of the java.lang.reflect but this class i used with user created classes which have methods that the user wants to run dynamically.
    I just want to make an object from the class and give it a value.
    For example if the object i have created with the
    Object instance = thisClass.newInstance();is an object of java.lang.String class
    how can i do something like this below dynamically from instance object :
    String x="TEST ";
    Thanks for the help..

  • How to dynamically set the name of the generated PDF file sent by email

    Hello,
    I am using Reports 10g and I managed to send PDF reports by email, specifying the recipient, subject, format etc, using the reports servlet URL.
    But there is one thing that I cannot find a way to do: I want to dynamically set the name of the attached file. It defaults to the name of the RDF file (eg monthly_sales.pdf). I would like it to be something more meaningful (eg monthly_sales_072010.pdf, where 072010 is the month and year passed by parameters).
    Is it possible to do it?
    Thanks
    Luis

    Use System.load(...) instead of System.loadLibrary(...).

  • Dynamic Class Loading and Unloading

    I am trying to create a system where the class name and method name is
    picked up from a meta-data database and executed.
    This was accompanied using Dynamic Class loading. I tried to extend this to
    support versioning of meta-data. Here depending on the version of meta-data
    different libraries can be loaded and different implementations of object
    with the same name can be executed. This does not seem to work with Forte
    3.0.
    When the second Library is loaded the method execution does not work.
    (Even though the unload flag on the LoadLibrary is set)
    If the application is stopped and restarted pointing to the second library
    there is no problem. In a running application a dynamically loaded library
    does not seem to unload and reload a new library for the same class names.
    Has anyone tried sometime similar, is there a workaround for this type of
    problem.
    - Vivek

    I am trying to create a system where the class name and method name is
    picked up from a meta-data database and executed.
    This was accompanied using Dynamic Class loading. I tried to extend this to
    support versioning of meta-data. Here depending on the version of meta-data
    different libraries can be loaded and different implementations of object
    with the same name can be executed. This does not seem to work with Forte
    3.0.
    When the second Library is loaded the method execution does not work.
    (Even though the unload flag on the LoadLibrary is set)
    If the application is stopped and restarted pointing to the second library
    there is no problem. In a running application a dynamically loaded library
    does not seem to unload and reload a new library for the same class names.
    Has anyone tried sometime similar, is there a workaround for this type of
    problem.
    - Vivek

  • Dynamic Class Loading and Stubs

    How Dynamic Class Loading is used on Java RMI, since stubs are generated on clients using Reflection API?
    I was reading Dynamic code downloading using JavaTM RMI (http://java.sun.com/javase/6/docs/technotes/guides/rmi/codebase.html), it seems to be out of date.
    For example, "The client requests the class definition from the codebase. The codebase the client uses is the URL that was annotated to the stub instance when the stub class was loaded by the registry. Back in step 1, the annotated stub for the exported object was then registered with the Java RMI registry bound to a name."

    "Enhancements in J2SETM 5.0
    Dynamic Generation of Stub Classes
    This release adds support for the dynamic generation of stub classes at runtime, obviating the need to use the Java(tm) Remote Method Invocation (Java RMI) stub compiler, rmic, to pregenerate stub classes for remote objects. *Note that rmic must still be used to pregenerate stub classes for remote objects that need to support clients running on _earlier versions_.*
    When an application exports a remote object (using the constructors or static exportObject methods(1) of the classes java.rmi.server.UnicastRemoteObject or java.rmi.activation.Activatable) and a pregenerated stub class for the remote object's class cannot be loaded, the remote object's stub will be a java.lang.reflect.Proxy instance (whose class is dynamically generated) with a java.rmi.server.RemoteObjectInvocationHandler as its invocation handler.
    An existing application can be deployed to use dynamically generated stub classes unconditionally (that is, whether or not pregenerated stub classes exist) by setting the system property java.rmi.server.ignoreStubClasses to "true". If this property is set to "true", pregenerated stub classes are never used.
    Notes:
    * If a remote object has pre-5.0 clients, that remote object should use a stub class pregenerated with rmic or the client will get an ClassNotFoundException deserializing the remote object's stub. Pre-5.0 clients will not be able to load an instance of a dynamically generated stub class, because such a class contains an instance of RemoteObjectInvocationHandler, which was not available prior to this release.
    * Prior to the J2SE 5.0 release, exporting a remote object would throw a java.rmi.StubNotFoundException if the pregenerated stub class for the remote object's class could not be loaded. With the added support for dynamically generated stub classes, exporting a remote object that has no pregenerated stub class will silently succeed instead. A user deploying a server application to support pre-5.0 clients must still make sure to pregenerate stub classes for the server's remote object classes, even though missing stub classes are no longer reported at export time. Such errors will instead be reported to a pre-5.0 client when it deserializes a dynamically generated stub class.
    (1) The static method UnicastRemoteObject.exportObject(Remote) is declared to return java.rmi.server.RemoteStub and therefore cannot be used to export a remote object to use a dynamically generated stub class for its stub. An instance of a dynamically generated stub class is a java.lang.reflect.Proxy instance which is not assignable to RemoteStub."
    http://java.sun.com/j2se/1.5.0/docs/guide/rmi/relnotes.html

  • Dynamic Class Loading with interface

    Hello
    I would appreciate any help on the following problem.
    I need to load all classes in a particular directory and its subdirectories (top directory is known but not in the classpath) which implement a predefined interface. At the moment I am using a lot of reflection to accomplish this and believe it can be avoided somehow using the fact that I know these classes have to implement a predefined interface.
    At the moment, I am searching through the directory and subdirectory, loading all names of classes into a vector using a custom URLClassloader, and then load all classes in the vector into modulecontainers to populate a defaultmutabletree which is displayed on the gui.
    I'm sure that knowing the interface means there's a more straightforward way.
    Thanks in advance.

    Finally i've found out myself, i've read some postings in this forum and put them all together, so that my webstart-application finally works the way i want...
    That was the topic:
    Downloading a jar-file and starting a class from this jar-file within a webstart application (dynamic class loading).
    I'll post my final solution for this problem, may be it would be useful in future for anyone else.
    //grant all permissions on the clientside
    Policy.setPolicy( new Policy() {
    public PermissionCollection getPermissions(CodeSource codesource) {
    Permissions perms = new Permissions();
    perms.add(new AllPermission());
    return(perms);
    public void refresh(){
    //get the current classloader
    ClassLoader cl = MyLoadedClass.class.getClassLoader();
    //create a new url-classloader while using the current classloader
    URL[] urls = new URL[1];
    File f = new File(new String(jarName));
    urls[0] = f.toURL();
    URLClassLoader ul = new URLClassLoader(urls, cl);
    //load a class from jarfile
    Class c = ul.loadClass(new String(className));
    //get an object from loaded class
    Object o = c.newInstance();
    /* Are we using a class we specifically know about? */
    if (o instanceof KnownInterface){
    // Yep, lets call a method we know about. */
    KnownInterface client = (KnownInterface) o;
    client.doAnything();

  • Why do we use only dynamic class loading for JDBC drivers

    Hi,
    My JDBC experience is that we always use dynamic class loader for drivers.
    If we have a well defined package from a vendor, why do we use this dynamic class loading feature for drivers??

    chandunitw wrote:
    Hi,
    My JDBC experience is that we always use dynamic class loader for drivers.
    If we have a well defined package from a vendor, why do we use this dynamic class loading feature for drivers??Oftentimes, the driver class name is set in a configuration file, not in code. So the thing which processes the configuration file has no idea ahead of time which driver or drivers it will support, so it is not coded specifically for any. So it loads the driver by reflection, since it is given the class name as a string it can use with the reflection API.

  • The sound  with movieclip loaded from outside

    Hi.everybody...I have a probelm with sound working with
    movieclip loaded from outside. this movieclip is just working fine
    alone..but after being loaded to the other movie..the sound doesnt
    play any more.
    by the way,I loaded this movieclip with loadclip and also add
    listener on it.
    any suggestion,,please..thank u .

    try adding
    yourHolder._lockroot = true; //yourHolder would be the
    instance name of the holder MovieClip

  • Accessing Dynamic Movieclip Children

    There is a lot of code that I have but here is snippet to get to the point.  I have created a Movicelip called via actionscript called "McButton".  Then I created 10 MovieClips within that MovieClip ("McDot0", "mcDot1", etc).  I need to know how to access mcButton.mcDot3 to change its color when button3 (mc already on stage) is clicked but can not figure it out.
    I have tried both of these below but it does not work:
    mcButton.mcDot3.transform.colorTransform = cityColor;
    getChildByName("mcButton").getChildByName("mcDot3").transform.colorTransform = cityColor;
    This is the code below that I have used to create the Dynamic Movieclips:
    var button:Container = new Container();
    button.name = "mcButton";
    this.addChild(button);
    for (var a:int = 0; a < 10; a++) {
         var dot:Dot = new Dot();
          dot.name = "mcDot" + a;
        MovieClip(getChildByName("mcButton")).addChild(dot);
    Can someone please help me see the light.
    Thanks

    In order to change a color using color transform, first you must create a new ColorTransform object and than assign it to transform.colorTransform property.
    i,e,
    var cityColor: ColorTransform = new ColorTransform();
    getChildByName("mcButton").getChildByName("mcDot3").transform.colorTransform = cityColor

  • Function short dump - A dynamically specified column name is unknown.

    Hello,
    I've created BRF fuction according to the  Note 1466868 - Dunning by collection strategy with BRFplus. I get short dump during simulation of function with following exception:
    "A dynamically specified column name is unknown. "
    Runtime Errors         SAPSQL_INVALID_FIELDNAME
    Exception              CX_SY_DYNAMIC_OSQL_SEMANTICS
    No.   Ty.          Program                             Include                             Line
          Name
       19 METHOD       CL_FDT_ELEMENT================CP    CL_FDT_ELEMENT================CM012   129
          CL_FDT_ELEMENT=>GET_VALUES_DDIC
       18 METHOD       CL_FDT_ELEMENT================CP    CL_FDT_ELEMENT================CM011   124
          CL_FDT_ELEMENT=>GET_VALUES
       17 METHOD       CL_FDT_WD_RENDER_VALUE_INPUT==CP    CL_FDT_WD_RENDER_VALUE_INPUT==CM00G   139
          CL_FDT_WD_RENDER_VALUE_INPUT=>VALIDATE_VALUES
    In my opinion there is uncorrect query.
    Current version:
    .  SELECT FIKRS AS VALUE NAME AS TEXT FROM FMBS_BS_T
        INTO CORRESPONDING FIELDS OF TABLE lt_value
        WHERE LANGU EQ 'E'.
    instead of:
    .  SELECT FM_AREA AS VALUE NAME AS TEXT FROM FMBS_BS_T
        INTO CORRESPONDING FIELDS OF TABLE lt_value
        WHERE LANGU EQ 'E'.
    My sap version:
    EHP4 FOR SAP ERP 6.0 / NW7.01
      SAP_BASIS     701     0003     SAPKB70103
    Do you know any note or solution  to resolve this problem.
    Best regards,
    Jacek Witczak

    Hi, I came back to working on "Dunning by collection strategy with BRFplus". According to your sugestions, I raised the level of components:
    SAP_BASIS Level 09
    SAP_ABA level 09
    PI_BASIS level 09
    SAP_BW level 09
    But still I have the same short dump.
    Shoudl we raise any other components? Maybe you know note, which resolve this problem?

  • Dynamic Receiver file name in AS2 adapter

    Hi Experts,
    How to get dynamic receiver file name in AS2 adapter. We need receiver file name same as of sender file name.
    We tried selecting dynamic attributes file name but we are getting followin error in CC.
    Message processing failed. Cause: javax.resource.ResourceException: Fatal exception: com.seeburger.xi.connector.queue.TaskBuildException: Mandatory attribute dtAS2FileName is not present in XI message., Mandatory attribute dtAS2FileName is not present in XI message.
    Thanks,
    Hari

    hi hari,
    You can't do it manually. As both adapter are in different context.
    You can go with UDF to slove ur problem.
    Just extract the input file name using Dynamic configuration
    Store that in some variable.
    Use same name in the dynamic file name in AS2 receiver. Below code might be useful.
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://seeburger.com/xi/common/dtAS2FileName", "DYNFILENAME");
    conf.put(key,strfilename);
    Thanks
    Jai
    Edited by: Jaideep Baid on Apr 9, 2010 9:16 AM

  • Dynamic Logo file names in PO XSL-FO stylesheet

    We have different company logo files for different operating units. Hence , we require to use a dynamic logo file name in XSL-FO template.
    When I use the below for a single file it works.
         <fo:inline>
    <fo:external-graphic content-width="50pt" content-height="50pt" src="url({'${OA_MEDIA}/Logo_medium_COMCEL.jpg'})" />
    </fo:inline>
    However, I would need to make the filename dynamic.
    When a tried usng an xsl variable tos tore fielname, it didnt work.
    Any pointers as to how we can achieve that would be helpful

    Thanks for your quick reply Dave, I appreciate your time.
    But I couldn't test the new template as I was neither able to create a new PO nor was able to run the PO Output for communication Report. When I tried to create a PO the Purchase Order form did not open saying I am not setup as an employee, even the PO Output for communication did not give any LOV for the PO's.
    I tried to define employee name in the employee's login
    information (System administrator/Security/User/Define) for my user, but some how my name doesn't appear in LOV. Any help is appreciated.
    Thanks,
    Sharmila

  • Include the file dynamicly by file name

    in my jsp,I want include another jsp dynamicly
    <%@ include file="thefile.jsp" %>
    thefile.jsp should be dynamic like:
    <%=String filename=="thefile.jsp" %>
    <%@ include file=filename%>
    I know above is not working since file only take static name.
    is there any way to include the file dynamicly by file name?

    String path = "..."; // to the ressource to include
    javax.servlet.RequestDispatcher dispatcher
              = getServletContext().getRequestDispatcher(path);
    dispatcher.include(request,response);

  • Dynamic Global Host Name!!!

    Hello Everybody!
    I have Time Capsule 2TB, and i have an issue about it, which its how to connect to it via internet?
    i know that i must have mobileme account and to be added to advanced in the airport utility.
    then i have to setup the Dynamic Global Host Name, this is my problem?
    how can i get the Dynamic Global host Name?
    Is it from ISP?
    is it supported by some regions? or all over the countries?
    if so, is it supported in Egypt?
    i gave a try and i contact my ISP (Vodafone) but they didnt hear anything or even know anything about the Dynamic Global Host Name. If from ISP, what could i tell them to understand me?
    because when i asked about DGHN, no one understand me.
    Thank you for your help,
    Sincerely,,,

    Abdelaal wrote:
    now the ip address for the Time Capsule is 196.168.0.4
    and the WAN IP address is 10.0.1.1 .
    That sounds backwards. The public IP address 196.168.0.4 is administered out of Mauritius, which should make what you see a WAN address. An IP address 10.0.1.1 is a "private" IP address, which you'd expect to see in a LAN behind a NATting router.
    (Back to My Mac isn't working properly because you may have more than one device on your network providing Network Address Translation (NAT). Try disabling NAT on one of the devices )
    As it says, that means that you are behind multiple layers of routers providing translation of network addresses. Can you tell what WAN address is being assigned to your ADSL modem/router? I'd still try to put that device into "bridge" mode.

  • Movieclips loader loads png but does not display image in ie

    hello, i have created a static class to deal with the loading
    of images, it works great. yesterday, i found an issue: i try to
    load png files (those pngs are generated with quasimondo's bitmap
    exporter), they do load, but they are not displayed in ie.
    it worked until recently. is there some specification about
    the png that i have to make sure that the png has? or is there an
    issue using the movieclip loader with ie?
    i included the actionscript class (save the code in an .as
    file), so if you want to test, write only this in the first frame
    of your code:
    import com.iCongo.utils.MovieClips;
    this.createEmptyMovieClip ("placeholder",
    this.getNextHighestDepth ());
    MovieClips.loadIMG (this.placeholder, "
    http://somedomain.com/somepng.png");
    that image will load, but in the context of my flash file
    where many many files are loaded at the same time, only the block
    generated by the bitmap exporter will not show.

    OOPS
    cancel that question. i ftp'd the file to the server again, this time setting the transfer type to binary and the png image comes up
    just like it should.
    john

Maybe you are looking for

  • CS6 Design Standard , clone, migration tool, trial mode (urgence)

    Hi all and sorry for this question. I clone on a external disk my MacBook Pro (OSX 10.7) with Super Dumper . Then i have istalled OSX 10.8.2 and imported all data and applications with the migration tool during the installation. My problem is that no

  • Need help understanding PC vid card options in MP

    Hi all, I have a 2008 MP with the 2600 XT video card, but I just installed Windows 7 via Boot Camp and decided I'd like to get a second video card just to play games in Windows. I do know that a PC video card won't work in OSX unless flashed, but I'm

  • SLD error with ABAP Trial Version 7.0

    Hi,   I have installed JAVA trail version and ABAP trial version 7.0 on a single system.I am able to connect to my ABAP (NSP) version with system alias. But when I am configuring SLD ,I am getting RFC_EROR_COMMUNICATION  error. I access my local java

  • Line on Monitor Screen

    I have a TouchSmart 520.  Recently I have noticed a slanted line in the upper right corner of the screen...it slants just across the upper edge of the "X".  Is this a sign that my monitor is failing?  Thanks for any input.

  • Did the 7.0.4 update now can't access FB or other websites

    Help, I did the iOS 7.0.4 update now I can't access Facebook or anything web based other than Apple or google. Any suggestions to help me sort this problem?