ForumsProgramming ForumFunctions & Buttons on Main Time Line

5 2882
Maaron
offline
Maaron
47 posts
Nomad

Hey everyone,

I've been messing around with ActionScript 2.0 and I came up with this code but it just won't work, I don't know how to make it work.

var myNumber:Number = 0;
Start_btn.onEnterFrame = function():void {
on (release) {
trace(myNumber = myNumber + 1)
}
}

Could you please explain to me why it isn't working an tell me how to make it work, thanks in advance.

P.S. Bear in mind I'm only a beginner.

  • 5 Replies
IQAndreas
offline
IQAndreas
299 posts
Peasant

I am not quite sure what the problem is as I am a beginner as well and still learning, but with my experience in VB.net, it looks to me like you have a function nested within a function.

I'm not sure if that is possible in AS 2.0, but that might be the problem.

I'll look into it more and get back to you.

dank
offline
dank
986 posts
Peasant

Instead of using an onEnterFrame function, just use the onRelease function.

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

A function actually says "do that" to the code, on release is not saying anything, it's stating something at random, so it won't execute what's inside

Like dank said, try this, you have to say "onRelease do that"

Start_btn.onRelease = function()
{
trace(myNumber = myNumber +1)
}
LonLonRanch
offline
LonLonRanch
172 posts
Nomad

Exactly as said as above. For clarification it is good to note that button instances have different methods and functions you can use from movieClips. For example, if Start_btn is on the instance of a button, you can not use onEnterFrame -because that method is only for movieClips.

So yes, use Start_btn.onRelease instead. But other than that your organization and code layout looks well done, nice!

Maaron
offline
Maaron
47 posts
Nomad

Thanks guys for all the help once again. I'll try what you guys have said now.

Showing 1-5 of 5