OOP helping hand?

Hello,

My background is more art/design/photography etc than programming.

I learned programming in Flash MX, and recently got back into flash with Flash 8.

So basically, whereas OOP might be second nature to many of you, it really means nothing to me :smiley:

I have tried and failed to convert some of my code into AS2 classes.

So I would really appreciate it if one of ye OOP faithfuls here at kirupa could do exactly that?

This is a somewhat simple function comprising of 2 elements, a flower whip that gets sort of sucked towards a large vortex flower. Itā€™s not basic, but itā€™s not mega complex either.

If I post the FLA, would you be able to turn it into AS2 classes and post it back?

If I could see how the code would be turned into classes, it would help me a lot, Iā€™d be able to learn how itā€™s done.
[URL=ā€œhttp://rumblesushi.com/kiru/flowerpower.htmlā€]
Cheers.

peeking at your file nowā€¦ man, when and how did I learn class/oop - Iā€™ve been working on flash day-in day-out for about 8+ years, and I started learning oop in as1 probably 6 years ago - there were hacky ways to actually create class files in as1 - learned from co-workers. Then tons and tons of downloading examples and reading books. Iā€™m a bit miffed that I never took an actionscript class and struggled a lot to learn, but I also know of people that have taken several classes and they didnā€™t learn that much. But with that all said - I just worked on a project for an agency where I felt like I knew nothing at all about OOP and design patterns - it really threw me off working with developers of that scale. Iā€™m from a creative background as well - so, I think its inevitable that my mind wonā€™t ever work like a software engineers :wink:

you code appears really organized and all very solid - it runs great. Its just in 3 places correct? on _root then within the flower and within the small flower correct? Iā€™ve gotta take off, but think I can convert later today.

EDIT: one thing to mention - you have a number of onEnterFrames running, onEnterFrame is an awesome tool for any animation, but it really starts to tax the player if you have a number of them running at once. There are no real shortcuts to this, but just be weary of it - I may set it up so that there is a master class that runs an onEnterFrame and tells all its ā€œlistenersā€ what to do, itā€™ll be a lot of code to execute within that one oef, but it may improve performance if you add more content or other interactive elements.

Creatify, thanks a lot for this, youā€™ll be doing me a real favour, this is how Iā€™ll learn best, by example of my own code.

Youā€™re right, the code is just in 3 places. The random function on the root timeline, the timeline of the small flower, and then finally the little rotation onenterframe in the big flowerā€™s timeline.

Indeed, I usually try my best to have as little as possible, and I always make sure to delete onEnterFrames whenever possible. This code I did a while ago too.

With all the code I write, I am constantly exporting it and monitoring my CPU usage, to try and optimise it as much as possible for people with crap computers.

By the way, I still havenā€™t explored ā€œlistenersā€ at all yet, only for the stage, I still just always work with onEnterFrames. Itā€™ll be interesting to see what you do with classes, and if you can cut down the enterframes.

Cheers,
Joe

By the way, I also setup a couple of thigns using the prototype structure in Flash MX, but it seemed pointless to me and a bit of a faff, it didnā€™t seem to have any advantages to me, so I stopped :smiley:

Also, I read in Senocularā€™s AS2/OOP article that AS2 gets compiled into AS1. Thatā€™s very odd :slight_smile:

@ everyone I donā€™t see the difference between creating a reuseable function and a class fileā€¦

i find classes confusing as they are slightly different than standard as convention, and I struggle with that :stuck_out_tongue_winking_eye:

@randomagain
(self proclaimed ā€œRegistered Spamophileā€ based on your ā€˜User Titleā€™)?

Did you even read this thread (see this post) ? Better yet what does your post add to this thread ? Why do you keep posting such posts throughout the forums ?

(I forgot your the one that wants to close down the Flash 8 forum). :puzzled:

?? Spamophile ā€“ seems like.

rumblesushi - its going to take a little longer for me to class-ify this, Iā€™m going to tackle it this weekend - stay tunedā€¦

Thatā€™s fine, whenever you have the time, youā€™re doing me a favour.

I was going to upload something much simpler, just 1 simple function, but then I thought thatā€™s pointless, as thatā€™s the sort of thing I would be able to get working as a class :slight_smile:

Itā€™s more involved stuff comprising of several elements that I have tried and failed to convert to classes.

BTW creatify - when you said you worked with some hardcore devs, and you realised your mind didnā€™t work in the same way as these hardcore devs, could you give me an example?

Iā€™ve only ever worked with 1 person in Flash, and he was from a creative background, not a software engineer type.

coming from a creative background - I get caught up in (and think all creatives do) things like :
ā€œI need to adjust that text, the leading is off, I need to spend time adjusting that graphic, I can really make this item perfect by adjusting a ton of small mc properties in codeā€ etc etc etc.

So, by creative nature, there is time spent worrying or getting distracted with non-functionality issues throughout the development process. These interjections effect the overall architecture of the application, functionality, scalability, etc. For true developers, the graphic items are usually just icing that isnā€™t touched until the architecture and functionality are in place. Or, they just leave all that up to someone else to do. With where as3 is at, its now more difficult to be the creative person and the developer, like something has to give if that is the case; time, effeciency, technique, graphic refinement, scalability, etc. Luckily, I think a lot of people can and do manage playing both rolls. But, the minute youā€™re not as efficient as the other group, and the client sees the cost difference, or the lack of scalabily - thats really the core of the matter.

Good point, I completely agree. I am certainly guilty of that myself, spending a LOT of time tinkering, and adjusting positioning, getting just the right shade of grey etc :smiley:

Where as people with more of a computer science/engineering background, itā€™s ALL about functionality.

For example, when you see a highly impressive physics engine being developed by a hardcore dev, itā€™s often the most basic of lines and sprites being used, absolutely no attention to aesthetics at all.

Flash devs who can combine great artistic talent with incredible programming skills are certainly a rare breed.

Were you influenced at all, by their functionality first approach?

And when you say itā€™s harder to do both with AS3, are you implying itā€™s simply harder to learn, and the people to make the most of it are people with development backgrounds?

Take a peek at the attached zip. Yeah, AS3 is more complicated in that it works best and makes most sense in OOP - however, if youā€™re not used to OOP, it can be tricky. There are many great things about AS3, its amazing what is available compared to AS2, but its more strict so its, IMO, harder just to pick up if youā€™re new to flash and just start playing with flash. AS2 and AS1 are very very loose, you can get away with a lot of improper techniques - this makes it easy to play with, but makes it even easier to form bad programming habits - AS3 helps a lot with this.

Iā€™m just checking it out now, it works :smiley: Youā€™re the man, thanks again Creatify.

Iā€™m going to have a good look now to see how the mechanics of the whole thing.

Where are you from by the way?