Interval Manager, Dev Kit

I vote for you to write a book
go 4 it !!!
respect for sharing stuff with community

From what I’ve heard, there’s nothing better for solidifying your own understanding of Actionscript than writing a book about it. Try e-mailing some other flash authors to get a real breakdown of what it requires. They’re really usually approachable and willing to help.

I’d be glad to read over anything you write (I have a degree in English where I focused on technical writing) to help out with clarity, structure, etc.

P.S.- Don’t forget to be funny.

I have spoken to a few people now, and it looks like this might actually happen. I’d really like to get your guys’ feedback, Take Care.

_Michael

Definitely write a book! That would be so sweet!

And, you’re really, really good. :thumb:

Aw nokrev… you’re going to make me tear up :slight_smile: Lol, thanks this means alot, seeing as I have alot of support from various forums, I think I’m going to approach this, full force.

_Michael

Book sounds awsome!

Sorry I am an idiot but I am curious as to when setting an interval comes in handy. Is it when you want certain things in a MC for instance to delay or accelerate or pause for different lengths?

setInterval allows you to call functions at a specific interval.

Let’s say for instance you wanted to say hello overy 1 second ( 1000 milliseconds)

You create a function called sayHello…


function sayHello()
{
   trace("Hello");
}

Then you want to create the interval. setInterval takes in a few parameters

The first is the path to the function. Since we are calling a function that is in the same places as the interval is set, the path is the this keyword. You then put the name of the function as a string. The third parameter is the number of milliseconds inbetween each call. And starting at the fourth parameter, all arguments are passed in order to the function you call.


var myInt = setInterval(this, "sayHello", 1000, "Michael");

function sayHello( name:String )
{
   trace("Hello " + name);
}

You can then clear an interval that is running using the clearInterval method.



var myInt = setInterval(this, "sayHello", 1000, "Michael");

function sayHello( name:String )
{
   trace("Hello " + name);
   clearInterval( myInt );
}

In this example your function is only called once, because it is cleared when the function is called.

I hope this shed some light.

Take Care.

_Michael

Ya sounds great write a book, I would write it on advanced actionscript, i’ll read over it too :stuck_out_tongue:

there is a lack of advanced AS books out there, most are geared towards beginners, so it may not be a bad idea actually. you seem to know a lot and like sharing the knowledge…

A friend of mine wrote a chapter for “Gaming Hacks” published by O’Reilly. I don’t think it made him rich, but it sure helped his resume.

Yeah, I definitly don’t plan on getting rich, but I’m sure that writing a book would solidify your resume. I like the idea of Advanced Actionscript. I’m going to try and gather a few ideas, I will post in here as they come to me.

@bombsledder I will definitly take you up on that offer.

Take Care.

_Michael

If you guys would like, start posting topics you’d like to read about.

thanks! Thats cool. Why do you think Flash’s Interval setting is primitive?

There are a number of reasons that I don’t care for it.

The main thing is management. setInterval returns an integer that represents it’s id. This id is what you pass to clearInterval when you’d like the interval removed. Now due to Flash’s nature of allowing code to be on different timelines, and just little scope oddities, you are not given one central location to manage your intervals.

If you set an interval on one timeline and then try to clear it from another, you have to be sure that your pointing to the interval id correctly. With this manager, or managers similar, you are given one place. All of the interval id’s are stored in an object under the name you provide. This lends itself alot to clarity, as you can identify a box fade interval as “boxFade”.

Another thing that this manager offers is a safer way of managing intervals. With this manager when you set an interval it’s id is automatically stored, and if you try to overwrite an interval that is currently going the old interval is removed first. This keeps you from allowing intervals to run wild, because once you lose the intervalID it’s very difficult to clear that interval.

I hope this made sense, take care.

_Michael

wow thanks Michael!

Another thing that I forgot to mention is that this Manager will free the memory used to store the intervalID, something that does not automatically happen with clearInterval… Take Care.

_Michael

On the other hand… if you happen to… I’ll take a few million. :wink:

of course…

Thanks :wink: