Flasher Archive
[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]
| Subject: | RE: [flasher] RE: someone's dynamic menu system |
| From: | Paul Willoughby |
| Date: | Fri, 23 Mar 2001 12:14:55 -0000 |
Hi Andy,
> I am absolutley certain that it can be done far more
> elegantly using the
> String() object... but every time I look at string
> manipulation code I get a
> headache, so I haven't really got into that whole area yet.
> Ah well... they
> say that identifying an area of weakness is the first step to
> eliminating
> it. Ho hum.
That's a good way to go. If you had your variable as a string like:
myMenu = this,is,the,most,complicated,menu,ever
You can convert this to a string object and then create an array using
string.split(). Heres some pseudo-code:
myString = new String(myMenu)
myMenuArray = myString.split(",")
Then all the elements of your menu are easy to access with myMenuArray[x],
no need for any substring :)
You can also access properties like myMenuArray.length which can help you
build the visual menu because you can find out dynamically how many elements
there are. And you can add/remove elements on the fly with.pop and .push
etc.
> I'd be interested as to whether anyone feels there are pros
> and cons with
> using duplicateMovieClip as against attachMovieClip. Memory
> usage? file
> size? speed????
attachMovieClip is really useful because it allows you to dictate the
position in the movie hierachy of the new clip. In Flash 4 you only had
duplicate which meant that if you wanted to duplicate _level0.myMC into
_level58.xMc.yMc, you'd have to write the duplication code in
level2.xMc.yMc. 'attach' allows you to centralise all your duplication code,
v.useful with large projects.
The other problem with 'duplicate' of course is that instances of the movie
clips need to be on the stage, so you have to make sure they're kept out of
the viewable area, and if they contain code that you want the duplicates to
respond to but not the original you have to write an additional test. Really
I'd only use 'duplicate' if the instance is already on the stage (like a
drag n drop shopping basket), otherwise 'attach' is a lot more durable.
I doubt there is much difference in terms of file size, speed or cpu
crunching between the two methods (never seen any tests for this though),
but picking the right method for what you want to achieve will allow you to
write less verbose, better organised code, which is nice :)
paul
[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]

