[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}
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); i =+1; //or i +=1; }
//Then something like this, i don't master the for loops yet
for (var i = 1; i<50; i++) { 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.
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.
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!
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.
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 ???
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.
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!!!