A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: know enough to be dangerous...

  1. #1
    Say Hello to my little friend. pimpjacksmack's Avatar
    Join Date
    Apr 2002

    know enough to be dangerous...

    I can almost always find a way to get a function to work, but it is rarely in the most optimized fashion...

    I have a portfolio page with 8 boxes and a loadMovie function calling external JPGs to load into each box as well as a setVariable function calling a caption into a dynamic text box. The problem is, I have 8 boxes so I have to have 8 different instances of the same box and 8 different functions (1 for each instance). I know there has got to be an easier way...please help!

  2. #2

  3. #3
    Say Hello to my little friend. pimpjacksmack's Avatar
    Join Date
    Apr 2002
    Basically I have...

    loadMovie("thumbs/owl_40_small.jpg", "_root.mask_2.loader");
    this.mask_2.T_Name = "owl n vine";

    loadMovie("thumbs/revolution_35_small.jpg", "_root.mask_3.loader");
    this.mask_3.T_Name = "revolutionary";

    loadMovie("thumbs/swallow_30_small.jpg", "_root.mask_4.loader");
    this.mask_4.T_Name = "swallow";

    loadMovie("thumbs/water_50_small.jpg", "_root.mask_5.loader");
    this.mask_5.T_Name = "water pumps";

    loadMovie("thumbs/wolf_40_small.jpg", "_root.mask_6.loader");
    this.mask_6.T_Name = "wolf and swallow";

    loadMovie("thumbs/morning_50_small.jpg", "_root.mask_7.loader");
    this.mask_7.T_Name = "bright morning";

    2 commands for EACH and I was wondering if there was a cleaner way to consolidate them.
    Last edited by pimpjacksmack; 12-04-2007 at 11:34 AM.

  4. #4
    AS3 Mod
    Join Date
    Sep 2007
    Here is a more dynamic approach. Let me know if you have questions. I did not test it but should work for you
    PHP Code:
    var startNum:Number 2// Set this to the first number of your images sequence
    var maskArray:Array = ["owl n vine",
    "water pumps",
    "wolf and swallow"];

    imageArray:Array = ["thumbs/revolution_35_small.jpg",

    maskArray.length == imageArray.length) {
    startNummaskArray.lengthi++) {
    this["mask_"+i].T_Name maskArray[i];
    loadMovie(imageArray[i], _root["mask_"+i].loader);
    trace("ERROR: Array length does not match");

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