ActionScript 2.0 :: Referring To Library Objects Via Classes?
Feb 26, 2007
I've been heavily mired in 3D recently, and decided to pay a visit back to good ole Flash.
My problem is this. I'm extending the MovieClipLoader class to create a Preloader Class (yes I'm sure it's been done fifty billion times but). I'm trying to refer to a symbol in a common library, the preloader symbol itself.
baseClip is a MovieClip object which takes a MovieClip passed to the constructor of the class in the FLA. (say a container movieclip which has a target clip preloaded into it) The class does load the target clip into the baseClip, but doesn't show the preloader, which makes me think I'm not referring to it properly.
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 a simple question regarding the objects that are on stage. If you make a symbol in the Flash editor, export it for actionscript and put it on the stage, how can you refer to it in an external .as file which contains the document class? I tried using getChildAt() but that returns a displayobject, and I want to modify properties of that instance of the class of that symbol.
I need this because I am trying to make a scrollpane that adapts it's size to the screen resolution, and it's source is a MovieClip that isn't on stage but in the library. I also want the source to adapt it's width and height to the screen resolution. Is this possible? For this to work I need to refer to that source MovieClip in my as3 file, and I can't figure out how to do that...(in this situation it isn't even on stage but I guess I could make it invisible and put it on the stage if nessecary)
I'm creating mc's during runtime like this: for (var i:Number = 1; i <= pictures; i++) { this.attachMovie("box_mc", "box" + i+ "_mc", this.getNextHighestDepth()) }
So, if pictures is 5, then we end up with 5 boxes, box1_mc, box2_mc, box3_mc and so on. But I can't work out an easy way to refer to them later on. For example, say someone presses a button and I want to move all of them - how can I set their _x value in a loop? For example, if I wanted to move all of them 100 pixels, then this wouldn't work: for (var i:Number = 1; i <= pictures; i++) { "box"+i+"_mc"._x = "box"+i+"_mc"._x - 100; }
Using AS3, I was wondering how to control one object, a ball, while another ball bounces around. I'm modifying code from "Foundation ActionScript 3.0 Animation" by Keith Peters.
I'm pretty new so I'm probably making some obvious mistakes here. First of all I thought I could refer to the balls as ball[0] and ball[1] since they are in an array called ball. Is this correct?
I've created a carousel class which takes one parameter, an array of menu item names, these will then be displayed on the carousel. I've then created two movieclips for the left and right controls, added them to the library and given them classes of their own.Within the carousel class I instantiate instances of the two control classes which then enables me to add event listeners for rollover and rollout.
What I'd like to know is, is this the best way to do this short of creating the controls using pure actionscript?I'd like to not have to add the class properties for the left and right controls and have a situation where I could just give them the right name and they would work or maybe pass them in as parameters and use them that way.
I'm having some doubts about how to access some features of embedded files and loaded.
For example, I created a .fla and added a symbol to your library - a MovieClip with name and class circle. Then convert the .fla to .swf, thus becoming test.swf.[code]...
I have just started my first project using AS3.0 and Flash 9 this week.I feel like I know AS3.0 from my flex experience very well, but it is downscaled for Flash 9. Anyway I have looked for this issue in the forums and maybe I am just missing something.I have a class we'll call MyClass which extends Sprite. I have several methods in there that update things like rotation and position based on events it is listening for via the model. I even have a trace statement in the constructor for testing.
Now maybe this is just stupidly obvious but when ever I set a library element to link with the class (i.e. linkage = MyClass), all my script fails to work. If I remove that linkage and work from a purely data perspective it works as expected.I have the project settings to Flash 9 and AS3.0 so that shouldn't be an issue.
The one thing that was never covered (that I read) was how to set up your library. As a result, I have been guilty of starting a project folder and copy/pasting all of the classes I need into each project folder. (As a result I have like 30 copies of TweenLite on my PC). I have done some searching, but the topic seems elusive... I have also read where most people use a reverse web address format (e.g., "com.site.page"). So my questions: Is there a standard way of setting up a library for your classes?WHERE does the "com" folder live on the directory (ex: c:com, or c:Adobecom, etc).How do YOU have your library set up?
I was wondering if anyone knew how to create a .swc library file that could be used in Flash or Flex?I want to compile a custom package of classes into a .swc for use and download,
I am starting to create classes instead of using the timeline and I am learning a lot more even if mistakes happen more often. However I have a question about linkage & library. For example let say that I have a ball pic called Ball1.mpg. I copy and past that Ball1.mpg in my folder where the Fla file is as well as the as file. If I want to utilize this Ball1.mpg in my code using Flash do I absolutely need to import into my library and link it and export using linkage? Or can I use the object Ball.1mpg just using actionscript. Of course that implies that I would use an actionscript class not the timeline.
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.
1. I've got a Main Document class, that loads external swf each with its own document class (they are pages and pieces of the site).
2. The Main class makes use of some movieclip simply instantiated from the GUI library. It all goes fine.
3. The external swf have references to the Main class, and here start problems: when I compile them, I get an error for every library mclip used by Main. See the attachment. A simple trace(Main) is enough to start getting all that errors.
A partial solution is to uncheck Strict Mode in publish settings
What I want to do is compile an .fla with nothing on the stage but several of the movieclips are set to export on first frame in the properties linkage manager. When the .swf runs, I want to loop through and get the names of all the exported assets so I can place them in an array and manipulate them later.
I want to turn the code over to the art team where all they have to do is attach my .as file for the document class. I will not know what they name their movieclips, yet they are instructed to name them alphabetically according to what order they should appear. (My code is a sort of self contained slide show).
I have a series of large fla files that were being published into swc's and then used directly in an flash project. Probably a total of 1000+ objects. As the number grows the final compiled swf is getting quite large so I want to download individual swf's of each object only as needed. I then need to be able to access and clone the object via classname from the final AS project.
The issue is the only way I have found to export each one is to 1) copy and paste it into a new fla file 2) double click to 'edit' it to force it included, 3) reset the linkage (class) name since it was wiped, 4) publish (i.e. file->publish) and name this swf. This will take quite a while for 1000+ of these.
While you can right-click on each item in the library to save it as a swf, it appears NOT to include the classname etc, just the item. Once I download this, I cannot clone to use it more then once without downloading it again which is unacceptable.
Is there a faster/better way to generate these swf's?
(I did look into xfl briefly but it looks like writing a script to do this given some of the unknowns there will take longer then just doing it by hand.)
working a project that has 9 swf.a lot of the swf are using the same classes like papervison and tweenlite.is there a way to store classes like papervison in a share library?
Im working on a App that is using a external swf as a container for some graphical assets. An asset is a movieClip symbol with a class name attached to it. for example ASSET_1. I load the swf with the Loader class into the app. Its working fine I can also access ASSET_1 with this technic:
//--- inside onLoaded var ASSET_1:Class = event.target.applicationDomain.getDefinition("ASSE T_1") as Class; var asset:MovieClip = new ASSET_1() as MovieClip; addChild(asset);
my problem start when im loading a second swf and than i try to access "ASSET_1" again, and the class doesn't update itself, the content is the same as in the firs one.
I have several library classes that I am loading from swfs external to my main swf. These swfs all use the native tween class (import not extend). This means that I have the tween class creating bulk several times over (as well as the extra bulk for having to load a swf rather than having the class internal).Is there a way that I could make the tween class accessible at runtime to the loaded swfs without having it create the same extra bulk in all of the loaded swfs?the only solution that I can think of is to create yet another swf with the tween class as a library object, that would be loaded at run time by all the other loaded swfs.
My workflow usually goes like this: i create a symbol in Flash IDE with textfields, containers, etc. Then I select "export for actionscript" and type in the classname (automatic declaration of stage instances, of course, is off). Then i create a corresponding classfile in FDT and declare all this textfields and other objects that are in my symbol. This is pretty routine and boring process that takes a lot of time.
Is there a way to automate it? Maybe some plugin for flash IDE that will automatically create a class file based on symbol exported for AS?
Update: So, following the answer Pavel fljŨt provided, i wrote my own command to accomplish this task.[URL]..
can you declare multiple classes and then register each movieclip from the library to a different class? It isnt working for me.I created two different classes and created two entire different movieClips and registered each movie clips to a different class.However, I can only use on movieClip at a time, when I use the duplicateMovieClip... command to create copies of the movieclip, i find that only those movieclips, whose class i declared first, appear on stage.
I have 2 classes Main.as and RedPawn.as (yes, in the same folder).I am wanting to check if a child exists on a movie clip in Main.as through RedPawn.as.This is within a for loop since I am checking 24 possible values for _dest until I find a match.This simplified code example would be in the RedPawn class:
Code: _dest = 'example_mc'; // example_mc is pulled from an array if ( MovieClip(root)._dest.numChildren < 2 ) { // do stuff; }
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've got a problem targeting objects is AS2 classes. In a class I have a multi-dimensional array with paths to some mc's in the main timeline (caminho['mc']). I need to reference them via method in a class, so i use something like this:
This question stems from this question that I asked yesterday.I've followed Theo's advice and created a .swc with all the common classes and added the .swc as an external library to my module .swf. This all seems to have worked smoothly--I don't get TypeErrors and my classes are all present in the catalog.xml of the .swc file when I unzip it--but now I've encountered a new problem: when I try to link a symbol in the module .fla's library to a base class from my .swc rsl, it says the base class definition can't be found in the classpath. The whole reason I want to use rsls is so I can do this,If I now include the project's source path or the .swc in the normal (not external) library path, will that cancel the sharing benefits of the rsl, or will the compiler still know not to compile the shared classes into the module .swf?
I have an array of ingredients for soup as strings. These ingredients are also movieclips in my library, all linked with an identifier. I want to add the movieclips to the stage dynamically.
I tried getDefinitionByName but I keep getting an error that the variable "appel" (veg[0] in this case) is undefined. And basically, I only have a general idea what I'm doing here, so I would be grateful if someone could explain it to me or link me to a helpful tutorial.
If I've got a bunch of plain old Objects, what's the best way to map them to a bunch of Classes?For example, if I use an HTTPService to pull in some JSON, then deserialize it, I'll have a bunch of objects which look like:
{ type: "person", id: 42, name: "David" }
And I want to turn them into instances of a Person class:
class Person { id:int; name:String; }
(also to be considered: how about some standard way of dealing with relationships between objects? For example, if the Person had an additional "spouse" field:
{ type: "person", spouse: 61, ... } // Where 61 is the ID of the spouse )
When I try to do this in an AS CDATA block, it tells me I can't have a class declared within a class (the MX:Application itself). Makes sense. But where and how do I do it?