Creating an array of movieclips in AS2 oop

Long time proceedural programmer trying to switch to OOP.
Using the book "Object Oriented Actionscript for Flash 8" I've
created the example of a class with a movieclip passed to it as a
parameter. Trying to expand that to an array of clips/classes and
without success.
Here's the class:
class Location extends MovieClip {
var targetMC:MovieClip;
var x:Number;
var y:Number;
function Location(targetMC:MovieClip, x:Number, y:Number) {
this.targetMC = targetMC;
this.x = x;
this.y = y;
moveTo(x,y);
function moveTo(x:Number,y:Number) {
this.targetMC._x = x;
this.targetMC._y = y;
and for a single clip the following works well in the fla
attachMovie("dot","dot",1,1,100);
var myLocation:Location = new Location(dot, 200,300);
However when I try to create an array of 'dots' it doesn't
work.
var myLocation:Array = new Array();
for(x=0;x<5;x++) {
attachMovie("dot","dot"+x,1,1,100+x);
var myLocation[x]:Location = new Location(_root["dot"+x],
200,100+x*30);
Also how do I avoid using the _root command in this?

Below is code that should help. You were declaring myLocation
array twice by using “var”, which is syntactically
incorrect. “_root” is referring to the maintime. Since
your code is on the maintimeline and not in an eventHandler you can
use “this” to target it.

Similar Messages

  • How can i assign an identifier to a movieclip using AS2 ???

    Hey guys, i'm using the scrolling pane component in my
    project. i used to enter in the content path, the identifier of the
    movieclip which i set through the library. But now i wanna give it
    a movie clip that i've created in my code...so how can i assign an
    identifier to a movieclip using AS2 so that i can use it with my
    componenets ???? THANX

    I'm trying to make a script that goes through a folder recursively, checks for every folder if it's name is "template", and if so it changes the icon of that folder to an icon
    I chose.
    I searched for an answer here, and I've only managed to find a way to assign an icon to a shortcut, but not to an existing file.
    Thanks in advance (:

  • Displaying an array of movieclips

    hello
    I am trying to create an array of several movieclips (they
    are actually just one frame graphics) that will display only one
    movieclip at any given time depending on a counter value.
    I setup an array with movie clip names in quotes
    var ChlogoAr:Array = new
    array("sixties","fifties","forties");
    The only way i know how to make this work is to palce all the
    movieclips on the stage, but outside the document area, then change
    the ._y value of the one I want displayed
    ie.
    ChlogoAr[2]._y = 40;
    but actually, that doesnt work. Is there a way to accomplish
    this? Ideally, I would want to setup a placement holder and then
    display whichever movieclip that matched up with the counter. thank
    you for any advice.

    you can use a dynamic textfield to allow users to type a
    movieclip _name or part of a movieclip name which you then use to
    reference a movieclip. again, you would use the array operator to
    help flash resolve a string to an object (like a movieclip).

  • Main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)

    main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)
    The path(Grundpfad)for the excel file should be inserted in the main.vi.

    1. There's a shipping example called Write Table To XL.vi (Help>Find Examples>Communicating with External Applications>ActiveX>Excel) that you can use as a starting point.
    2. Buy the LabVIEW Report Generation Toolkit. Info can be found here.
    3. Search this forum for other examples of writing to Excel.

  • How do you create an array without using a shell on the FP?

    I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
    So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
    do not want to go that route.)

    Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
    I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
    If I seem a tad green... well I am.
    I hope you understand the LabVIEW environment and icons are still very new to me.
    Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
    e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
    "I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
    the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
    Attachments:
    Initialize_Settings.vi ‏55 KB
    Save_Settings.vi ‏52 KB

  • Creating a report in Web dynpro using OOPS concept

    Hi all,
             Iam new to web Dynpro, i need to create a report in Web Dynpro  using oops concept. can any one guide me regarding it.
    Regads,
    Easter

    Hi,
    Please refer to these links -
    DEMO_COMMON_ASSISTANCE1 -Example for standard component
    http://help.sap.com/saphelp_nw04s/helpdata/EN/43/1f6442a3d9e72ce10000000a1550b0/content.htm
    http://help.sap.com/saphelp_nw04s/helpdata/EN/43/1f6442a3d9e72ce10000000a1550b0/content.htm
    Regards,
    Lekha.

  • Is it possible to/how can I create an array of arrays in Labview 6i?

    I am trying to create a data structure based on a tree where each limb is an array of arrays and each of those arrays is an array of arrays...etc. My ultimate purpose of this is for multidimensional (infinite) data saving/data recovery.

    I suspect it won't work for your intended application, but here is an answer to your question:
    You can't create an array of arrays, because that would be the same as increasing the number of dimensions of the array. However, you can store an array in a cluster, then have an array of clusters with arrays in them. So, indirectly it is possible. This gives you the possibility of each array being a different size.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order

    I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order. Any ideas, I've been playing with the idea but have had no luck, is this even possible?

    Hi,
    Please check it out the attached Vi.. Is this you need?
    Sasi.
    Certified LabVIEW Associate Developer
    If you can DREAM it, You can DO it - Walt Disney
    Attachments:
    Event.vi ‏11 KB

  • How to create an array in if/else or case structure without 0's ?

    Hello,
    I've been trying to do this for a while now.
    I only managed to think of this in three ways:
    1. (What I'm doing right now Create the array by going through a for loop, which populates the array by auto indexing. It populates with correct number if true and with a '0' if false. The idea was to delete the 0's later on in the code. This however seems highly ineffective.
    2. Make use of a shift register, which automatically adds the correct number to an array. The problem is that the array will keep growing and growing and at the very least would tremendously slow down my program. At worst, it would crash.
    So, my question is: How do I create an array that if a comparison is true, it puts the element in and if not it does nothing ?
    I've attached a PNG snippet of my code.
    Kind Regards,
    David.
    Solved!
    Go to Solution.
    Attachments:
    Get_Indices.png ‏24 KB

    Pladio wrote:
    I've been trying to do this for a while now.
    You did not explain what "this" is. Can you give some typical inputs and expected outputs? Populate your controls and indicators with typical data and make it the default efore attaching.
    Pladio wrote:
    So, my question is: How do I create an array that if a comparison is true, it puts the element in and if not it does nothing ?
    Your code show three different comparisons. Which one are you talking about.
    Pladio wrote:
    I've attached a PNG snippet of my code.
    That code makes very little sense. Why is there a shift register if the data in it never changes? What is the purpose of the inner FOR loop? Why are you creating a 2D array?
    Do you want to remove all rows where the corersponding SD is zero, for example?
    LabVIEW Champion . Do more with less code and in less time .

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

  • How to create an array in bpel?

    I am trying to integrate a web service into open-esb. The web service consumes an unbounded array of a "userInfo" data structure. The issue is that although I can create bpel to receive a message like this, due to type incompatibilities I need to create a different array within bpel to pass to the webservice.
    To date I have not found a way to create an array within open-esb's bpel. After extensive googling I have found that other ESBs define their own proprietary extensions to add nodes to an array.
    Thus I have two questions:
    First, does open-esb support creation of arrays? and if so, how do I create the array and add nodes to it?
    Second, and perhaps more importantly, is using an <assign> activity the best way to transfer a potentially large array from one variable to another (i.e., will it perform well)? Or should I use XSLT to transform the array from one wsdl type to another? And if XSLT is the answer, how can I do this within open-esb?
    Thanks in advance,
    Steve
    PS. Based on the various googlings Ive been doing this question seems to be frequently asked. If someone will help me find a solution I plan on writing a short "how-to" article for posting back to the community. Given that arrays are one of the most basic data structures I hope the article will be useful for others struggling with this issue.

    I think this is all covered in Steve-Nies other thread concerning this subject, entitled "Need help with BPEL please" (http://forum.java.sun.com/thread.jspa?threadID=5116270&tstart=0)

  • How do I create an Array of Images

    Hi,
    I'm creating a program that basically is a slideshow. It has buttons that allow the user to switch from image to image, and has some audio in the background. I was wondering how I might create an array to store the images. I'm very new to Java, so please no detail is too small. I've just started using arrays, so I'm not sure where I would store the files or how to call the images. Please be descriptive and as dumbed down as possible :)
    Thanks for the help!

    I like ArrayList
    ArrayList<BufferedImage> myPics = new ArrayList();then just dump them in with add(myBufferedImage)
    If you'e not using BufferedImages then just change the BufferedImage to Image.
    to get, say the 6th image back out, then use:
    myBufferedImage = myPics.get(5);the index starts at 0 and should be addressed as 0 to (myPics.length - 1)

  • Creating an Array of external JPGs, please help.

    So what I want to do is load up external JPGs into an Array of MovieClips, and then go to the main onEnterFrame function. My code is below:
    var imageLoader:Loader = new Loader();
    var imageArray:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i] = new MovieClip();
            imageArray[i].addChild(imageLoader);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    I tried adding an Event.COMPLETE function I found:
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[i] = new MovieClip();
         imageArray[i].addChild(image);
    Unfortunately, I usually only ended up with 1 or 0 images, and errors. I can't seem to properly pass the i
    value, so that's a big problem because the order the images go is key to my program.
    Please help me get this working so my image gallery can work, thanks!

    So the problem is that you want them in the array in the same sequence am I right on this?
    See the updated code:
    var imageArray:Array = new Array();
    var imageLoader:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            var imageLoader[i] = new Loader();
            imageArray[i] = new MovieClip();
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i].addChild(imageLoader[i]);
            //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    /* function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[index].addChild(image);
    In this case you can not track whether an image is loaded or not. It is the most simplest way of doing this. If your images are not coming from dynamic sources and are fixed in number and position you can use this method also.

  • "Using a CIN to Create an Array of Strings in LabVIEW" example crashes LV on Linux

    Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)
    Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:
    LabVIEW caught fatal signal
    7.1.1 - Received SIGSEGV
    Reason: address not mapped to object
    Attempt to reference address: 0x0
    Segmentation fault
    Any ideas? Did anybody try this on a Windows machine?

    H View Labs wrote:
    Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)
    Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:
    LabVIEW caught fatal signal
    7.1.1 - Received SIGSEGV
    Reason: address not mapped to object
    Attempt to reference address: 0x0
    Segmentation fault
    Any ideas? Did anybody try this on a Windows machine?
    This code is badly broken. In addition to resizing the actual handle to hold the number of string handles you also would need to create the string handles itself before attempting to write into them. NumericArrayResize is the fucntion to use as it will either resize an existing handle (if any) or create a new one if the value is uninitialized (NULL).
    /* resize strarr to hold handles to NUMSTRINGS strings */
    err = SetCINArraySize((UHandle)strarr, 0, NUMSTRINGS);
    if (err)
    goto out;
    /* perform this loop once for each element */
    /* of array of strings being created */
    for (i = 0; i < NUMSTRINGS;) {
    LStrHandle handle = (*strarr)->arg1[i];
    /* determine length of string that will be element of strarr */
    strsize = StrLen(str[i]);
    err = NumericArrayResize(uB, 1, &handle, strsize);
    if (err)
    goto out;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    /* moves strsize bytes from the address pointed to */
    /* by str[i] to the address pointed to by the data pointer in the handle */
    MoveBlock(str[i], LStrBuf(*handle), strsize);
    /* manually set size of string pointed to by *strarr */
    (*((*strarr)->arg1[i]))->cnt = strsize;
    /* manually set dimSize of strarr */
    (*strarr)->dimSize = ++i;
    return noErr;
    out:
    return err;
    Rolf KalbermatterMessage Edited by rolfk on 06-30-2005 03:15 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

Maybe you are looking for

  • Using List Class in java.awt / java.util ?

    have a program that: import java.util.*; List list = new LinkedList(); list = new ArrayList(); ... read a file and add elements to array use a static setter StaticGettersSetters.setArray(list); next program: import java.awt.*; public static java.util

  • Open an Access database from ASP on the Windows 2008 32-bit server

    We are upgrading to a Windows 2008 server.  The ASP application opens an Access database with this code:   Set oConn=Server.CreateObject("ADODB.connection")   oConn.Open  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\webdata\applications\po\sfisn

  • What happened to the Sync button in iTunes 11?

    I don't see a sync button in the new iTunes, nor does it individually list the podcasts that are downloading. They are all lumped together. These seem like losses of functionality, but maybe I'm doing it wrong. Do I really have to go to the menu to s

  • Is it possible to upgrade the graphics card in the HP ENVY 17-j053ea?

    Hi I'm considering buying the HP ENVY 17-j053ea for use as a portable workstation for applications such as Max Design, autocad and photoshop as a second system for when I need to be away from the office but still need the ability to work. This machin

  • Time series for cvc's

    hello In any case ( whether new cvc's added or the new period is to be included ) we create time series for the planning area. Not aware as to why Adjust time series option is given for Planning Object Structure at the time of creation of cvc's. Any