FORUMS: list search recent posts

Actionscripts not responding

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brian Bradley
Actionscripts not responding
on Dec 8, 2010 at 6:13:32 pm

I have a basic button I created in flash. It just changes color when the user rolls over it. It's not grouped or embedded inside a 2nd movie clip. When I select the button then click on the Actions Panel. I see a message in the center of the actions panel "Current selection cannot have actions applied to it."

Return to posts index

Brodd Nesset
Re: Actionscripts not responding
on Dec 9, 2010 at 1:48:42 pm

This is correct. It means you have set up your document to work in AS3 instead of AS2. Congratulations! I might say. Using AS3, you can't add script bits just about everywhere like you could.
Using AS3, there are three steps to make a button functional:

1. Give the button an instance name. The element the button is made of doesn't need to actually be of the button type; it can also be a MovieClip. The instance name must be unique for that frame or section, so no more 14 occurances of "button1" anymore.

2. Add an event listener. Now, these were actually available in AS2 as well, but now they are compulsory. Similar to all or most other programming/scripting languages like Java, javaScript, Python etc. The syntax is as follows:
mybutton.addEventListener(MouseEvent.CLICK, CallFunction);
This piece of script must be available in a frame where the button actually recides. I.e. if you have a button in frame 133, this line of scripting must recide there in the Timeline as well.

mybutton is your button's (or movieclip's) instance name. CallFunction is the name of the function (AKA 'method') to call / trigger.

3. Write the CallFunction. This is often placed in the first frame or so, together with all the other functions (scripts in one location is great!) - or even in an external script document. The basic syntax for this is:

function CallFunction(e:MouseEvent):void {
gotoAndPlay(10); //Add your stuff here; even call other functions etc.

It's a bit more typing than making one basic button work with AS2, but you'll get into it. It is far more concistent now, for one thing. Also, as you add more buttons, you actually save typing in AS3

Migrating from AS2 to AS3 is a long issue, although I'd argue that most arguments against it is myth-based, rumours and general resistance to change. Actually most of it is the same! gotoAndPlay("x") hasn't changed at all, and the general logic with variables etc. still applies. I can recommend AdctionScript 3.0 Quick Reference Guide published by O'Reilly. It's not thick, it's got some chapters on migration, and the rest is some really nice tips on common AS3 usage. Some really clever stuff there too.

Not everything that can be counted counts, and not everything that counts can be counted.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved