Skip to main content
April 20, 2008
Question

Problem Attaching a Link to Button

  • April 20, 2008
  • 1 reply
  • 261 views
This question may sound stupid, but I'm no pro at Flash. Well, I'm basically trying to attach a link to a button, but it keeps on telling me that it cannot apply actions to the selected object. Here's the whole process of me creating a button, and trying to attach a link to it...

1 - I randomly draw a rectangle with the rectangle tool, and convert it to a button.
2 - I click on the rectangle, and go to the Actions panel.
3 - I get "Current selection cannot have actions applied to it".

I am using ActionScript 3.0.

I would appreciate any help. Thanks.
This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 20, 2008
In AS3 you have to use event listeners to get buttons to function, unlike earlier versions that allowed coding directly onto a button instance.

An event listener assigned to an object is associated with a function.

The code is applied in the timeline frames where the button exists (not necessarily the same layer... normally not).

Here's the basic generic coding:

function doThisFunction(event:MouseEvent):void {
// whatever you want the button event to produce
}

buttonName.addEventListener(MouseEvent.CLICK, doThisFunction);

There are other MouseEvent types such as ROLL_OVER, ROLL_OUT, etc (all caps)... the Flash help file should help you out there.