715 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Had an item featured in an Envato Bundle
+7 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
  • Has referred 50+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 more
fisch79 says

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

230 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
theflashfactory says

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

715 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Had an item featured in an Envato Bundle
+7 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 100+ members
  • Has sold $10,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
lars019 says

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

691 posts
  • Has been part of the Envato Community for over 7 years
  • Has sold $5,000+ on Envato Market
  • Located in Canada
  • Has collected 10+ items on Envato Market
+2 more
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
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Had an item featured in an Envato Bundle
+7 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!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by