Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]

Subject: Re: FLASH: F5 better actionscripting - looping question
From: Gregg Caines
Date: Wed, 27 Dec 2000 21:55:36 GMT

Well... most of your problem is in the fact that you're not using
arrays. Your code is similar to the old Flash 4 way of doing
arrays, which is great for Flash 4, but Flash 5 has much better
array support.

You can do this:
name = new Array();
name[0] = "some name";
name[1] = "some other name";
etc, etc...

Instead of creating another array called var to hold var1 to var9, you
can just create a function to give the proper output like this:

function properoutput (inString) {
outputval = othervar1 + inString + othervar2 + "/n";
return outputval;

So anytime you want to use the var1 you had in your example, you
can just say properoutput(name[1]). If you're going to use that
function in a loop make it a 'for' loop. 'For' loops are much more
efficient for basic incrementation. If you really need to load the new
strings into an new array (like the var array in your example), then
use a 'for' loop for that too...

for(i = 0; i < 10; ++i) {
var[i] = properoutput(name[i]);
//or without the function call:
//var[i] = othervar1 + name[i] + othervar2 + "/n";

That's about all I can come up with....some of those tips will speed
up the processing, but most of them will just speed up the typing...

Gregg Caines
n e o m e t r i x systems inc.
gcainesatneometrixsystems [dot] com

> I have an "improvement" question. The following F5 actionscript works OK
> for me:
> var1 = otherVar1+name1+otherVar2+newline
> var2 = otherVar1+name2+otherVar2+newline
> var9 = otherVar1+name9+otherVar2+newline
> combinedVars = var1+var2+var3+var4+var5+var6+var7+var8+var9;
> However, I know this is not the most efficient way of doing this, and
> comming from Authorware, I know this can be done with a repeat loop. I
> just don't know how to say it in actionscript. Would it be something
> n=1;
> while (n<10) {
> var(n) = otherVar1+name(n)+otherVar2+newline;
> n++;
> }

flasher is generously supported by...
flashforward2000 and the Flash(tm) Film Festival
November 27-29, 2000, LONDON, National Film Theatre

Produced by United Digital Artists and lynda.com
-Sponsored by Macromedia, Adobe Systems and Apple Computer
-http://www.flashforward2000.com or UK tel. +44 (0870) 751 1526
Register before November 10 and save �200
http:// www.flashforward2000.com
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com

  FLASH: F5 better actionscripting - loopi, jmerrill

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]