ActionScript 3.0 :: Classes That Refer To Each Other?
Nov 24, 2008I'm having trouble getting classes that refer to each other to compile:
package People {
class Pairing {
var Father:Person;
var Mother:Person;
[Code]...
I'm having trouble getting classes that refer to each other to compile:
package People {
class Pairing {
var Father:Person;
var Mother:Person;
[Code]...
Is there any way to auto-import as3 classes (internal/intrinsic Flash Player classes at least) using Emacs ?
Looked for as3-mode and actionscript-mode but nothing working was found. as3-mode can import class if it is opened in buffer (but not *.mxml files)
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).
[Code]...
How do you refer can i refer to a Internet url in actionscript 2
View 4 RepliesI'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..
View 2 Repliesinheritance 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?
Is there any way to refer to a certain layers x value, or visibility, or any of those? And if not, what is usually done to preform an action on a whole layer? Should I just make a new symbol out it?
View 2 RepliesHow do i refer to an array name inside an array?[code]...
Now i need something like stuff=array1[3]; (this makes an array called stuff which is a copy of array2, hopefully) and then myvar=stuff[3] (which is "succes").. get it?
Is it possible to have one xml doc for more than one swf, so that i would only need to edit one xml doc as opposed to 12?
View 4 RepliesIs there any way to refer to a certain layers x value, or visibility, or any of those? And if not, what is usually done to preform an action on a whole layer? Should I just make a new symbol out it? And what effect does groups have in actionscript?
View 2 RepliesI have balls (...sounded pervert) that are created by duplicateMovieClip, yes, they spawn, but right on top of each other, and I don't seem to be able to do anything to them, I tried ball+i.onEnterFrame = function(){} typed in several different ways ("ball"+i, ["ball"+i] etcetc...) And I just couldn't find How to refer to them. i'm trying to spawn them to random positions and make them move in random directions (got the moving part already coded but like I said I can't name them -> can't use it atm.)
Short version: How to refer to balls that are created by duplicateMovieClip?
I have a container movie which loads another movie into a Loader object which then gets added to the main timeline. The loaded movie has a main class which controls all the other classes in that movie. The container movie has one other element - a scrollbar which scrolls the loaded movie (which is longer than the container) up and down.
When content changes in the loaded movie I need to pass a message to the scrollbar. If I trace parent.parent.parent from the init() function of the loaded movie it traces [object MainTimeline]. My scrollbar, sBar is a direct child of the main timeline, but tracing parent.parent.parent.sBar doesn't work So how can I pass a reference to the scrollbar to the loaded movie? Here's the code in the container movie:
PHP Code:
var ldr:Loader = new Loader();
var sBar:Scrollbar;
ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
[code]....
I have an array that movieclips are added into depending on the users actions. When they are added to the the array, they are also added to the display list of another movieclip on the stage.I'm trying to refer to them later so I can remove them from this movieclip's display list, but I can't work out the wording.[code]
View 2 RepliesI have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this: obj.x = stage.stageWidth / 2; I get a message that I Cannot access a property or method of a null object reference
I am using the load movie from my main file (main.swf) as:
mc_zoom.loadMovie("detail.swf");
I then have a loader as a movieclip with the detail.swf
when the movie (detail.swf) is loaded the preloader I am trying to make/set the play to go:
_root.gotoAndStop(2);
But this does not work - it works locally but when used with the main file (main.swf)
For instance in Flex 4
?xml version="1.0"?>
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
[Code]....
the traces when the button is clicked twice are 'the id is myButton' followed by 'the id is yourButton'
Not just an idle query. I was hoping to change the id of custom components when populating a main app with them
I have an object created visually. How should I refer to it from classes of other objects? MovieClip(this.root).someObj or stage.someObj or MovieClip(this.root).stage.someObj? And moreover, if I want to see which frame is current on the main timeline, why I cannot just check stage.currentFrame? Why there is no such property of the stage, currentFrame? It has timeline, right?
View 1 RepliesI want to get information of an object from a previous keyframe. _root. works only for objects on the same keyframe as the code right?
View 1 RepliesHow can I refer to an instance on the stage if:
- I added it to the stage using the GUI
- I wrote its implementation in an external AS file
I can't assign it a instance name otherwise I get this error: Code: ReferenceError: Error #1056: Cannot create property myInstance on MyClassName.
i am having problems referencing an mc's instance name via a string var. I think the solution would be simple, but i have been trying different things for a while
ActionScript Code:
var hitarea:Array = new Array;
function populatehitareas()
[code].....
the second bit of code "mc_inst1.onRollOver..." works, but the first bit of code, which tries to loop through all movie clip instances, will not work.I think this is because myReference is a String. But can anyone suggest how else I should construct my reference to the instance name?
Code:
for (var a:Number = 1; a<myCount; a++) {
myReference="mc_inst"+a;
var myClip:MovieClip = myReference;
[code]....
I have 6 movieclips named answer1, answer2, etc. I also have a for loop where I want to assign functions to each one programatically. In my loop if I'm using var i, I wanted to refer to each movieclip with something like answer + i to refer to answer1 (assuming i = 1, for example). However, I don't know the syntax to do this.
Here's a rough shot of my code:
ActionScript Code:
for (i=1; i<7; i++) {
"answer"+i.onPress = function() {
this.startDrag();
[Code].....
what i have is a sub folder with a swf file... i need the .swf file to refer to a file at the main folder... how can i do that? my structure is like this:
[Code]....
I want to make it so that every five seconds an enemy is in a hitTest with an object the object loses 5 points. I need to know if theres any condition so that I can do an.[code]
View 1 RepliesI can't seem to find this simple code anywhere. But, how do I access a movie clip on the main timeline from inside another movie clip. I want to:
Code: Select allwallpaper.gotoAndStop("blur");
i've tried
Code: Select allparent.wallpaper.gotoAndStop("blur");r
Code: Select allstage.wallpaper.gotoAndStop("blur");
Code: Select allparent.stage.wallpaper.gotoAndStop("blur");
I have 3 SWFs.
X.SWF - Parent application. Contains an empty movie clip for loading external swfs using loadClip() method.
B.SWF - Has some text and pics. Gets loaded into the empty movieclip on X.SWF. Also has a button saying 'Load A.SWF'.
A.SWF - Similar to B.SWF with a button saying 'Load B.SWF'.
When I start the main application (X.SWF) and load B.SWF into it all is fine. But would like to click on the 'Load A.SWF' button on B.SWF and load A.SWF into X.SWF. And visa-versa. The problem is I'm not able to refer to the parent container (X) from these child (A and B) SWFs.
I want to enable smoothing for the bitmaps I load using a Loader.
How can I refer to these bitmaps ? Something like Loader.contentInfoLoader as Bitmap?
How do I refer to a variable using strings and other variables? What I mean is, for example, you can refer to an instance of a MovieClip on the root level with instance name "mc1" by doing this[code]...
View 5 Replies