715 posts
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Sold between 50 000 and 100 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Has been a member for 5-6 years
  • Beta Tester
+3 more
majd_abdul says

Hello people, I’ve been learning AS3 for the last couple of weeks, and I’ve made a script for my Hummungbird.

My goal was to give it some sort of natural behavior. Its functions are simple,pick one of the flowers at random and go to it for a while, then move on to another flower.

That’s what I managed to do so far: http://rapidshare.com/files/137405812/HummingBird25.swf

Here’s the script: http://pastie.org/253353

It’s very messy and not really in accordance with AS3 spirit. But I wanted to do something with what I learned so far. And I wanted some critique along the way.

So, I’m ready for any comments. Bombs away!

744 posts
  • Sold between 5 000 and 10 000 dollars
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 50 and 99 users
  • Bought between 10 and 49 items
  • United States
fisch79 says

nice… you should have some more hummingbirds randomly flying in also..

230 posts
  • Beta Tester
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • United Kingdom
theflashfactory says

i like how it changes the angle of the bird as it leans into the flower :) nice bit of coding

715 posts
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Sold between 50 000 and 100 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Has been a member for 5-6 years
  • Beta Tester
+3 more
majd_abdul says

Here’s the same file, instanced twice, with rays Of Light from dxc381 as background.

Actionscript is so cool :D

152 posts
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Referred between 100 and 199 users
  • Sold between 10 000 and 50 000 dollars
lars019 says

I didn’t study the whole script, but one little tip use TimerEvent.TIMER instead of “timer” ;)

691 posts
  • Bought between 10 and 49 items
  • Canada
  • Exclusive Author
  • Has been a member for 7-8 years
  • Sold between 5 000 and 10 000 dollars
geoken says

You should get yourself acquainted with arrays, they make life a lot easier.

For example, birdTarget is currently ~50 lines of code. If you put the 4 flowers into an array called fArray (for example) the code could look like this.

birdTarget():void{

for(var i:uint = 0; i<fArray.length; i++){
     fArray[i].alpha = 0
}
fArray[_nextTarget].alpha = 1;
_prevTargetX = _nextTargetX;
_prevTargetY = _nextTargetY;
_nextTargetX = fArray[_nextTarget].x;
_nextTargetY = fArray[_nextTarget].y;
_birdRotation = fArray[_nextTarget].rotation;
}

The basic idea is that once you can reference an object with a number, you can wright more dynamic functions and avoid manual recursion.

715 posts
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Sold between 50 000 and 100 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Has been a member for 5-6 years
  • Beta Tester
+3 more
majd_abdul says

@lars019: I used “timer” based on some tutorial from kirupa I think. I even left it’s name intact timerExample() :). What’s the difference between that and TimerEvent.TIMER?

@geoken: I’m starting with arrays just now. I really had trouble keeping track of my objects with switch and conditional statements.

thanks for the advice, people!

by
by
by
by
by
by