-
Designer, Programmer, Musician
[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.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
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.
Last edited by angelhdz; 12-08-2012 at 01:15 AM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
PHP Code:
function CreateClips()
{
for (var i = 0; i < 50; i++)
{
createEmptyMovieClip(["mc" + i],i + 1,_root);
trace("mc-" + (i + 1));
}
}
myButton.onPress = function()
{
CreateClips();
};
-
.
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.
-
.
Hi,
as for storing dynamically created movieclips, you don't, you actually store the data and then create clips based on the data.
-
Designer, Programmer, Musician
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.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
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!
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
well it would be something like
PHP Code:
var myArray:Array = ["1", "2", "3", "4"]; FirstRun = true; function CreateClips() { for (var i = 0; i < myArray.length; i++) { createEmptyMovieClip(["mc" + i],i + 1,_root); if (FirstRun == false) { trace("mc-" + (i + 1) + " Created with new data"); } else { trace("mc-" + (i + 1) + " Created"); } } } function RemoveClips() { for (var s = 0; s < myArray.length; s++) { _root["mc" + s].removeMovieClip(); trace("mc-" + (s + 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
-
Designer, Programmer, Musician
Last edited by angelhdz; 12-08-2012 at 09:40 AM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
Last edited by angelhdz; 12-08-2012 at 09:40 AM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
Last edited by angelhdz; 12-08-2012 at 09:40 AM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
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
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
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 ???
-
Designer, Programmer, Musician
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.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
-
Designer, Programmer, Musician
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.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
You have the recipe there Angel, decompile it and do the keystrokes.
-
Designer, Programmer, Musician
Yeah. Let me install the decompiler, thanks
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|