Community

Functions & Buttons on Main Time Line

Posted Oct 11, '08 at 12:22am

Maaron

Maaron

45 posts

Iron - Serf

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.

Posted Oct 11, '08 at 10:36am

IqAndreas

IqAndreas

164 posts

Gold - Squire

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.

 

Posted Oct 11, '08 at 11:43am

dank

dank

777 posts

Iron - Lord

Moderator

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

 

Posted Oct 11, '08 at 6:34pm

Captain_J_Sheridan

Captain_J_Sheridan

143 posts

Gold - Serf

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)
}

 

Posted Oct 11, '08 at 6:41pm

LonLonRanch

LonLonRanch

151 posts

Gold - Squire

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!

 

Posted Oct 11, '08 at 8:58pm

Maaron

Maaron

45 posts

Iron - Serf

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

 
Reply to Functions & Buttons on Main Time Line

You must be logged in to post a reply!