AS Coders
- Started
- Last post
- 16 Responses
- ian00
I guess I fancy myself as a decent AS coder but I could be deluding myself.
How might I clean this up:
http://ian.chemset.net/code.html…
it's for:
cheers.
- AMFA0
i dont understand what you're asking....
it works? or no?
are you just looking for a better way to do what you have already done?
- ian000
i guess my question is about form - good practices etc.
- AMFA0
In that case:
I would recommend taking your code out of the frames & fla file.
I like to use a Control class.
An AS2 class in a .as fileIn the first frame (and movie typically) I only have one or two lines of code:
_global.Control = new ControlClass()
in the constructor for the class, i intialize the stage, the objects and layout
also for XML i would create a separate class for that. currently i have written one that takes an xml file and imports it to an associative array.
that way i never have to rewrite any xml transfer. reusable over all my sites....
(continued)
- AMFA0
sometimes you cant separate the content completely (because of tweens, etc) but most of the methods are stored in the Control class.
So if i need to change sections, or load content, its always:
Control.changeSection("sectionna...
etc...
also, for my standard stuff like resizing clips, changing alpha, moving clips, i have predefined methods so i can call:
Control.Move(targetMC, x, y, moveType)
Control.Fade(targetMC,newAlpha)
and I use setIntervals to do all that...
- AMFA0
i dont know if im helping, im just running down some of my practices...
- ian000
no, it's helpful.
I'm always interested in how other people are doing things.
thanks for the feedback...
- AMFA0
thats cool....
For me, my FLA usually has only one frame (if no preloader required) or 3 if there is one...
- AMFA0
are you going to be at SXSW (youre still in austin?) in march?
im heading down there with a few of my designers.
- caseyc0
Here's a short list of things I noticed at first glance and how I deal with them. Note I mostly code is AS1 so these tips are geared to that.
1. Code on different frames/timelines
I keep everything external, I use .as files and have one clip in my lib that has export for as checked and contains all of my includes inbetween an #initclip #endinitclip block
2. XML Looping
I never use childNodes, a long time ago I learned this loop which is much much faster and leaner:
var child = anyxml.firstChild;
do {
// parse child
} while((child = child.nextSibling) != null);3. Code looping
Always use do, while, or for...in
loops, the i=0;l
- caseyc0
Son of a bitch, a lot of that got cut off and I am too tired to type it again. Arrgh. Sorry.
ps - AMFA, I was thinking about attending the interactive portion of SXSW, have you ever been?
- ian000
thanks for the tips.
i have yet to have the need to fully explore AS2. but then again, the flash work that i do comes and goes.
i don't know whether i'll still be in austin in March. If so i'll be checking out SXSW. In all likelyhood, i'll be living and working in NYC. dorp me an email when either of you are in town and we can get a drink,
- unfittoprint0
site structure > 3 files.
an index loader [+ intro] + main content.
php / AS 2.0 class/ v2 components centralized code for ALL web development> one library for all sites.
external library within each site with font symbols/common component instances / symbols. smaller > faster.
text, jpegs, movies, sounds should always be external, saved in a separate folder for easier site updating/development.AS2.0 will help you to faster detect bugs, develop your site's much faster, easier and much more complex.
- AMFA0
never been to sxsw but i am going this year to the interactive festival. got nominated for a few sites so we'll see.
i think i will be there sat-mon night
- mirola0
unfit, do you load your sounds in externally? i've never got a true loop when importing an mp3 because of the tiny bit of silence at the beginning.
- shaft0
*lurking bump
- rson0
I started to use classes to organize more eff.