A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: ::General Flash Organization question

  1. #1

    ::General Flash Organization question

    I have learned to use Flash basically by myself and I have this feeling that a lot of the methods I use might be innefficient or downright incorrect because it seems that I constantly have a problem with my projects coming out very choppy and/or slow and I wanted to see if anyone could answer a few simple questions for me.

    First, I use a lot of movie clips. If Im doing a site, every button is a movie clip (usually same file but load different text over each one) and if it is some sort of presentation, whatever is being animated is a movie clip. Do movie clips take up a lot of space? Should I limit their use? And as far as website menus go, what is the standard way of creating them? As I said, I usually have a list of buttons created from the same mc and load different text over them and then organize all of them into "menu_mc" or something..is there a better way of creating a menu?

    Second, I use onEnterFrame functions for almost every one of my animations and I get the feeling that this might cause a bit of lag...does it? If so, should I just use if/else functions to animate things? or some other function?

    Third, I have learned what Arrays are--they are basically list of variables/values/whatever but I am clueless as to their application. How would I use an array in a website? or at all? What are the most common uses of them? Why are they used at all?

    And that's basically it. I would appreciate anyone's help with my questions and also if you can provide me some insight on any other common errors with Flash or maybe even secrets that you've figured out as to organizing sites better or making things run smoother. Thanks!

  2. #2
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Rome, Italy.
    Man, I love to hear words like yours..! I was exactly in you same situation some time ago..

    Well to answer you questions..movieclips are the basic feature of Flash, that let you integrate in the most productive way programming and graphics. You can use trully as many mc's as you like (an empty movieclip occupies around 4Kb of memory, and if it's still it does not add graphic computation resources..).
    As regarding the use of the onEnterFrame event handler, you should start thinking that Flash has a major limit: it's ability to execute code is really bad..Actionscript is rediculusly slow, so you must take deep care of your scripts trying to design them so that they use the least resources as possible, so that you leave them for graphic computations.. this will come with experience.

    I personally took a very long time to learn arrays, just because I thought they'd be difficult: when I learned how to use them I got angry at my self for having left me behind for so long!
    Arrays are the base for practically anything you may want to do with actionscript...I'll give you two examples:

    1) If you want to create a series of buttons, you can use an array (that can have been retrieven from a stored file, like a database or a text file, or a webservice) to drive a "loop", like this:

    //suppose that the following array has been retrieven from somewhere;
    myArray = ["first", "second", "third", "fourth"];
    //this will create a series of buttons starting from a template,
    //already placed on the stage;
    for(var i=0; i<myArray.length; i++) {
    myDefaultButton.duplicateMovieClip(myArray[i], i);
    eval(myArray[i])._y = i*30;

    2) In this case we want to create a "number chooser" (which would look like a number next to two arrows, that let the user increment or decrement it's value) with fixed values (so it wouldn't go through each number, but it would jump through preselected choices):

    //this creates the preselected choices;
    //in this case we will integrate the selected item's ID
    //within the array, so the first array's element indicates
    //the currently selected choice:
    myChoices = [1,5,27,85,130];

    Then on the buttons you would put something like this:

    //the "increment" button:
    on (release) {
    if(myChoices[0]<myChoices.length) {
    //in the next line we use the first element
    //as the key to access the value
    //of the currently selected array element
    myDisplay = myChoices[myChoices[0]];
    // the "decrement" button:
    on (release) {
    if(myChoices[0]>0) {
    //in the next line we use the first element
    //as the key to access the value
    //of the currently selected array element
    myDisplay = myChoices[myChoices[0]];

    I hope this helps!
    Don't stop playing...everybody starts by using too many movieclips..with time you will pass onto using too much code forgetting about the graphics.

    Altruism does not exist. Sustainability must be made profitable.

  3. #3
    WOW, thank you soooo much, I really appreciate your help! I'll have to start messin with arrays and, from what you've given me, I think I will have a good foot to start on. Thanks again!

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