Dynamic movieclip duplication

Hi Everyone,
I am working on dynamic duplication of movieclip when the button is pressed one by one.
In that movieclip there are two buttons ok and cancel.
Here is the piece of code:
var new_panel:please_wait = new please_wait;
click_btn.addEventListener(MouseEvent.MOUSE_DOWN, generate);
function generate(e:MouseEvent):void{
    new_panel = new please_wait;
    addChild(new_panel);
    new_panel.addEventListener(MouseEvent.MOUSE_OVER , over_evt);
    new_panel.addEventListener(MouseEvent.MOUSE_DOWN , start_evt);
    new_panel.addEventListener(MouseEvent.MOUSE_UP , stop_evt);
    new_panel.ok_btn.addEventListener(MouseEvent.MOUSE_DOWN , ok_evt);
    new_panel.cancel_btn.addEventListener(MouseEvent.MOUSE_DOWN , cancel_evt);
function start_evt(e:MouseEvent){
    new_panel.startDrag();
function stop_evt(e:MouseEvent){
    new_panel.stopDrag();
function ok_evt(e:MouseEvent){
function cancel_evt(e:MouseEvent){
    removeChild(new_panel);
if i create two movieclip, then how i remove a particular movieclip.
i also attached the screen shot for reference..
Anyone Knows reply..
Thanks in advance..
Regards
Saransoft

I guess the problem with your code is your message box is getting duplicated twice.
You want to remove the previous instance if it is already on the stage.
If I am correct you can use the following code:
var new_panel:please_wait = null;
click_btn.addEventListener(MouseEvent.MOUSE_DOWN, generate);
function generate(e:MouseEvent):void{
    if(new_panel.parent)
          removeChild(new_panel);
    new_panel = new please_wait;
    addChild(new_panel);
    new_panel.addEventListener(MouseEvent.MOUSE_OVER , over_evt);
    new_panel.addEventListener(MouseEvent.MOUSE_DOWN , start_evt);
    new_panel.addEventListener(MouseEvent.MOUSE_UP , stop_evt);
    new_panel.ok_btn.addEventListener(MouseEvent.MOUSE_DOWN , ok_evt);
    new_panel.cancel_btn.addEventListener(MouseEvent.MOUSE_DOWN , cancel_evt);
function start_evt(e:MouseEvent){
    new_panel.startDrag();
function stop_evt(e:MouseEvent){
    new_panel.stopDrag();
function ok_evt(e:MouseEvent){
function cancel_evt(e:MouseEvent){
    removeChild(new_panel);

Similar Messages

  • Flash 5 speed in movieclip duplication

    this is my situation:
    I have a "cube" matrix containing boolean values: its
    dimension is 10 x 10 x 10.
    I have an isometric cube movieclip: it rapresents a matrix
    cell.
    In the render function of the matrix i clicle on the 3
    dimensions X, Y, Z; if the boolen value is true then I duplicate
    the movieclip and I put it in the right place (right coordinates).
    If I have few "true" value there's no problem....
    I tried to fill my matrix only with true values... the render
    funcion was very slow (about 2 seconds) for my purpose (it
    duplicates and creates 1000 (10 x 10 x 10) movieclips).
    is it a Flash limit (or Flash 5 limit!!!!!)?
    are new Flash releases optimized in movieclip duplication?
    thanks a lot

    create a new directory and save your fla (with a new name) in that directory.  restart your computer and then open that new fla in flash cs 5.5 and see if it performs better.

  • 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

  • Dynamic MovieClip reference

    Okay, how does one reference a MovieClip instance dynamically in AS 3.0?
    Example, I create a new instance of a "marker" MovieClip class that inherently has within it a series of embedded MovieClips labeled: "m1", "m2", "m3" etc ... and I want to be able to dynamically reference those embedded MCs.  I used to do this all the time in AS 2.0, and can't recall how to do it in AS 3.0.
    I know it is something like this:
    number = 1;
    marker = new StaticMarker();
    var thisMarker = this.marker.m[number];
    thisMarker.visible = true;

    Try:
    var thisMarker:MovieClip = this.marker["m"+number];

  • 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.

  • Dynamic Movieclips

    Hi
    I am writing an application which manipulates triangles and
    squares. I wish to give user control to the number of triangles and
    sqaures created and allow the user to manipulate each object.
    Now I am using attachmovieclip e.g.
    _level0.attachMovie("MyTRA_mc_link", MyMc,
    _level0.getNextHighestDepth(), {_x:412.5, _y:225, _alpha:78});
    and i have a list of names an array which allow me to name up
    to 26 variables - MCA, MCB, MCC ... MCZ.
    Now the user functions i have are:
    use of THIS for drag and drop
    then to move x or y or rotate i have to write the actual code
    for each function so i have MOVE_MCA(key_press), which is selected
    by a case statement and then depending on the key pressed i have
    movement in x, y or a roatation.
    Now my question is - is their a simplier and more dynamic way
    to do this. I tried writing functions which use the movieclip as a
    function but could not get this to work ?

    Hi
    Ok!, I think I understand what you want to do, so let's see
    I take it that the Triangle and Square are MC's in the
    Library? and you want the user to create as many of each as they
    wish or do you define a fixed amount?
    Once created they can rotate CW or CCW and move around on the
    x and y plane?.
    I will write some code, while I wait for your reply. This is
    relatively simple and shouldn't take more than 15 minutes to
    complete.
    Back soon

  • Attach eventlisteners to dynamic movieclips and pass a variable.

    Hi there,
    I have a mc (changeColorMc) and three movieclips. The three
    movieclips are created on the fly (so there could be more
    movieclips) and filled with a color from an Array. This works fine.
    Now I want to add an eventlistener for each movieclip, so
    when someone push one of the movieclips the movieclip with the name
    "changeColorMc" gets that same color from the colorArray.
    My question is: How can I pass the color value from the
    colorArray to the buttonPressed function? Is this possible?
    I was also thinking that I had to create three buttonPressed
    functions ie. buttonPressed1, buttonPressed2 and buttonPressed3 and
    attach these to the created movieclips.. but how? Because I don't
    know up front how many movieclips there will be..
    Thanks Peter.
    My code:

    Frankly, I am yet to see any piece of code that could be
    considered perfect and the only way to deal with a task. There are
    so many dependencies that what looks perfect today may turn out to
    be a total failure tomorrow and vise versa.
    My question about better way was purely conceptual. What
    would be the perfect code if it was written in English?
    Congratulations on purchasing Moock's book. So far I think it
    is the best single piece about AS3. I am sure you will be up to
    speed in no time.

  • Dynamic MovieClip Names

    I have an array that houses the names of six movieclips. I randomly select three of them. I am trying to get my randomly chosen movieClips to do what I want them to do. I have tried the following code to get the first to fade in:
    stop();
    // import tween classes
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var FirstPersonAnimation:Object;
    trace("mc"+[_global.FirstPerson]);
    FirstPersonAnimation = new Tween("mc"+[_global.FirstPerson], "_alpha", Regular.easeInOut, 0, 100, _global.FadeInTime, true);
    FirstPersonAnimation.onMotionFinished = function() {
    _root.nextFrame();
    But it does not work. The trace comes back with the full movie clip name ex: mcTom, but even though that value comes up in the trace, the AS doesn't see it as a movie clip. Any thoughts on how I can correct this?
    -Kirk

    I'm not sure what is involved with _global.FirstPerson, but when you use it the way you do, you are just feeding a string into the Tween.  You need to convert that string into an object using array notation:
    this["mc_"+_global.FirstPerson]

  • Accessing Child Dynamic MovieClips

    Dev Environment: Flash 9 Pro
    Alright, I have a movie that has one movieclip (imageHolder,
    this is defined in the Library and is an empty movieClip used as a
    place holder) which is on the stage. I read in and load images to
    the flash file, and create them in their own movie clips WITHIN
    imageHolder like so:
    ========================
    var nm= imageHolder.createEmptyMovieClip("swfHolder"+i,-(i *
    10));
    nm.loadMovie(filename);
    ========================
    Obviously this is a code snippet, I am using the LoadVars
    object to load these files. Once everything is loaded, it is
    displayed on the stage, with a depth in order from first image to
    last (first image on top, last image on the bottom). After this, I
    have an interval set, to call a function called "selectImage" which
    gets a variable called photonum, and changes images to the number
    you have passed in. In selectImage, I ensure that the image that is
    coming up next is one depth level below the currently displayed
    image using swapDepths, and I am constantly incrementing a variable
    called "curdepth" which is global, and always assigning that depth
    to the currently displayed image to that depth. So, the current
    image will be displayed at depth 30, and the next image up will be
    displayed at depth 29. Then I fade the current image out using the
    tween object, and it works like a charm! To reference these
    MovieClips I use the following code:
    ====================
    var cmc:MovieClip = eval("imageHolder.swfHolder" + (curpho +
    1));
    var nmc:MovieClip = eval("imageHolder.swfHolder" + (nexpho +
    1));
    // Force current clip to front
    cmc.swapDepths(curdep);
    // Force next clip to one below front
    nmc.swapDepths(curdepth - 1);
    ====================
    and this works perfectly... in flash. Once it's on the page,
    or displayed within the standalone movie player, everything goes
    south. I assigned the typeof cmc and nmc to a textbox, and i got
    "movieclip", in flash and on the page. However, if I store
    "cmc.getDepth()" to the textbox, I get "[type function]" in flash,
    but, on the page "undefined" It seems anything that is specific to
    the MovieClip object, such as getDepth(), or swapDepths() is
    undefined when I plug it into the textbox, but, things that are
    inherited, such as enabled, _x, or _y are all available for my
    perusal and setting.
    Does anyone have any idea how to remedy this? I can attach
    all my code in a couple of hours if necessary. I have tried not
    putting the loaded images into the imageHolder, and I found that
    didn't help. I have also tried a combination of adding "_level0."
    and "_root." to my cmc and nmc references to no avail. Any help
    would be greatly appreciated.

    Seems it had something to do with my Flash Installation...
    Tried it on another computer and everything was fine. What a
    pain!

  • Assembling dynamic pages, duplication of header material

    Folks:
    DW CS3
    Consider a home page, "index.php" which conditionally
    REQUIREs one of N HTML files containing pure content. All site
    styles are are specified in a master CSS file called
    "siteformatting.css" I've illustrated this schematically at the end
    of this message.
    I think that "index.php" must link to the master CSS file, so
    that HTML elements in this file can conform to site-wide standards,
    right?
    The content files must certainly link to the master CSS file.
    In fact, these content files must be fully valid stand-alone HTML,
    otherwise they will not pass DW file-->Validate-->Markup, and
    maybe other difficulties occur, correct?
    What I find is that all this works consistently during
    authoring in DW, but, when a page is served up, the recipient
    browser sees duplication of header (and trailer) material,
    including two identical header links to "siteformatting.css".
    Sure enough, the HTML Validator (0.8.5.2) extension to
    FireFox reports the duplications with multiple warnings.
    The obvious way deal with this is to ignore the warnings from
    HTML Validator. They aren't errors, and thus far I haven't seen any
    ill effects from the duplication.
    Or I could to push all the HTML out of "index.php" into
    stand-alone HTML files. But I'm reluctant about breaking up the
    home page into multiple files -- that seems ... very inconvenient
    for managing the site look. (Yes, my actual design is much more
    complex than the schematic description I'm using here, so I think
    it would require a dozen or more HTML files.) The only other option
    I can imagine is finding a way to persuade DW to pseudo-include the
    master CSS file for editing purposes but to omit the link to it in
    the actual code. Can DW do that?
    For a bonus, please correct any of my terminology that isn't
    clear. (I'm self-taught...)
    For an extra bonus, please let me know if there is a better
    place to bring up such questions, which I'll admit are only
    tangential to DW. (Except the issue of pseudo-including CSS in DW,
    which is valid but probably a bit bizarre and/or naive.)
    TIA,
    Henry
    file index.php
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link href="/siteformatting.css" rel="stylesheet"
    type="text/css">
    </head>
    <body>
    <?php
    if (condition1)
    require("content1.html")
    elseif (condition2)
    require("content2.html")
    else
    require("contentn.html")
    ?>
    contentN.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link href="/example.css" rel="stylesheet"
    type="text/css">
    </head>
    <body>
    [standard HTML defining content]
    </body>
    </html>

    You probabli dispay the data as
    <oracle> select empno,empname from scott.emp</oracle>
    However, you could do it like this:
    <oracle>
    being
    htp.p('<table>');
    htp.p('<tr>');
    htp.p('<td bgcolor=#ffaabb>empno</td>');
    htp.p('<td bgcolor=#ffaabb>empname</td>');
    htp.p('</tr>');
    for c in (select empno,empname from scott.emp) loop
    htp.p('<tr>');
    htp.p('<td>');
    htp.p(c.empno);
    htp.p('</td>');
    htp.p('<td>');
    htp.p(c.empname);
    htp.p('</td>');
    htp.p('</tr>');
    end loop;
    htp.p('</table>');
    end;
    </oracle>
    htp is package in sys schema in oracle.

  • Dynamic movieclip creation from library

    Version: Flash CS3, AS3
    To add a new movieclip to the stage from the library you can
    do something like this:
    var newMC:libraryMC = new libraryMC();
    this.addChild(newMC);
    To do this, however, I need to know the name of the library
    movieclip beforehand (in this case, libraryMC). What do I do when I
    only receive the name at runtime?
    ie:
    randomMC = "libraryMC";
    In AS2, you could use this.attachMovie(randomMC,"newMC",x),
    but that is no longer supported in AS3.
    So how is this situation handled now?
    Thanks
    Rick

    Thanks kglad - that's what I wanted.

  • Dynamic MovieClip and TextField

    Hi, I'm begginer in as3, and I want to ask you  my problem.
    I'm creating a lot of MovieClip in for cicle, and i want to add at every  MovieClip a textField.
    I try in this way
    for (var i:int = 0; i < 100; i++)
    var giorno:MovieClip;
    giorno = new MovieClip();
    giorno.graphics.beginFill(Math.random() * 0xFFFFFF);
    giorno.graphics.drawRect(i*(boxWidth+boxMargin),  0, boxWidth, boxWidth);
    var nameGiorno:String = "giorno" + String(i);
    giorno.name = nameGiorno;
    giorno.alpha = 0.6;
    var numGiorno:TextField = new TextField();
    numGiorno.text = String(i);
    giorno.addChild(numGiorno);
    addChild(giorno);
    but the textfield is only in the first movieclip.
    Somebody can help me?
    Thank a lot !!!

    yes, but i'dont find the error. under i post the code entirely
    package
        import flash.display.MovieClip;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import caurina.transitions.Tweener;
        import flash.text.TextField;
        public class Main extends Sprite
            private const boxCount:int = 10;
            private const boxCount_ok:int = 365;
            private const boxWidth:int = 300;
            private const boxMargin:int = 0;
            private const startPoint:int = 50;
            private const boxesWidth:int = boxCount * (boxWidth + boxMargin);
            private const endPoint:int = boxesWidth + startPoint;
            private const zeroPoint:int = stage.stageWidth / 2 + startPoint;
            private var container:MovieClip;
            private var targetX:Number;
            private var speed:Number = 0;
            public function Main():void
                    if (stage) init();
                    else addEventListener(Event.ADDED_TO_STAGE, init);
            private function init(e:Event = null):void
                    removeEventListener(Event.ADDED_TO_STAGE, init);
                    container = new MovieClip();
                    addChild(container);
                    container.x = 150;
                    container.y = 0;
                    for (var i:int = 0; i < boxCount_ok; i++)
                            var giorno:MovieClip;
                            giorno = new MovieClip();
                            giorno.graphics.beginFill(Math.random() * 0xFFFFFF);
                            giorno.graphics.drawRect(i*(boxWidth+boxMargin), 0, boxWidth, boxWidth);
                            var ok:String = "giorno" + String(i);
                            giorno.name = ok;
                            giorno.alpha = 0.6;
                            var numGiorno:TextField = new TextField();
                            numGiorno.text = String(i);
                            //trace(giorno.name);
                            giorno.addChild(numGiorno);
                            giorno.addEventListener(MouseEvent.MOUSE_OVER, illumina);
                            giorno.addEventListener(MouseEvent.MOUSE_OUT, spegni);
                            giorno.addEventListener(MouseEvent.CLICK, tracciaNome);
                            function tracciaNome(e:MouseEvent):void{
                                //Per tracciare il nome del MovieClip corrente sul quale si applica l' evento
                                //bisogna usare il nome della variabile evento della funziona (e:MouseEvent)
                                //e applicare la funzione currentTarget
                                trace(e.currentTarget.name);
                            function illumina(e:MouseEvent):void{
                                Tweener.addTween(e.currentTarget, {alpha:1, time:1});
                            function spegni(e:MouseEvent):void{
                                Tweener.addTween(e.currentTarget, {alpha:0.6, time:0.5});
                            container.addChild(giorno);
                    addEventListener(Event.ENTER_FRAME, enterFrameHandler);
                    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
            private function mouseMoveHandler(e:MouseEvent):void
                    var distanceFromCenter:int = stage.mouseX - zeroPoint;
                    speed = distanceFromCenter * -0.05; // Bring number into a good range, and invert it.
            private function enterFrameHandler(e:Event):void
                    container.x += speed;
    Thank a lot!

  • Dynamic MovieClip "Grid"

    Hello everyone!
    It's been i while since my last post, I wish I could be more
    active in this forums, but Flash it's just my sparetime activity,
    much like crosswords and since I'm bored here on vacation I decided
    to start a new simple project.
    I want to create a PhotoGallery application, nothing very
    complicate, but still a bit challenging (at least for me!!).
    Basically I want a "grid" of thumbnails from which I can enlarge
    the selected picture. I was able to create the "grid" using two
    "for" statements (one for the rows and one for the colums), plus I
    experimented the tween class, which I never used before. I have had
    no problem creating the "grid" because I hard coded the values for
    rows and columns, but a true photogallery application has to use an
    external XML file don't you think?
    Well, I thought it was a piece of cake, but the "double" for
    statement kinda block me. First of all, I haven't figure out how to
    hide the thumbnails that are in excess. For example, if I have 16
    pictures and I set a fixed number of columns (Let's say 5), I would
    need 4 rows, but the last one has to have just one thumbnail on the
    first columns and not an entire line of 5. Second of all, I can't
    loop the XML nodes inside the "double" for stament because
    obviously I get wrong values. Could anyone give me some hints in
    order to " fix" these problems?
    Sorry, for the long post, I hope you haven't fallen asleep!
    Thank you in advance for any help!!
    Test.fla

    Thank you very much for your reply. I understand the theory
    behind what you are saying; It makes perfectly sense. The problem
    is that it doesn't work. I'm sure I'm missing something and
    probably I didn't get exactly what you meant. I tried with this
    code:
    for (var i = 0; i<10; i++) {
    matrix = grid.thumb.duplicateMovieClip("thumb"+i, i+1);
    matrix._x = i*25;
    if (i%4) {
    matrix._x = 0;
    matrix._y = 80;
    the fourth thumb the goes down, but the other just stay on
    top of each other in the new line. I tried to add a new _x value,
    but then it would ignore the if statement and make a straight line
    of clips. Would be so kind to post an example?
    Thank you again!

  • Can't duplicate movieclips as an array within an array

    Hello.
    I have an animation that loads an xml into it and traces back
    an array within an array. I have tried to apply this to duplicated
    movieclips thereby creating a structured set of links. What I am
    trying to do is this:
    Chicken Nuggets
    __Compression
    __Texture
    __Disgust
    Mega Warhead
    __Taste
    __Hardness
    __Pain
    This traces fine but I can't seem to get the duplicated
    movieclips to assemble in this fashion.
    The code for the XML is as follows:
    var controlArray:Array;
    var variable:Array;
    var testTopic = new Array ();
    var test = new Array ();
    var controlsXML:XML = new XML();
    controlsXML.ignoreWhite = true;
    controlsXML.onLoad = function(success:Boolean){
    if (success){
    var mainnode:XMLNode = controlsXML.firstChild;
    var controlNodes:Array =
    controlsXML.firstChild.firstChild.firstChild.firstChild.childNodes;
    var list:Array = new Array();
    for (var i:Number = 0; i < controlNodes.length; i++) {
    var personnode:XMLNode = controlNodes
    .attributes.Name;
    trace(personnode);
    testTopic.push (new struct (personnode));
    var specificNode:Array = controlNodes.childNodes;
    for (var j:Number = 0; j < specificNode.length; j++){
    var itemnode:XMLNode = specificNode[j].attributes.Variable;
    trace(itemnode);
    test.push (new struct2 (itemnode));
    printer ();
    printer2 ();
    } else {
    trace('error reading XML');
    controlsXML.load ("controls3.xml");
    The code for the movieclip duplication is as follows:
    x = 50;
    function printer ()
    for (m = 0; m < testTopic.length; m++)
    duplicateMovieClip ( slotTopic, "slotTopic" + m, m );
    slotTopic = eval ( "slotTopic" + m );
    slotTopic._y += x;
    slotTopic.slotTopicContent.text = testTopic[m].personnode;
    function printer2 ()
    for (k = 0; k < test.length; k++)
    duplicateMovieClip ( slot, "slot" + k, k );
    slot = eval ( "slot" + k );
    slot._y += x;
    slot.slotContent.text = test[k].itemnode;
    function struct (personnode)
    this.personnode = personnode;
    function struct2 (itemnode)
    this.itemnode = itemnode;
    On the stage are two movieclips, titled "slotTopic" and
    "slot". Within those are dynamic text boxes titled respectively
    "slotTopicContent" and "slotContent". When I preview this file it
    only displays the text within the "slot" movieclip and it lists all
    six of the subtopics with no break. So, there are two dilemmas:
    1) The movieclips won't duplicate into the structured set of
    links that I want.
    2) "slotTopic" is not displaying text at all.
    If anyone has any advice, I'd really appreciate it.
    Thx!

    ok, I'm sorry but there are quite a few things wrong here.
    first though, when posting code please use the 'attach code'
    button.
    1) i can't imagine that you have a XML structure as deep as
    your calling to or the need for it with the limited amount of
    infomation your pulling, in addition your storing the info in
    attributes, so I can't see how this would work, it may 'trace' out
    the right text (somehow) but it's not getting into the arrays
    properly.
    2) you do not assign an attribute value to a XMLNode, and
    then try to push it into an array.
    3) you do not call a method (struct or struct2) using the
    'new' operator. this is how you envoke a new 'class' instance.
    4) do not use 'x' as a variable name as it is a reserved var
    in flash, assigned to an Object instance.
    5) the duplicateMovieClip() method needs to be called upon
    the existing clip as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m);
    additionally you can pass the _y placement within the
    initObject.
    6) you do not need to use eval, it isn't doing anything here,
    you will gain the correct path by calling duplicateMovieClip
    correctly.
    7) the reason why slotTopic is not being displayed at all is
    because of the second loop, you are duplicating the clips
    (incorrectly) into the same depths thereby replacing all of the
    contents of the slotTopic depths previously constructed.
    the solution to this problem is to construct both items with
    the same loop but increament one of the depth assignments by a
    specific number, in other words at depths much higher or at least
    different, than that of the first element, as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m, {_y:50});
    slot.duplicateMovieClip('slot'+(m+100), m+100, {_y:50});
    again I'm sorry man, but it will take some work to sort this
    out.

  • Is there any way to save an image from a nested movieclip as a .png using PNGEncoder

    Hello all,
    I am new to AIR and AS3 and I am developing a small AIR desktop application in Flash CS5 that saves a user generated image locally to their computer. 
    The image is generated from a series of user choices based on .png files that are loaded dynamically into a series of nested movieclips via XML.  The final image is constructed by a series of these "user choices".
    Sourcing alot of code examples from here and there, I have managed to build a "working" example of the application.  I am able to "draw" the parent movieclip to which all the other dynamic movieclips reside and can then encode it using PNGEncoder.  The problem is that the images loaded dynamically into the nested movieclips show as blank in the final .png generated by the user.
    Is there a way to "draw" and encode these nested movieclips or do I need to find another way?  I can provide my clumsy code if required but would like to know if this concept is viable before moving any further.....
    Thanks in advance....

    Thanks for the files.......
    Yeah I'm doing it in Flash but importing the images via an xml document.  The problem isn't in being able to view the eyes (based on the selection of the user) its when I go to save the resulting image as a .png.  When I open up the saved .png the eyes are blank even though they are visible in the swf
    Even when the user clicks on the option to copy the image to the clipboard, it works as intended.
    My only guess is there is an issue with the way my xml is loading (but this appears to work fine) or when the file is converted and saved.....
    As I said I'm still learning but surely there must be a simple answer to this....
    I have included the xml code I am using and also the save code to see if anyone spots an issue..... (I hope I copied it all)
    // XML
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    var xmlRequest:URLRequest = new URLRequest("imageData.xml");
    var xmlLoader:URLLoader = new URLLoader(xmlRequest);
    var imgData:XML;
    var imageLoader:Loader;
    var imgNum:Number = 0;
    var numberOfChildren:Number;
    function packaged():void
    rawImage = imgData.image[imgNum].imgURL;
    numberOfChildren = imgData.*.length();
    imageLoader = new Loader  ;
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedImage);
    imageLoader.load(new URLRequest(rawImage));
    faceBG_mc.Eyes.addChild(imageLoader);
    function loadedImage(event:Event):void
    imageLoader.x = -186;
    imageLoader.y = -94;
    imageLoader.width = 373;
    imageLoader.height = 186;
    //  Clipboard
    btn_Copy.addEventListener(MouseEvent.CLICK, onCopyClick);
    function onCopyClick(event:MouseEvent):void
    var bd:BitmapData = renderBitmapData();
    Clipboard.generalClipboard.setData(ClipboardFormats.BITMAP_FORMAT, bd);
    function renderBitmapData():BitmapData
    var bd:BitmapData = new BitmapData(faceBG_mc.width,faceBG_mc.height);
    bd.draw(faceBG_mc);
    return bd;
    // Save faceBG_mc as .png 
    var fileRef:FileReference = new FileReference();
    var myBitmapData:BitmapData = new BitmapData (faceBG_mc.width,faceBG_mc.height, true, 0);
    myBitmapData.draw(faceBG_mc);
    var myPNG:ByteArray = PNGEncoder.encode(myBitmapData);
    function onSaveClickPNG(e:Event)
    fileRef.save(myPNG, "myPNG.png");
    So my problem is....
    The final image is copied to the clipboard with the eyes visible - yes
    The eyes appear in the image in the swf as intended - yes
    When the image is saved as a .png and is meant to include the eyes, they are blank (see picture above)
    I hope this helps.....
    Thanks in advance

Maybe you are looking for