Declaring MovieClipLoader Objects in loop

I'm trying to clean up my code. I have a varying number of
MovieClipLoaders and related listeners.
I wanted to make a general purpose loop to create them where
I can call the function with a variable and instantiate both the
MovieClipLoader and its listener.
I'm starting with pretty typical MovieClipLoader code.
var MCname = new MovieClipLoader();
var MCListener = MCSlotname+"Listener";
var MCListener:Object = new Object();
MCSlotname.addListener(MCListener);
//Load Files
MCListener.onLoadComplete = function(MCSlotname:MovieClip) {
_global.MCname.Loaded = true;
But if I try to put it into a function and pass a variable so
that each call to the function will instantiate a different
movieclip loader it seems I run into a problem.
function MakeLoader(InstanceName){
var MCname = new MovieClipLoader();
How do I use the value of the instanceName to provide a
unique var name for the instancing of the new MovieClipLoader?
Thanks.

> var MCListener = MCSlotname+"Listener";
> var MCListener:Object = new Object();
That won't do what I imagine you want it to do. The first
line gets overwritten by the second line.
> How do I use the value of the instanceName to provide a
unique var name for
> the instancing of the new MovieClipLoader?
There are a couple of different ways this could be
approached. The most literal answer to your question I think would
be:
this['loader_'+instanceName] = new MovieClipLoader();
So, say the instance name is "myClipOne", it would make:
this.listener_myClipOne
However, here are a couple other things to consider:
1) A single MovieClipLoader can load multiple clips at once.
2) Neither the MovieClipLoader nor the listener need to be
assigned to a variable, or unique variable. They will function the
same wether or not there is a reference to them in variable.

Similar Messages

  • So how do you declare an object?

    Okay I have a program I'm trying to build that lets me navigate between menus...
    Main Menu starts up:
    (Unimportant)
    Then it takes me to another Menu.
    When this is over I want to go back:
       System.out.println("Select: ");
            System.out.println("1: to Return to the main menu");
            System.out.println("or");
            System.out.println("0 to Exit");
         if(input.nextInt()==1){
             main(); // <-- error here
         else if(input.nextInt()==0){
             System.exit(0);
            }   It doesnt find the main method because I didn't declare it as an object at the top...
    How do I do that?
    Edited by: tark_theshark on Mar 30, 2008 5:24 AM

    Nah, this has nothing to do with declaring an object, and you really don't want to do this. What you really want to do is to have a loop of some kind, say a while loop and have the loop repeat until the user presses "0". Something like so:
        public static void main(String[] args)
            boolean done = false;
            while (!done)
                if(input.nextInt() == 0)
                    done = true;
        }Edited by: Encephalopathic on Mar 30, 2008 6:27 AM

  • New object inside loop condition

    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
         //now would like use File object created above
    }What's the notation for that?

    YoungWinston wrote:
    TheGreatEmperor wrote:
    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
    //now would like use File object created above
    }What's the notation for that?Encephalopathic gave it to you, but I'd worry about ending up with a never-ending loop. What about
    if ((myFile = new File(fileString)).exists()) { ...instead?
    Winston1) Same thing I put (except change the name "f" with "myFile")
    2) you could get a never-ending loop with your answer (depending on the body)
    3) The previous answer by Encephalopathic would NOT give a never-ending loop unless there was a never-ending listing of files with the name:
    "Foo" + fileCounter + ".txt"; where "fileCounter" is incrementing (as done in his code)

  • Puzzle about declare List object

    Why we declare a object using "List list=new ArrayList();" other than "ArrayList list=new ArrayList();"?I have seen in Java API that:"Source source=new StreamSource();" other than "StreamSource souce=new StreamSource();".Is there any advantages to do this?

    just gives you more flexibility when you may possibly change the instance of the object being created.... more like the Factory patteren....
    hmmm.... i dont think im making much sence here.... :O)) let me explain with an example....
    the return type of Calendar.getInstance() is Calendar while internally it actually returns an instance of GregorianCalendar which is a sub-class of the Calendar class... the reason to that all the methods that you want are available in the Calendar class, & if a couple of version down the road if the API changes to return an instance of some other sub-class of Calendar, anyone using it would not be effected....
    BUT if in your case you are using specific methods that are only available in the ArrayList and not in the List class.... then you would be better off using ArrayList list=new ArrayList()....
    hope this explains to some extent
    regards
    omer

  • Help, can I declare an object using a variable name

    I need to make a bunch of objects using a for loop, so I was wanting to name the object one of the variables that I read. But I basically want to know if I can do this.
         private Software makeObject(String proName, int proStock, double proPrice,String objName){
              Software objName = new Software(proName,proStock,proPrice);
              return objName;
    I want to create a Software object using the objName inputted to it. The software object holds three fields as you can see. The name, num in stock, and price. However it won't let me do this, because it says objName is a duplicate variable. Help would be appreciated

    private Software makeObject(String proName, int proStock, double proPrice,String objName){
    Software objName = new Software(proName,proStock,proPrice);
    ... it won't let me do this, because it
    says objName is a duplicate variable. Help would be
    appreciatedWell, it is duplicate. Change the name of one or the other of those variable names.

  • Where do I declare my objects?

    I've never understood where to instantiate/construct/declare? my objects. For example when making a JFrame I could put
    JFrame frame;
    at the top of the program and the in the main class put
    frame = new Frame();
    or I could just put
    JFrame frame = new JFrame();
    Which one do I use and in what situation?

    You could theoratically do both. Because it really depends on the scope of how you want to use your object.
    For example, for the following code... You can subsequently use the xxx Object in xxxMethod2()....
    public class NewClass {
         private Object xxx;
         public void xxxMethod() {
              xxx = new Object();
         public void xxxMethod2() {
    }But for the following code... you can't use xxx in xxxMethod2()... since the scope of the object already ends in xxxMethod().
    public class NewClass {
         public void xxxMethod() {
              Object xxx = new Object();
         public void xxxMethod2() {
    }I hope i've made it simple enough for you to understand.

  • Function module parameters declare BOR Object

    I dont know if this is even logical...
    I need to create a function module which will be used in my  program..
    Can I create an object of BOR object type say 'Sales Order'  and pass it as an export parameter in Function Module..
    i.e i will pass the obj key and obj type as import..
    I want to instantiate that Sales Order.. and pass the whole Sales oRder as export/tables  parameter..
    I know swc_object_create is supposed to create an object but as i can see it only has the handle.. and it is of type swc_object..
    But i want to export  the whole Instance .. so that i can call the methods of the object  in my original program..
    Regards,
    krishna

    Hi Ravi ,
    I simplified my requirement but my actual requirement is with workflows...
    I have a scenario in workflow where,
    1.Activity step to fill internal table with sales order numbers
    2.loop at sales order numbers internal table
    3.Activity Step to Instantiate  based on order numbers
    4. Activity Step to Edit these sales orders
    5.end the loop
    For the above logic in workflows i have separate Activity step for instantiation..What I am thinking of is to instantiate the sales orders and fill the instances in the internal table in Step 1 instead of just order numbers..In the BOR method/F.M  of Step 1 I need to export the Instance of the Sales Orders (this is my actual question/problem, how do i instantiate while coding??swc_object_create, creates only a ref to object ...If I am able to create the object what should the type be in export /tables parameter)
    This way i can remove the loop and offer parallel processing (from miscellaneous tab in activity step) and send multiple Edit workitems to user  at Once instead of one after the other..
    Please let me also know how you would handle the above situation, i am very new to workflows and BOR.

  • Declaring an object

    I have a class (lets say it innerClass) which is nested inside the main. I have a method which has been used defined another class. Now, i want to create an object of the class which contains the method definition and use it in the innerClass which is inside main. How can i do it?
    Heres a sample code:
    Class A
    method m()
    some code;
    public static void main(String [] args)
    display.asyncExec(new Runnable() ) //Innerclass
    want to use the method here;
    Now where do i create and with what do i initialize it?
    Edited by: iconabhi on Nov 30, 2007 8:51 PM

    If it's not evident to you where and how your object should be constructed, you probably don't need an instance of that object. You should make the method static and call it statically, with A.m().
    Now, if what you have is multiple classes (say A, B, C, D) implementing the same interface I, and m() is declared in I, then that's a different story. That's closer to the Strategy pattern that petes mentioned. However even with the strategy pattern, the whole point is that you would just have some object of type I supplied to you from the outside caller or a factory method. So it seems more likely that you just need a static method.

  • Declarative java object cache in non oc4j container

    hello,
    i'm trying to use the cache.jar from 10g in a standalone application.
    i've followed the j2ee services guide and use cache.open(path_to_javacache.xml). javacache.xml has preload-file defined, in which i've declared my userdefined classloader and userdefined cached object. the implementations of both implement declarable. however,when i use cacheaccess.getaccess(region_name) i get regionnotfoundexception.
    i've also tried to use the configurator alternative, where i specify the declarative cache xml file. but this gives me a classcastexception.
    any suggestions. better yet is there a sample program that
    shows the use of a decl cache in a non oc4j container.
    thanks

    Hi,
    I ran into the same problem while evaluating OC4J V9 Java Cache standalone.
    Cache.open() silently ignores errors:
    * Cache.open(path_to_javacache.xml) seems to silently swallow alle error messages (in your case the ClassCastException) and the ignore the configuration file
    * so to get meaningful error messages, first attempt to open the file with new Configurator(path_to_javacache.xml)
    * once there are no more errors, you can open it with Cache.open(path_to_javacache.xml)
    Now, to get around the ClassCastException:
    * you need to add xmlparserv2.jar from your oc4j distribution
    * this must be the first xml-parser in your classpath (when e.g. xerces.jar comes first, you will get a ClassCastException)
    A relative javacache.xml is relative to your working directory.
    The preload-file - Path seems to be relative to the javacache.xml path, if it is not absolute. I keep javacache.xml and preload-file together which worked for me.
    Hope this help,
    Andreas

  • Declaring an object with a string

    Is there a way to declare a data object (at runtime) from a
    string descriptor? For example, lets say I load a text file that
    contains the following string: "{name:"bob", age:42,
    location:"earth"}". Is there a way to then have Flash parse the
    string and interpret it as an Object object in memory?
    Thanks!

    This may be just what I need, thanks for the tip!
    I've set up a quick test though, and I'm having some
    problems. My code is as follows:
    import JSON;
    var str:String = "{'var1':'hello world'}";
    var obj:Object = JSON.parse(str);
    trace(obj.var1);
    All that I'm getting is an "[object Object]" trace in my
    output window (upon JSON.parse() calling). Scripts following the
    parse command do not run (ie: the trace action). And, if I try to
    access the obj object later (I was checking it upon a button
    press), then Flash is reporting that obj is undefined. Do you have
    any insight on this?
    Thanks for your help!!

  • Declaring String object

    Is it a good practice to initialize a String object variable to a zero length string?
    String strMyString = "";and later, when we need to assign a new value for it, we just do
    strMyString = "Hello World";This is correct or not?

    It's only appropriate if you want an empty string to be the default, and you don't invariably reassign it. This doesn't happen very often; usually you either can (and should) unambiguously find a value for it, or you can just use null, or you don't need a default at all.

  • THREAD,  OBJECTS,  FOR LOOP

    HI FORM
    I have a method which does some heavy duty mathametical validation and this
    method accepts I/p args from a String[6] for ' n' times avaliable via a for loop .
    1) How to assign this method to run in a threads in parallel ,so the validation is
    avaliable at a same instance .
    Please Do advise me with some code.
    Thx in advance

    I can give more Clarification to this if needed.I think I understand what you're trying to do. Sort of. Enough to suggest how you should do things at least :P
    I'm not entirely sure really that threads are the best way to do this, but I also don't know what I/p stuff is :P
    But if you do go with the threads still, here's how I'd do it.
    for(int row=0; row < rows; row++){
        for (int col=0; col < col; col++) {
            /*this assumes that the textBoxes came from an array,  of the fashion TextBox[rows][cols] which I doubt                 they would.*/
            String text = textBox[row][col].getText()
            Whatever whatever = new Whatever(text);
            Thread t = new Thread(whatever);
            Thread.start();
    }public class Whatever implements Runnable {
    protected String text;
    /** Creates a new instance of Whatever. */
    public Whatever(String text) throws Exception{           
    this.text= text;
    //Whatever this whatever does.
    public void run() {     
    If you want to get the text as well in your whatever, you could pass it enough information to find it.
    As for what you replace my imaginary TextBox array with? I haven't done much with JSPs, and it was quite awhile ago so my memory might be a little fuzzy, but I think you get a Map with key value pairs. In which case you'd do something like
    for (String key: map.keySet()){
        String value=map.getValue(key);
        Whatever= new Whatever(text);
        Thread t = new Thread(whatever);
        Thread.start();
    }Does that help?

  • Question on declaring an object initialized in a constructor

    Anyone knwo what is wrong with the winappFrame line below? It's from a book I'm following along and it errors in my IDE.
    public class winapp extends java.applet.Applet {
         public static void main(String[] args) {
              winappFrame frame = new winappFrame("System Status");
              frame.resize(400, 300);
              winapp applet = new winapp();
              frame.add("Center", applet);
              applet.init();
              applet.start();
              frame.show();
         public void paint(Graphics g) {
              g.drawString("The system is currently down", 60, 30);
         class winappFrame extends Frame {
              public winappFrame(String str) {
                   super (str);
              public boolean handleEvent(Event evt) {
                   switch(evt.id) {
                        case Event.WINDOW_DESTROY:
                             dispose();
                        System.exit(0);
                        return true;
                        default:
                        return super.handleEvent(evt);
         }

    Your error message in Reply #2 (don't know why it says textfields, but ...) means:
    winappFrame class only exists inside an instance of winapp. So, try this:
    Instead of what you have:
    winappFrame frame = new winappFrame("System Status"); // 1
    frame.resize(400, 300); // 2
    winapp applet = new winapp(); // 3Do this:
    winapp applet = new winapp(); // 3 [above]
    winappFrame frame = applet.new winappFrame("System Status"); // 1 above [note change]
    frame.resize(400, 300); // 2 [above]

  • If a variable is declared in d for loop, can it be used afterloop exits?

    pls someone explain this to me!

    Do you remember The Green Phantom?i know a girl who has one..
    its long, vibrates at 4 speeds?Well, I suppose your breath is fresher when she uses it versus when ...
    No, I can't post that. [CANCEL]

  • Declare object type inside the package

    Hi,
    How can I declare an object type inside the package?
    CREATE TYPE TempObj AS OBJECT (
    user_id number,
    text varchar2(4000),
    date_created DATE
    This will not work if placed inside this:
    CREATE OR REPLACE PACKAGE SAMPLE_PKG IS
    ---declaration goes here.
    END SAMPLE_PKG;
    I tried using the type RECORD and it worked. But I am just curious how to declare an Object. Or maybe RECORD is the replacement of Object? is this correct?
    thanks,
    Baldwin

    The inside of a PL/SQL package should contain PL/SQL statements.
    CREATE TYPE is not a PL/SQL statement. You can't create a table in package either.
    If data protection is the reason that you would rather create the type inside the package, then consider using a record type as you suggested, or hiding the SQL type in a more protected schema.
    Message was edited by:
    jonjac

Maybe you are looking for

  • Table numbers in a column to Right alignment

    Hi All, I have a table like the below. Age (Years) 1985 1998 2007 1–4 52 35 29 5–14 26 20 15 15–24 102 82 80 25–44 167 161 144 45–64 875 680 661 65–74 2,848 2,495 2,059 75–84 6,399 5,703 5,164 Over 85 15,224 15,111 12,947 I want to decimal align the

  • CVI 8.0 / Diadem 10.0

    Hi, I'm  thinking about introducing DIAdem to our LabWindows/CVI applications. However, I learned on a DIAdem product presentations that CVI 8.0 does not yet has the full capabilities when it comes to generating TDM files. Can anyone list the limitat

  • Login name appears as full name - how to change to short name?

    My user name for login on previous versions of OS X always appeared as the "short name". Since I installed a fresh copy of Snow Leopard, the user name in login boxes appears as my full name instead. How do I make the short name appear instead? (I'm a

  • How to use SQL Dev with MySQL DBs ? Connection Setup

    As far as I know SQL Dev can be used with MySQL databases as well. How do I have to setup the connection for MySQL? In detail what do I have to enter for -role -connection type SID/ServiceName Or is there a separate version for Oracle and MySQLß Pete

  • Help! My Xserve is not working!!!

    I had an G5 Xserve running 10.4.6 with an XRAD connected to it, this server ran my network home folders I ran a software update and now its hosed. I booted the xserve in target mode and ran the combo updater for 10.4.7 hoping it would fix the issue,