[RESOLVED] Create multiple movieclips and store them in Shared Object
A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: [RESOLVED] Create multiple movieclips and store them in Shared Object

  1. #1
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953

    resolved [RESOLVED] Create multiple movieclips and store them in Shared Object

    Hi,

    I'm creating 2 flash apps that require a button to create movieclips.
    Then i need to store these created movieclips so when refreshing the page or the SWF, the movieclips still there.

    I know how to work with shared object to store variables, but i don't manage to see how to store the dynamically created movieclips.

    My first app is a bookmark saver, you click a button "ADD URL" and a first movieclip is created, then when pressing that button again, a 2nd movieclip is create below the first one, leaving a 10px space between each movieclip. And finally, store/save these created movieclips in shared object.

    I think I know how to make the movieclip creation, making an if statement. If (nomovieclipcreated) {then create the first at this X and this Y } else { create a new one at first movieclip Y plus 10px}

    But how to store them? Thanks
    Last edited by angelhdz; 12-08-2012 at 01:03 AM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    I think I have an idea. When creating the movieclips on button press, I specify a Number variable. Then I make a FOR LOOP that reads these variables and according these variables, create the movieclips.

    Something like
    PHP Code:
    myButton.onPress=function(){
    createEmptyMovieClip("mc"[+i], "",  _level0);
    =+1//or i +=1;
    }

    //Then something like this, i don't master the for loops yet

     
    for (var 1i<50i++) { 
    createEmptyMovieClip("mc"[+i], "",  _level0);

    The thing is, when the flash starts, the for loop reads the shared object for "i" variable and according to these stored numbers, it creates corresponding movieclips.
    Last edited by angelhdz; 12-08-2012 at 01:15 AM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    PHP Code:
    function CreateClips()
    {
        for (var 
    050i++)
        {
            
    createEmptyMovieClip(["mc" i],1,_root);
            
    trace("mc-" + (1));
        }
    }

    myButton.onPress = function()
    {
        
    CreateClips();
    }; 

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    If you look at that Angel, there is a whole load of goodies with shared object, it stores colours, names, numbers, x /y positions, creating clips and deleting clips all in arrays.

    You'll have to decompile it though, sorry, no flashkit space left for me.

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,


    as for storing dynamically created movieclips, you don't, you actually store the data and then create clips based on the data.

  6. #6
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Yeah! I imagined precisely that, that I don't store the movieclip, but I create the clips based on stored data. Let me check what you replied.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  7. #7
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Wow, that's excellent!

    That's precisely what i need. Thanks for the reply. Let's begin with, your script for creating the clips kinda works. I changed the number "50" of the loop with "1" because I don't want 50 clips to be created, I only what "ONE" clip to be create at a time. When I changed the 50 with 1, each time I press the button, it creates one movieclip at a time , but in the output panel all the movieclips are called "mc-1". How to fix this?



    And then , how to store the needed data into a shared object in order to "save"/create the clips? Thanks!
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  8. #8
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    well it would be something like
    PHP Code:
    var myArray:Array = ["1""2""3""4"];
    FirstRun true;
    function 
    CreateClips()
    {
        for (var 
    0myArray.lengthi++)
        {
            
    createEmptyMovieClip(["mc" i],1,_root);
            if (
    FirstRun == false)
            {
                
    trace("mc-" + (1) + " Created with new data");
            }
            else
            {
                
    trace("mc-" + (1) + " Created");
            }
        }
    }
    function 
    RemoveClips()
    {
        for (var 
    0myArray.lengths++)
        {
            
    _root["mc" s].removeMovieClip();
            
    trace("mc-" + (1) + " Removed");
        }
        if (
    FirstRun == false)
        {
            
    CreateClips();
        }
    }
    myButton.onPress = function()
    {
        if (
    FirstRun == true)
        {
            
    CreateClips();
            
    FirstRun false;
        }
        else
        {
            
    RemoveClips();
        }
    }; 
    your array will be called from your saved data

    as for showing the data one by one, you have the ingredients with my attachment and you can show or hide things from the beginning etc ect

  9. #9
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    *deleted*
    Last edited by angelhdz; 12-08-2012 at 09:40 AM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  10. #10
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    *deleted*
    Last edited by angelhdz; 12-08-2012 at 09:40 AM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  11. #11
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    *deleted*
    Last edited by angelhdz; 12-08-2012 at 09:40 AM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  12. #12
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    flash kit gone crazy LOL!!!!

    This is my idea. "http://www.mediafire.com/?k6baavuzzzcd1vu Here is the fla.

    Is a bookmark saver. It's like the other tool i'm developing, it saves everything in a shared folder and sent it to your email.

    Check my fla. It should work like this:
    -First frame, you press "1" to go to the 2nd frame , to add urls.
    -Frame 2, you type the URL and press 1 to store that URL below in a dynamically created dynamic textbox. (I made a mistake, i don't want the for loop to create movieclips, but dynamically textboxes instead).

    By now, forget about the shared object, and help me please, to create the dynamic texboxes when typing "1" instead of pressing a button.

    Here is an animation to show you how it should work
    http://sofistica2.zzl.org/bmt2.swf
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  13. #13
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    Sorry Angel, I have not as clue what is going on there ??? and why have the keypress backspace, input fields have that naturally, when you press yours it deletes 3 or 4 letters in one go ???

  14. #14
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Neither do I have a clue what's happening there LOL.

    In the first frame,everything works great. You press "1" and it takes you to frame 2. If you press backspace, it removes only 1 digit.

    But when going to frame 2 (the same script as frame 1), when you type the URL, and press backspace, it removes 3 or 4 letters.
    The script to remove characters is this
    lolazo.text =lolazo.text.slice(0, lolazo.text.length -1);
    where "-1" says flash to remove "1" character of the textbox.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  15. #15
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    Angel

  16. #16
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Exactly that!!!! But with the BATCH styles and colors!!! And instead of pressing buttons, keyboard keys presses like in the batch files!!! We're almost there!!!
    Last edited by angelhdz; 12-08-2012 at 02:21 PM.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

  17. #17
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,110
    Hi,

    You have the recipe there Angel, decompile it and do the keystrokes.

  18. #18
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Yeah. Let me install the decompiler, thanks
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com