PDA

View Full Version : Loading Buttons and their Events through AS2.0


Denaes
11-03-2003, 11:07 PM
I want to use AS2 to load a button from my library, not a component button.

I also want to supply a mouse over, mouse leave and mouse up event.

Basically its going to be a navigation system. I have (currently) 4 buttons (I'm using balls).

These are headers. When you mouseOver on it, it gives a description in a dynamic text box. When you click on it, it moves the buttons below it down and reveals 3 miniversions of istelf which are also going to have a mouse over event, then a link to another frame in a movie clip.

When you click another header button, the first open node closes, then its children open up.

I'm doing this right now with flat up movie making right now, with buttons on a screen and using tweens to fuidly move them.

with just 4 Header Buttons, this is a LOT of work with all of the tweens.

Now, if I wanted to change to another style of button, add more, or do any customization, I'll have to start over again pretty much.

If I had a class to handle this, their moving fluidly, which buttons to grab from the Library, even their spacing, it would be SOO much better.

I'm not asking for the answer per se, but if someone has already answered this question, a hint at where I could find the post, tutorial, FLA file, etc would be greatly appreciated.

It seems, as a concept, a straightforward navigation tool. I just can't seem to find an example of it. The one I did find on this site was just like a HUGE amount of scripting along multiple clips and had almost no 'easy' customization methods.

farafiro
11-04-2003, 04:51 AM
I didn't understand you well, but I don't think what u wanna do is achievable??

Denaes
11-04-2003, 08:02 AM
So you can't load an existing button through actionscript or its event handler?

farafiro
11-04-2003, 08:32 AM
again, what do u mean by that??
do u mean load an external swf that has a button??
or attach it from the library??

Denaes
11-04-2003, 04:00 PM
Load Buttons from the library, or just create new instances of an existing button.

The point is to set up code that can handle a menu with 2 categories with 3 items each (2 parents with 3 children each) or even 10 categories with 50 items each.

Doing it by hand involves a LOT of copying and pasting, but only changing the destination frame on a click, and the text on a rollover.

Just adding one single item (or child) to a category would mean you'd have to redo the tween's for the animations, and there would have two be two animations per Category (parent), the opening and closing... unless you can just play it in reverse for a close.

I have it working nicely with 3 categories (button1) and between 2 and 6 items each (button2), but I realize that if I wanted to change the graphic, I'd have to start 100% over again, while I'd only need to change a line of code if it was scripted.

Even sticking with the same graphic, having to add buttons and redo the tweens could be VERY annoying.

I actually found what I may be looking for, for the AS2.0 event handler.

I found on www.UltraShock.com, a tutorial dealing mostly with flash forms, but it writes a program without a single line of code within the FLA file. All of the handlers for the componants are handled in the .AS files.

That sounds pretty promising, and seemed to be the harder of the two.

It really can't be very hard to get an instance from the library or just create another instances of an existing offstage button... I hope.

farafiro
11-05-2003, 03:54 AM
I hope this helps//make a button MC, linkage it in the lib as main_btn
for(i=0;i<3;i++){
_root.attachMovie("main_btn","chil"+i,i,{_x:10,_y:i*37})
// the 37 is the height of the button
}

Denaes
11-05-2003, 04:16 PM
//make a button MC, linkage it in the lib as main_btn
for(i=0;i<3;i++){
_root.attachMovie("main_btn","chil"+i,i,{_x:10,_y:i*37})
// the 37 is the height of the button
}

lemme dissect that to make sure I comprehend :)

It'll run through the loop 4 times (0 to 3)

"main_btn" is the name of the actual Movie (can it be a button, or do you have to create a movie clip that acts like a button? Or put a button in a movie clip?

"chil"+i this is the instance name (I hope)?

the i by itself I'm not sure what that is.

Then you're placing it, all along x = 10 and starting at 0 and placing them each 37 pixels below each other.

Thank you for the help!

I think the handling of events is done by a "Listener"? or am I mistaken? I've got to look into that some more.

Eric Echols
11-06-2003, 12:14 AM
Yes and No.

Basically, an event is in an internal Listener, whereby you are only supplying the object that will handle the event. While, were it a Listner, you could supply both, the event and the Object handling the event.

event ex:

myRadio.click(myHandler);

Listener ex:

myCustomRadio.addListener("onCheck", myHandler);

I hope I haven't just said something you already knew. If so, so offense intended.