- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
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!
nice… you should have some more hummingbirds randomly flying in also..
i like how it changes the angle of the bird as it leans into the flower
nice bit of coding
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
Here’s the same file, instanced twice, with rays Of Light from dxc381 as background.
Actionscript is so cool 
I didn’t study the whole script, but one little tip use TimerEvent.TIMER instead of “timer” 
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.
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
@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!
