A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: new to CS4 can't write code on button like M8

  1. #1
    Member
    Join Date
    Nov 2009
    Posts
    35

    new to CS4 can't write code on button like M8

    Hello I am new to CS4. I have been using Macromedia 8 and used to be able to write code on a button very easily. So click on the button and go the actions. But How do I do it in Cs4?

    Thank you in advance.

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    By default CS4 (and now CS5) files are written in Actionscript 3, which doesn't allow you to put code on buttons or clips, only on frames (or in external class files). If you change your Publish Settings to Actionscript 2, you can write code on buttons.

    If you want to do it the Actionscript 3 way, you place your button on the stage, give it an instance name in the Properties panel (let's say you call it myButton), and then in the same frame you add a listener and a function, a la:

    Code:
    myButton.addEventListener("click", doSomething);
    function doSomething(e) {
        //code here
    }
    Or, if you want to follow more strict coding standards:

    Code:
    myButton.addEventListener(MouseEvent.CLICK, doSomething);
    function doSomething(e:MouseEvent):void {
        //code here
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center