• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

WARNING: Actions on button

New Here ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

Hi

I do not understand why I am getting this warning below

WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0.

All scripts on object instances will be ignored.

Can someone help?

mimi

TOPICS
ActionScript

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 07, 2009 Sep 07, 2009

You can still use pretty much any objects that you have ever used before, though that's not saying they haven't changed in some way. In AS3 to manage things like buttons and other interactions the primary code approach involves creating event listeners and event handler functions.  Here is a description of how you would approach coding a button, though the same could apply to a movieclip....

Let's say you create a button symbol.  Since it is a button, it is already a self animating object that wi

...

Votes

Translate

Translate
LEGEND ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

It is stating exactly what it intends.  You probably have an object selected with the Actions window open.

If you are familiar with AS21/AS2, those versions of actionscript permitted placing code on objects.  AS3 does not support that feature any longer, and requires that all code be in the timeline where it is clearly visible and easy to find (or in external as files).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

Many thanks

can we still use botton in AS3 ?

if yes, please show an example of code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

You can still use pretty much any objects that you have ever used before, though that's not saying they haven't changed in some way. In AS3 to manage things like buttons and other interactions the primary code approach involves creating event listeners and event handler functions.  Here is a description of how you would approach coding a button, though the same could apply to a movieclip....

Let's say you create a button symbol.  Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"


In AS3, to make a button work with code, you need to add an event listener and event handler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:


btn1.addEventListener(MouseEvent.CLICK, btn1Click);

The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:


function btn1Click(evt:MouseEvent):void {

   gotoAndPlay("site_section");

}


Here's some of what's involved there:


evt:MouseEvent - the event listeners throws an argument automatically which the function must be set up to receive.  In this case I have given that argument a variable name of evt, though I could have chosen anything.


:void - this defines the class of the value that the function will return.  In this case, the function does not return anything, so "void" is used.  If it did return a value, you would see a line containing "return xyz"; in the function (where xyz is not literal, it simply represents the variable or value being returned) and the :void would be rplaced with some other class such as :String, :int, Date, etc....


In AS3, in strict mode, it is necessary to identify the types/classes of the variables being created, which is why you see :String, :MouseEvent, etc... showing up everywhere.


Now, to create another button with a unique function for it, you could just drag another copy of it from the library, give it a unique name, say btn2, copy/paste the code from btn1 and replace "btn1" with "btn2" in that copied code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

yes you can still use buttons in AS 3.0. First you create the button, you give it an instance name (let's say myBtn) and then you add an event listener to it which listens to the to whatever you want to do with it. Here are a few examples:

myBtn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void

{

gotoAndPlay("frameLabel");

}

myBtn.addEventListener(MouseEvent.MOUSE_OVER, onOver);

function onOver(e:MouseEvent):void

{

TweenMax.to(myBtn, 1, {alpha: 0.5});

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

Many thanks guys for all these useful information

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2009 Sep 07, 2009

Copy link to clipboard

Copied

LATEST

You're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines