I've recently started development on my first proper AS3 project and I�ve hit a sort of brick wall with my knowledge of how to make AS3 classes do what I want. I could do this in AS2 no problem with referencing the stage, but now that only the document class has access I'm stuck.I have instances of a MC called activity. These sit inside a container MC that is the source of a scroll pane (that sits on the stage).
When I click a button inside the Activity MC I need to generate a new MC and set that as the content of another scroll pane on the stage. I�ve tried several things, even gotten the stage passed to the activity MC class but it can't then be used to addChild to items on the stage just reference then (much to my aggravation). And I can�t set an event listener for the new activity�s button when it�s created as it throws a static display object error of some sort.What methods can I use to pass information from a MC class back to the stage so i can call a function or just paste a MC onto the stage? I'm at my wits end after about 10 hours of exhausting everything the internet seems to have to offer on the subject.
I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code. What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.
I have a project that i'm working on, and in the project it's important that i have an object that i can create with actionscript that already has two arrays inside of it. To do this, i made the movieclip, i checked export for actionscript in the library, and in the custom class that corresponds to that object i made the arrays with the following code:
package { import flash.display.*; public class cont extends MovieClip {
I've been working my way towards better OOP design lately and I've come across a problem with accessing functions in other classes from my Main class. Here is the code:
They are listening for functions that are within the Player.as class, these functions control the dynamics/movement of the player itelf. But for some reason I'm getting a 1120 error(access of undefined property). Basically how do you listen/access for functions within a different class?
I want to access an object from a class in which it was not created in. I have a main class (A) in which I create and instantiate an object (of class B), from this class I can obviously do whatever I want with the object, no problem. The issue I'm having is another class (C) needs to access the object in question to change its x and y location values. Class C doesn't know what the instance of class B, created in class A, is; this doesn't surprise me, but I can't figure out how to allow class C to get access to what class A created.
I have 2 swfs, one is main and it loads other file "skin.swf". skin contains object of custom class SkinClass. I can access it from main swf, but when I try to cast that object, the result is null. This happens when I use absolute url, when I load skin from relative url, everything is ok.
I am having this issue were I can not access any variables from any other class![code]Now, from my other variables, that is what I do, I don't understand what I am doing wrong?
So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?
How do you access Library items from classes other than the document class?For example, if I create a movie clip in Flash and Export it for Actionscript with the name Foo, I can do this in the document class:
Code: Select allvar f = new Foo(); this.addChild(f);
And it appears on the stage, as it should. But I need to be able to create other instances of this object from other classes. If I use the same code above in SomeOtherClass.as, I get nothing on the stage, obviously because this class doesn't know about the Foo object in the library.
how to put actionscript classes into an MXML document? Lets say my class represents a movieclip, a rotating triangle for instance. How do i put that into a <mx:vbox> containter? I can do the AS work in a <mx:Script> tag, but how do i embed my class instance?
I have a document class which links to several classes, one of which adds a container onto the stage and loads external .swf's into it.Q: How do I access the various classes loaded in the document class from the external swf timeline?For instance, when you click a button in the loaded swf it changes the soundtrack from the soundtrack class. I have tried dispatchevent from the external swf timeline, but I still can't seem to get it to work. Is this supposed to work, or should I be doing something different?
I began with a class for a movie clip rollover function FigureRollOver. It works marvellously. Three things happen:
1) it loads XML from a file "mod1_fig1.xml" and uses another class, XMLMember, to retool the scoping of the XML so that I can get at it
2) an onload call inside of XMLMember calls the myOnLoad function and transfers the XML into an array.
3) so long as the array is finished building, rolling over a movie clip attaches a new movie clip with the rollover text in it.But I don't want all those functions in one because I need it to be more dynamic, starting with being able to load any old xml file instead of just "mod1_fig1.xml", plus it seems lik overbuilding to have all of that in one class, so I've separated out the loading of the XML and building of the array into its own class, FigureXMLLoader. FigureRollOver is then left to just attach the rollover with text in it, extracted from the array built by the new class.
Problem is, though the array builds inside FigureXMLLoader, I can't figure out how to make it available outside the class. I know that I'm constructing things in the wrong order, and that the array needs to be somehow built inside the class function to be available, but I can't figure out how to do that. A cruddy work-around is to put a function call at the end of the building of the array, which calls yet ANOTHER function on the main timeline of my .swf to put the array I've just built into a new variable.This works, but it's messy. It seems like I should be able to have one line of script in the .swf that generates an array on the main timeline (or just a public array) which I can then access from my FigureRollOver class:
var myRollOvers:Array = new FigureXMLLoader("mod1_fig1.xml");
Here is FigureXMLLoader (see comments in the code for more details) which obviously does not return an array as it is, because of all the working around I've had to do. Note the "testing" variable, which can be traced from the main timeline of the .swf, but I will get "not what I want" because of course the array hasn't been built yet, and never will be, inside of the declaration as it is. How do I get it in there so I can return an array?
i've got two classes and i'm not extending to MovieClip. I like to attach the mc in the constructor just because i'll be working with different MC's that have the same purpose.
however, im using private var loadedMC:Movieclip and now i've got another class that needs to be able to access the instance's variable.
for example, myClass.loadedMC , but this would mean having to make it public and I rather not go that route.
I'm trying to get a button to change color via a Custom class written in ActionScript. I have built and attached an example to show you all what I'm trying to achieve. The code works perfectly with a MovieClip, but when I try to apply it to a Button, it falls flat (can't even find the reference to the button it seems). On my stage are two objects:
1. A Movie Clip 2. A Button
These are both set to "Export for ActionScript", and have an attached class called 'ColorClass'. ColorClass is basically what does all the work (makes a Color object, and has set and get methods). I also have an action layer where all my other code is contained. I'm fairly new to ActionScript, but come from a Java background
Im just getting in to start using classes .. I have a very simple question:: So if I create a rollOver and rollOff class package - to change the alpha value of some buttons .. how do 'connect' them to my buttons?? .. if I was simply hard-coding them in I would:: myButton.addEventListener(MouseEvent.MOUSE_OVER,my Function); But this will be tedious with 10 buttons for the on and off states!
My problem is that I created my buttons on the stage and then grouped them together as a movieclip called navSat.Then I set the Linkage for navSat to NavSat.I am doing all my coding through AS3 outside of this. This is my code:
Importing the NavSat MovieClip
Quote:
function loadNavSat():void { var newNavSat:MovieClip = new NavSat(); addChild(newNavSat);
[code]....
When I run the swf now, my navigation system comes in and all the buttons are working (up, down, over, off states are working) It still links to nothing yet. The problem is when I try to add functionality to those buttons. I have tried about 5 days worth of variations around this type of code but cannot 'communicate' with the buttons within the movieclip. This is my code for the 1st button - contactBtn (linkage: ContactBtn):
Quote:
contactBtn.addEventListener(MouseEvent.MOUSE_DOWN, contactDown); function contactDown(event:MouseEvent):void {
I'm trying to organize a presentation using several movieclips as "scenes." The problem I have is related to buttons nestedwithin those mc's--I would like them not to be available until eachindividual mc begins, but if I don't include the buttons on thefirst frame of the mc timeline, the main timeline cannot accessthem (and throws me an error)
I've recently designed some menu buttons each one gets highlighted on mouse over and defaults back on mouse out. On Mouse click the button remains highlighted and when another button is clicked the current button goes back to its default state and the new button is now highightedI know this has been asked before, and I know how to do this using a timeline and having flags marking the 'start' 'end' and 'highlight' states on the timeline. My original code uses IF and gotoAndStop statements...But recently I've been getting into tween classes using as2 and would like to know how to achieve this effect using _alpha values within tween classes.To me it seems easier to do this purely with code, i.e _alpha is 0 then tween to 100 on rollover. On rollout it reverses, and on click the alpha immediately goes to 100 and stays at 100 until another button is pressed
Using Flash CS3 and AS3 to build a learning module that will load different layers of SWF files based on buttons on the main screen. Got this working with no problems. What I want to do is add buttons to provide learners some functionality, specifically a forward button, back button and a check box that will keep advancing automatically. I've done massive searches and so far nothing seems to work. Seems like what I am acccessing so far is the main layer, not the new layers as they are loaded. Below is what I have been trying with the back button; the foward button uses nextFrame and is Handler2. It isn't working. Not even sure how to start with the checkbox for auto advance.
I need to set properties of buttons on the main stage from the current class. How would I do this?
I have multiple buttons on my stage. Each representing a chapter in a movie (from frame x to frame y of the movie).
When I push one of them, the movie plays. When it gets to the end, it should continue to the next segment/chapter. This works, but now I need to highlight the current button, not let the button I pressed be highlighted forever..
I have loaded an external swf into loaderTopBanner. It works to manipulate that, but not the individual buttons within it. (e.g. btn_Home, btn_Info) loaderTopBanner.btn_Home.alpha = 0;
I need to disable some buttons in a movie in level0. I manage to do that. but the thing is i have some other buttons inside a movieclip and i can't disable them... what should i do? how can i acess the buttons inside the movieclip to disable them? the code i'm using for the buttons in level0 is:
on (release) { for (i=0; i<4; i++) { _level0["button"+i].enabled = false; }
and for acessing the buttons inside MyMovieClip...?
I'm working with an ActionScript Classes file for some MovieClip buttons to animate In and Out. Everything is working the way it should but I would like the button to stay indicated once clicked on and then animate out once a new button is selected. The way I set it up in the past isn't very efficient and the next project I'm working on is going to be a lot of buttons. Trying to learn something more efficient.
Here is the AS class code: class ButtonClass extends MovieClip { public function ButtonClass() { this.onRollOver = this.Over; this.onRollOut = this.Out; } private function Over() { this.gotoAndPlay("Over"); } private function Out() { this.gotoAndPlay("Out"); }}
And then for the MC button in the FLA: b1.btnMC.btnText.text = "PORTFOLIO"; b2.btnMC.btnText.text = "CONTACT";
I am trying to add multiple different versions of the same button to the stage and to be able to access them later on by assigning them an ID. The way I assumed this would be done is to have a class for the button where an internal static variable is defined so that the ID can be found in the next function. This does not seem to be working, as the ID is constantly showing as the last number given, so in this case 6.I assume that I am doing this wrong? Here is my code so you can better understand:
I had to create a menu using array and I had to animate it. With some great expertise from people, I've accomplished that. But now I have a question about OOP, because I'm trying to add functionality to the buttons to load swfs into my main movie. Even though I strictly follow tutorials and exercises, I can't figure out how to reference a variable made in one class to another. For instance, I have index.as, navbar.as, and menubutton.as. I assume I need to add a loader to my index.as. But I can't trace the loader in my other classes. I've been told to effectively accomplish this, it is best to use custom event dispatchers. But I'm lost on how to use them.
The examples I'll use don't do anything - they're classes without ANY members - no variables, methods, anything.
Let's say I extends Sprite and call it MySprite.
I save it in test.core
[code]...
Now I create another custom class called MyWindow that extends MySprite.
I save it in test.windows
[code]...
Then I create another class that extends MyWindows (the example I'll use is a document class - but that doesn't matter - I've tested using an instance too).
[code]...
Notice that I'm not even trying to instantiate the helper classes - just having them there throws the error.
If there is only a single helper class, everything runs fine.
Also note that - as far as I can tell - this only happens when extending one class from another package, then extending that class with more than one helper object.I'm pretty sure there's no namespace bumps or typographical errors, as this is a very pared-down version of the original application.
EDIT: seems the problem exists even without the crossing packages - even extending MySprite in the document class with multiple internal classes generates this error.
I am creating a library in AS3. Inside the library I make use of a bunch of classes/packages that need not be exposed to the end user of my lib. I want to only expose one of these classes.
I guess my questions are:
1) How are libraries commonly distributed in AS3?
2) Is there a .jar equivalent in AS3 that developers can include, but will only have access/knowledge of the classes I've declared as public?