It seems like my code in How To Create Flash Game Level Timer post is not as straightforward as I thought, because it was rejected as Tutorial on one of the directories, so I decided to give detailed explanation of it.
var count:Number = 0;
// this is a counter variable
var maxCount:Number = 75;
// maxCounter is duration of level in seconds
var intervalID:Number;
// Identification variable for repeating interval function
var timerStarted = false;
// variable which tells us if timer has started or not
var temp:Number;
// variable for shortening code writing
// next, we format and display seconds left
if(maxCount < 60) {
// if we have less then 60 seconds,
timeleft.text = "0 : "+maxCount;
// we display '0 minutes' in our Text Field 'timeleft' and concatenate maxCount seconds
} else {
// but if we have more than 60 seconds left
if((maxCount%60)<10) {
// and if we have to display seconds as one cipher number
timeleft.text = Math.floor((maxCount/60))+" : 0"+(maxCount%60);
// we display zero
} else {
// otherways,
timeleft.text = Math.floor((maxCount/60))+" : "+(maxCount%60);
// if we have two cipher number for seconds, we don't display zero
}
}
startlevel.onRelease = function() {
// when click is released on startlevel button
if(!(timerStarted)) {
// if timerStarted variable is false (we don't want to duplicate interval)
intervalID = setInterval(_root, "hronos", 1000);
// we set interval function 'hronos' to repeat once every second to act as counter
timerStarted = true;
// we declare that timer has started
this._alpha = 0;
// and we make invisible startLevel button.
// We chould also remove it from stage!
}
}
function hronos():Void {
// function hronos repeats every second
if(count < maxCount) {
// if counter is still less than maxCounter
count++;
// we increase counter by 1
temp = maxCount - count;
// temp variable holds seconds left until level end
// next piece of code is for formating and displaying purposes,
// same as above except instead maxCount we have temp variable.
if(temp < 60) {
if(temp < 10) {
timeleft.text = "0 : 0"+temp;
} else {
timeleft.text = "0 : "+temp;
}
} else {
if((temp%60)<10) {
timeleft.text = Math.floor((temp/60))+" : 0"+(temp%60);
} else {
timeleft.text = Math.floor((temp/60))+" : "+(temp%60);
}
}
} else {
// if counter is greater than maxCounter
clearInterval(intervalID);
// we clear our interval
timerStarted = false;
// we declare that timer is out of business
count = 0;
// we set counter to 0 so we can use it again
startlevel._alpha = 100;
// and we make startLevel button visible again
}
}
I hope this explanation is clear enough. If you have any questions, don't hesitate to ask.
*_*
31 October 2009
Level Timer code explained
words by
flanture
at
4:20 AM
2
comments
Links to this post
Labels: actionscript, AS2.0, code, examples, flash, programming, tutorials
23 October 2009
Protecting The Brand
There are few very strange things here. First, FlashDen is already registered trademark in Australia from August 2008 and therefor Envato should be protected by law, but they decided to change their name and url right away. Second, many websites use similar names like flashcomponents.net, flashloaded.com (to name a few) and a LOT more, but it seems like only Envato is contacted about this issue or at least I'm not aware of others. Idea that this is only first step and that all those websites will be contacted in near future is unlikely because it will be biggest technology suicide of all times!
Community responded and they responded hard. Just check 500+ comments on Envato forum. Some are furious, but many of readers are simply confused. Matthew Craig wrote:
"This is absolutely ridiculous… A community developed around a product to promote that product yet the product thinks it’s harmful to the product having a community promoting it? Makes no sense to me. It’s like mall-cops on a power trip thinking they are real cops."
and Mark wrote:
"I’m pretty annoyed that companies like Apple, and Adobe are so vicious with it’s legal protection of their trademarks. Sad really."
So, how about Adobe? What are their thoughts? Let's see what they say about proper use of the flash trademark:
"Trademarks help protect corporate and product identity, and the Flash® trademark is one of Adobe's most valuable trademarks. By following our guidelines, you can help Adobe protect the Flash brand name. The Flash trademark must never be used as a common verb, as a noun, or as a generic term for animation or video or to describe the output format. The Flash trademark should always be capitalized and should never be used in possessive form or as a slang term. It should be used as an adjective to describe the product and should never be used in abbreviated form."
It seems that Adobe is just trying to protect their brand. There is nothing wrong with it and I think there is no room for talks about 'evil Adobe' (at least not for now). Just imagine what would The Ronald do in same situation. They will sue everyone, right away, until extermination! And after dust comes down, they will sue some more! If you put The Ronald and other big aggressive brands together in same room, Adobe would be like nerd teenager trying to get attention, nothing more. For now.
*_*
words by
flanture
at
6:14 AM
0
comments
Links to this post
15 October 2009
How To Create Flash Game Level Timer


Here is the code:
var count:Number = 0;
var maxCount:Number = 75;
var intervalID:Number;
var timerStarted = false;
var temp:Number;
if(maxCount < 60) {
timeleft.text = "0 : "+maxCount;
} else {
if((maxCount%60)<10) {
timeleft.text = Math.floor((maxCount/60))+" : 0"+(maxCount%60);
} else {
timeleft.text = Math.floor((maxCount/60))+" : "+(maxCount%60);
}
}
startlevel.onRelease = function() {
if(!(timerStarted)) {
intervalID = setInterval(_root, "hronos", 1000);
timerStarted = true;
this._alpha = 0;
}
}
function hronos():Void {
if(count < maxCount) {
count++;
temp = maxCount - count;
if(temp < 60) {
if(temp < 10) {
timeleft.text = "0 : 0"+temp;
} else {
timeleft.text = "0 : "+temp;
}
} else {
if((temp%60)<10) {
timeleft.text = Math.floor((temp/60))+" : 0"+(temp%60);
} else {
timeleft.text = Math.floor((temp/60))+" : "+(temp%60);
}
}
} else {
clearInterval(intervalID);
timerStarted = false;
count = 0;
startlevel._alpha = 100;
}
}
*_*
words by
flanture
at
9:18 AM
1 comments
Links to this post
Labels: actionscript, AS2.0, code, downloads, examples, flash, fun, game development, games, programming, tutorials
07 October 2009
Free Microblog Flash Widget v1.0
Main text field is scrollable. Use up and down triangles on right to navigate current page. If page has long text then navigation is there to help. You can also expand main text filed by clicking on rectangle placed between navigation triangles. Clicking again on same rectangle will shrink text field to it's original size.
When user click on page title, Microblog takes him to original blog page or custom web location. Links are also stored inside XML file.
On the left side of the widget you can load preview images in few formats: JPEG, PNG, GIF and even SWF. Preview files should be 60 x 60 pixels. Microblog free Flash widget is resizable. Original size is 250 x 125 pixels.

Microblog movie clip contains link to this blog.
You are free to use Microblog Flash Widget in any way you desire as long you don't sell it, claim it's your work, modify or use source without author permission.
For custom solution and support please contact.
*_*
words by
flanture
at
10:04 AM
0
comments
Links to this post
Labels: actionscript, AS2.0, downloads, examples, flash, programming, web development, widgets
06 October 2009
Myth hacked: Flash on iPhone
Watch and weep!
*_*
words by
flanture
at
5:11 AM
0
comments
Links to this post
Labels: adobe, community, cs5, flash, iPhone, news, programming
05 October 2009
Flash Catalyst beta 2
Adobe has just released beta 2 of Flash Catalyst with lots of new stuff and improvement. Ryan Stewart gives you an introduction via his screencast.
*_*
words by
flanture
at
10:04 AM
1 comments
Links to this post






