first off have you ever successfully used an external AS class? because you don't have a document class and i can't find any place where you are importing a class and calling it..............do i need to go over the basic structure of an OOP program?
This is my first time using a AS Class. In my library I had the classes linked to the different movie clips. I a pretty new to flash and Ive been trying to learn AS3 but I haven't done many things in flash. Going over the basics might be helpful.
here is structure .....*.fla>>>>>>>main/doucmentclass main.as>>>>>>>>>other as files are always called from main.as this gives us a central point to manipulate stage objects and connect classes togeather here we can send variables to other classes,call classes set properties to objects on stage tell the stage that methoss from the classes have used addChild and need to be added to the stage do numerous other things(main)........our fla file has zero code in it and its just used for stage Objects such as background buttons and images it may even be void of all objects and code if you choose to build objects using actionscript only.............I'll build you a main class to get you started after that its up to you.
here is the demo file it needs stuff added to stage and refences to objects specified in the extrenal as files just remember when you want to access something on stage use main1.instance_name such as main1.btn0.addEventListener(ButtonEvent.CLICK,butt onhandler,false,0,true);
Im meaning, what was wrong with what I had? (Im not saying anything wasn't) It was working and I had the classes linked to the Movie Clips in the library. I just wasn't sure how to get the movie clips in the drop downs to play when rolled over.
what i mean by dirty/non-flexible is a coder using bad coding practices and creating a coding environment that will have horrible future problems. Code the way i showed you and you will have a robust application with far less limitations for your imagination
What was I doing that was bad coding practices? I'm not trying to be stupid I'm just trying to learn from my mistakes. Why do I need to have my main AS in a as file if I can put it in the first frame? Why do I nee to import the other classes for when I have them linked to the buttons using the class? Are you saying I should have all my AS in classes? What are the class variables for in main.as? Your notes in the as files just confuse me even more. I know you probably think I'm really dumb but Ive never learned well by reading I'm a person that learns faster by watching.
the main.as file is known as the document class everything on the stage is available from this class and you can pass variables/instance names between the classes and classes can have access to the stage by tying it to the buttons you only have 1 instance available instead of the entire stage......the class variables in main.as make refrences to your classes avaiable in all functions in the main.as/document class.....if you want to call a function that resides in a class from another class you put classvariablename.thefunc(); and it will call it from main.....or you can call it from a class other than main with
main1.classvariablename.thefunc(); I hope this demonstrates the flexibility that main class creates.
So how would I get all the buttons to use the same class and roll over function? The AS in main.as, do I put that in the flash file? Importing it to main.as makes it available for the rest of the stage correct... Could you explain more of what the comments you put in the AS means? If coding this way is better I have to have more explanations, I dont understand any of it, yet at least. I want to learn how to code AS right the first time so I wont have to go back and fix my mistakes. I just am confused......
all buttons are available to main.as if you want to access a button from a class file you have to have refrence to main.as hence you pass "this" to the class.
ask another question i'll give you bits and pieaces.
you are starting to understand.....but main.as is external from .fla it is connected to the fla by the document class setting and yes by importing other classes into main.as makes it available to the stage its a two way connection the stage can access stuff in the class but for the class to access stuff on the stage you need a refrence to the stage which is where
PHP Code:
this and main0 variable comes into play
you have a handle on your thinking though we are getting there.
you can't have any code in the fla if you use a document class......the reason it is like this is a question for the adboe developers the best i can do is say thats how it is......I mean we are talking OOP programming here.