ActionScript 3.0 :: Comunication Between Two Classes?
Apr 30, 2009
im having some trouble comunicating between two diferent classes, what i usualy do is to setup a simple class with static object vars inside of it, and on one class with the function "function doSomething(){}" i say in its constructor StaticClass._Var1=this;
and then on every other class i just need to make StaticClass._Var1.doSomething().but this doesnt seem to be a good pratic doesnt it? how can i do this other way? i sometimes have to comunicate with more than 1 class so extending a class its not an option for me, i tried to writte this.dispatchEvent(new Event("event")); in one class and then his.addEventListener("event", appear); in another, but it doesnt go
have a film with two empty MCs, "mc1" and "mc2", each one load a external swf, so far so good. The film loaded in MC1 must control an especific MC ("mc3") from the film loaded in MC2, and here is the problem. Dont work. I can�t comunicate me with mc3. Here is the code that I use:
link1_mc.addEventListener(MouseEvent.CLICK,link1cl ickPlay); function link1clickPlay(event:MouseEvent):void { MovieClip(parent.parent.parent).mc2.mc3.alpha=0.5; }
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?
I have an actionscript project which uses visual symbols from an SWC. I have a CheckoutButton which has the following class associated with it (compiled into the SWC in Flash CS3).
I'm trying to import a class from a class that is located in another folder. How do you move up a directory? Using./ or ../ doesn't seem to work. Essentially I want to access a TweenLite Class but not from the document class. My class is at com/myName and the class I want to access is at com/TweenLite. import ../TweenLite doesn't work... I realize I could just copy and paste the entire Tweenlite folder again, but there's got to be a less duplicative way of doing this..
inheritance and building classes from other classes.
I have 3 classes: gfxRoomText - changeable colour gfxRomInter - changeable colour - interactive gfxRoomImg - interactive - only image / no colour
The first two incorporate the same text field and functions to change colour. The second and third incorporate another class to interactive with. What is the best way of creating these classes using inheritance and how?
I have to use many custom classes for a project, each class includes lots of elements(methods,properties) and I generally forget their names when coding. Is there any editor which I can enumarate the elements of my classes after pressing "." like Flash's built in classes?
I am new to classes and I am just starting to follow tutorials on how to assign classes and sub classes and I am wondering when you assign a base class or class to an object(Symbol e.g movieclip) through the properties, are all instances on the stage no matter how many and what they are named influenced and is the Stage/main timeline always the parent? and just one more question, is the parents objects display list all the movieclips that are used on the stage or all the instances on the stage?
I am doing an Actionscript 3.0 project which involves introspection. I am wondering if there is a way to get all the classes within a given package structure.
I've created a base class to house some basic functions I'd like to have across several movie clips in a game I'm making, however, when I link a custom class to the same movie clip I get the message; "The base class will not be used because the class specified is already defined and extends its own subclass. If you wish to use the base class, specify a class name in the Class field that will be auto-generated or enter the default base class 'flash.display.MovieClip' in the Base Class field." I removed the 'extends MovieClip' inside the Class but it still shows the message. Does this mean that I cannot use a custom class and a custom base class on a movie clip?
how to get a Class file up and going in Flash and that works fine but say I want to import other classes. I try "import testCass" above in my import statements section of my as file and that doesn't work. What do I have to do to get that to work?
been working with AS3 for a while. not and expert but not a beginner either. Somewhere in between I guess. One thing i haven't been able to get a grip of yet is using objects with AS3, so I'm doing some tutorials and experimenting to see if I can't become a better "programmer". So to start, i made a constructor, did a few traces- simple stuff. But now I'm trying to mess with a mc on the stage. in my fla file i have on the stage an instance of a movie clip of a box called "box_mc". I've exported is for actionscript with the class name of "box" and a baseclass of flash.display.MovieClip.
I use Flash professional CS5 and want to use Action Script3 mx.* classes but I cant find them in the "Action" tab in Flash. How can I get att the mx.* classes in the "Action"-tab?
I was learning Actionscript a while back but had to stop when I came across this question. I added a class using the blank class space on the property bar on the right. After making my first class and after saving it, I exited using the 'x' on next to the class' tab. Then..... I was confused because I didn't know how to add a another new class. Where can I add or how can I add a new class
How do you import 2 classes of the same name that exist in different packages? I thought that's what namespaces are used for but I can't get it to work right. My attempt for example:
Am I using namespaces incorrectly or is there a different way to do this without having to write out the entire package name anytime I want to use these classes?
I use multiple custom classes like tweenlite, csvparse, papervision and many more. The way I do is put them in one central location and edit Flash CS4 Actionscript 3.0 settings to include that location.The problem I face is even though I don't use all the classes in a project, flash CS4 compiles every single class that is in that central location eventually increasing my compile time by minutes.
i've got an AS3 project going out on cd. The project will consist of the SWF, several folder directories containing flvs, and folders containing ActionScript Classes used by the SWF. I'm not so much worried about protecting the FLV's or the Swf, but the cd could eventually be snagged by a rival company. is there a way to somewhat protect or encript external actionscript classes?
I tried to import a class in a .as file and I had strange behaviors that I cannot explain. First of, I tried to get work a senocular class by importing it locally his script in the same directory of my main .as class.
There was no error returned from the compiler saying not found but there was one telling my class is still undefined as when I try to make the class work. (possibly undefined method). So I did it with the old fashion I found in some demos, placing the .as file in a com/senocular/display/ folder:
I have a move that reads class files located in folder called 'src' and has been working once I changed the path to absolute. for some reason now my movie has decided not to work.
this is how I create the path:Go to porperties and click 'Edit' then clicking the AS3 'settings'. I then go to the 'Source path' tab and click 'browse folder' icon to the folder of the classes.having done all this my movie still does not work.
I am having some trouble trying to communicate a class with another class... Here's the simple explanation: I have a main fla that loads the class Kgame through properties.
I have a project that I want to import an external class (Caurina) I have the folder on my desktop and I'm trying to find out how to import and where in Flash do I do this. I got as far as looking for the folder in the publish settings tab (Mac)
I have tried to follow what info i could from the net, but i can't get it to work.Basically, what would appear to be a pretty cool tutorial which also lets you download the class files (i think that's what they're called), which you then import in the actionscript.The prob is that i have no idea where to save this file so that i can import it. I thought i had figured it out and tried to save it in FlashCS4>Common>FirstRun>Classes>mxI then created a sub directory called com which contained more subdirectories and then the .as file.WHen i try to import it using:import com.sub1.sub2.sub3.myNewClass;i get errors saying that the definition could not be found....
I'm new to as3 programming and I'm trying to communicate between two classes to get the player coordinates for a game from one class to another class. I tried using a getter and a setter and calling a class public function that returns the value.[code]...
In my application I often call to different web services, and because I don't want to hardcode urls to them in my code, I am passing urls to the services as flashvars.Currently I am doing it this way:
public var siteUrl:String; public var gameId:String; public function main():void[code]....
Where main is a function, which is called on application's creation complete event.This way I can call both variables from main file of the application but I want to access them from other files. (other as classes).So is there a way to create class with constants and init values there with flashvars so I can use them everywhere (after importing of course)