ForumsProgramming ForumSimple Adobe CS4 question :)

9 3636
Wyuen
offline
Wyuen
374 posts
Nomad

Okay, when I read about codes and programming actionscript onto a movieclip or whatever, Actionscript 2 allows you to actually put the script ON the object.

For example, if you wanted to move the character right, you'd click on the object FIRST and then place the codes right?

But I'm using Actionscript 3.0, and that isn't allowed since if its going to be a big project it'll be really hard to find specific codes.

So I googled or binged, and found that I'd have to click on the frame, and THEN place the code. But If I want to place a code on the object, how do I reference the code TOthe object?

Like what do I write? I'm really confused...

  • 9 Replies
gluesy
offline
gluesy
65 posts
Nomad

Do some research into Object Oriented Programming its one of the main advantages of as3.

I would read this to get started:
http://www.adobe.com/devnet/actionscript/articles/oop_as3.html;

Using OOP each movieclip has its own actionscript file where you can put your code.

Wyuen
offline
Wyuen
374 posts
Nomad

Yes i've read the articles on as3, I couldn't find the bit on what I was trying to find though.

mcname.addEventListener(MouseEvent.CLICK, clicked)
function clicked (lolz i forgot this part but close to or maybe MouseEvent:void){
MovieClip(parent).gotoAndPlay(3);



Thanks! But whats the CLICK, clicked part?
Hectichermit
offline
Hectichermit
1,828 posts
Bard

CLICK is what happens, the clicked is a function...tells the program to run the function clicked when you CLICK the Mouse on the mcname movieclip

Wyuen
offline
Wyuen
374 posts
Nomad

But if I want to remove the CLICK because I just want to refer that I'm typing the code that is related to the mcmovieclip, do I just delete the CLICK part?

manny6574
offline
manny6574
922 posts
Nomad

if you want the object to change when you do something you do this:

nameofmc.addEventListener(*put event type here eg. MouseEvent,TimerEvent, Keyboard Event*.*event goes here eg. CLICK, KEY_UP,ROLL_OUT*,*event handler function*)

then the event handler:
function eventhandlername(e:*whatever event type u used*):void{
reaction code goes here
}


so... you set up an event listener for the Movie Clip which will do the function specified when the event happens!

manny6574
offline
manny6574
922 posts
Nomad

oh, and if its a big project then don't make the same mistake as me. You don't really know the code, you ask other people, you mess around with the code they give you, you ask again. I did that and had to stop the project a month later.
But then I said to myself: 'Right, I just got learn the code!' and I did.
And now I'm making another project and didn't ask a single person!!

Wyuen
offline
Wyuen
374 posts
Nomad

haha yea its hard to learn the language but I'm trying

Showing 1-7 of 9