Skip navigation
Currently Being Moderated

Question about AS3

Mar 29, 2012 6:53 PM

Hi guys,

 

 

I have a question hope someone can help me.

Well I have a couples of buttons with some effects inside them (motion tweens, labels, etc).

I know in AS2 we can actually set codes to an object like the button itself.

But how I can archive this using AS3? I mean what I need to do (because I can't set codes to the object in AS3) for make my buttons run the frames inside them?

 

For example in AS2 I can set the button (object) with this code and it will run the labels, etc. into it:

 

 

on (rollOver) {

gotoAndPlay ("go1");

}

 

on (rollOut) {

gotoAndPlay ("go2");

}

 

on (rollOver) {

gotoAndPlay ("go3");

}

 

 

on (rollOut) {

gotoAndPlay ("go4");

}

 

on (release) {

getURL ("http://www.anysite.net", _self);

}

 

 

 

Thanks in advance and sorry about my english.

 
Replies
  • Currently Being Moderated
    Mar 30, 2012 4:33 AM   in reply to Coo1On3

    For AS3, all coding is done either in frames or external class files.  Just about anything in AS3 involving interaction requires the use of event listeners.  What you should do for starters is look up the "addEventListener" method.  You are likely to find examples.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2012 6:58 AM   in reply to Coo1On3

    Ideally you should keep all code in one place,  it just makes life so much easier when you don't have to hunt down different code locations.  There is no rule that says you have to, but it is a good habit to try to get into (though some designs are easier for some people to manage with code scattered around the timeline).  The one place where most people choose when they code within the fla is frame 1 of the main timeline.

     

    So if you put that code into the main timeline, and you name your button "mybutton", then the only thing I can see that needs changing for your code is that you need to tareget the movieclip in your event handler functions...

     

    function manageMouseOver(event:MouseEvent):void{

      mybutton.gotoAndPlay ("go1");

    }

     

    function manageMouseOut(event:MouseEvent):void{

      mybutton.gotoAndPlay ("go2");

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2012 9:51 AM   in reply to Coo1On3

    That is not a correct answer.  You cannot tell a movieclip to gotoAndPlay() two different places at the same time.  Only the last one called will end up playing.

     

    (and you cannot award yourself points if that is what you wanted to do... you can only award points to others that respond to your posting)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2012 1:49 PM   in reply to Coo1On3

    There are no rules about marking your own entries as correct answers... it is perfectlyt legitimate to do when the answer is correct.  The only problem is yours was not correct, and by what you show now it remains incorrect.  But if you are happy with it as it is, I won't try to pursuade you otherwise.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points