ActionScript 3.0 :: Display Object Management Within Class *tear*?
Jan 28, 2010
I've been procedural programming with AS2 for a few years. just recently jumped into AS3 a couple of weeks ago and working on a current project and trying to write a class that:
1) loads and collects data from an XML file
2) creates text-based buttons using the XML data
3) loads page sections once these buttons are clicked
i have all those down so far.
i am using TweenMax for tweening. there are two for loops that create the text buttons because they are separated with a header. if there is an easier way to do this, please let me know. the section class is a library movieclip and populated with data from the XML file. it is loaded to what i think is the parent clip of the buttom. so, each instance should look like[code]...
View 1 Replies
Similar Posts:
Jul 28, 2011
Using Flash CS5 Professional I have created a symbol, dragged it onto the stage, and given it an instance name of GreenLight1. If I want to make this visible from the document class, I can simply do the GreenLight1.visible=true; and poof it's good to go when I test the file. As long as I stay in the document class I am good to go, but now I'm trying to move to another class and hitting ALL kinds of trouble just trying to get Flash to allow me to access this simple object. All I am looking to do is have this GreenLight1 go invisible (visible=false) when a certain condition occurs in this new class and Flash just won't let me access GreenLight1 at all. Things I've tried thus far:
stage is passed to the class and is referenced by _stage and is working just fine when I do _stage.addchild or anything like that. So I have tried "_stage.GreenLight1.visible=false;" and I get "ReferenceError: Error #1069: Property GreenLight1 not found on flash.display.Stage and there is no default value." My document class extends Sprite, so I figured I'd try the root function. So I tried "Sprite(root).GreenLight1.visible=false;" and I get "1119: Access of possibly undefined property GreenLight1 through a reference with static type flash.display:Sprite." I tried to create the Resource class as described therein. To which I came across the same problem that I started with in that it doesn't know what GreenLight1 is to begin with so I got "1120: Access of undefined property GreenLight1." Here is my code for Resource.as (am I supposed to pass something to this class from the document class?)
[Code]...
View 2 Replies
Jun 27, 2011
How can i cast a object to another type? in AS3 i tried putting (objectType) infront of the variable but it doesnt work, below i have added objects of fishes into the child, and i am getting the fishes back out when mouse down is triggered, and then calling the fishes what to do. however i cant call the method of the custom class fish because it is a displayobject.[code]...
View 1 Replies
Nov 4, 2009
Does anyone have suggestions for a good method to manage the display list in an actionscript 3 project? I'm building an application at the moment and keeping track of all the modules which need to be displayed and reordering them has become unwieldy.I have loaded swfs and instantiated classes that also load in swfs, images and video.. Should I just reference everything to the stage? How should I keep track of the display tree? How can I always force one particular module to the top of the tree?
View 3 Replies
Nov 28, 2010
I have a movie clip in my library with a class name "MyClass", and I am trying to do something like this:
ActionScript Code:
function createbtn(bclass:Class):void{
var addB:bclass = new bclass();
addChild(addB);
}
creatbtn(MyClass);
But i get the "1046: Type was not found or was not a compile-time constant: bclass." Error.
View 9 Replies
Jun 6, 2010
Does flash supply 'invisible' containers, to make object management a little easier ? eg. add some objects to the container, then add the container to the stage, then later on remove the container (i.e removing also the objects) ?
View 2 Replies
Jun 8, 2011
I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it,I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button.So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.[code]How can I tell displayName to change it's current frame from within display object class?
View 9 Replies
Jun 3, 2011
I have a collection of movieclips, I would like to create a clone (a new instance) of a instance everytime I create a new object.
For example
var s:Star = new Star(); // star-shaped movielcip
addChild(s);
// then I want to duplicate an instance of s and add it beside s
For an example like above, it's simple enough to create a new instance with a different name and just add it to the display list. But I have a list of objects I would like to clone as a group...?
View 2 Replies
Sep 8, 2009
I've been trying to figure out how Flash does its memory management regarding object declarations but haven't found anything that describes declarations themselves. [code]Basically I want a pool of declared variables that get instantiated only when a certain type is set. I'd have logic in other functions that figures out what the type is and then does certain things to it, but for now I just wanted to know what kind of memory management Flash does with something like this. Does it do nothing until I actually instantiate it (= new Object()) or will space be set aside once I simply declare it (someObj:Object)?
View 2 Replies
Aug 23, 2009
I have a SendData class that sends form info to a php script. It is a static class that does not extend anything.
I want to be able to dispatch an event if there is an error, or when it gets info back from the server. I have a custom event class that I have been using to dispatch events like this, but I have only used that in displayObject extended classes.
The problem is, it seems like something has to be a displayObject based class to dispatch events. I know there must be a way to do this, but I'm having trouble finding it in searches.
View 2 Replies
Nov 7, 2011
I have a question regarding AS3 memory management. Supposing I created an instance variable for a Class, in this case or type Sound:
public class SoundStore extends Sprite{
var s:Sound;
Then within various class functions I referenced this variable multiple times, each time I wanted to load in a new sound:
s = new Sound();
Am I correct in thinking that each time I created a new Sound I would be overwriting the previous allocated memory?
View 1 Replies
Jan 31, 2010
If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased.With 45 rotation, the size becomes about 143x143 (from 100x100).Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't.At the moment I am doing this:
var currentRotation = object.rotation;
object.rotation = 0;
var normalizedWidth = object.width;
[code].....
View 4 Replies
Jan 10, 2011
want to make a tear/rip/flip effect and i find alot of diffrent pageflip flash pages out there and tutorials, but the problem is that i want it to be "static", a code that i just past on the MC, so it *flips* when you get to X frame in the timelineThe feel is like the link below, except that i want the page to completely rip o
View 9 Replies
May 22, 2008
do you know the tear or remove pages in page flip v2. i want to eliminate the tear or remove pages function. thnks in advance!!
View 1 Replies
Mar 6, 2008
Is there any way to test if a display object has been added to the display list?
View 9 Replies
Jan 22, 2012
can I resize a display object (container) without its contents (children) are resized?
For example, in the following code when I resize the green square, red is also resized. I wanted to resize only the green.
ActionScript Code:
import flash.display.Sprite;
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xff0000);
[Code].....
View 3 Replies
Mar 4, 2011
What's a simple way to detect if a display object is currently on the display list?
View 1 Replies
Aug 14, 2009
Can you make one Bitmap Object (I'm using an external jpg) or something similar, and then display it many times simultaneously without creating a separate object each time?
Also, would they be easily removed or hidden?
I've got a little checkmark jpg graphic loaded here, but I'm not sure how to go about using it in many places at once.. I can only display it in the one place at any one time...
I'm thinking there might be a way to load the picture once, then use its bitmapData elsewhere in new display objects somehow, without needing to reload the image over and over?
View 3 Replies
Feb 9, 2009
It's my understanding that a display object cannot be in the display list more that once.So if I add something to the stage shouldn't a second addition of the same object replace the first? for instance:
[code]...
there should now only be one "myDisplayObject" on the stage.
View 3 Replies
Aug 4, 2009
I'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
[Code].....
View 3 Replies
Jul 20, 2009
I have a class CoverPoint extends Pointwith some extra function.except for that ther is no difference. I would like to use the functions of Point with a return value of Point, to calculate those CoverPoints.Can i turn the return value into CoverPoint (since all the vars are the same, there shouldn't be a problem with that, right?), so that it can be stored in my var cP:CoverPoint;
View 2 Replies
Jun 24, 2009
And i cant figure it out.the "my.fla.class"content looks like this
Code:
package my_fla
{
[code].....
View 2 Replies
Jul 28, 2010
I'm trying to build a shuffle function that somebody gave me into my card game. I two external .as classes; one is Shuffle.as, which is my document class, and the other is card.as. I'm building the shuffling function into Shuffle.as. I think I'm getting close to making it work, but there are some problems. I keep getting this error message: "5000: The class 'Shuffle' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type." Here is my code. Shuffle.as code
[Code]....
View 2 Replies
Mar 2, 2011
package {
public class priyan {
public var a:String = "priyan";
public var b:String = "bhagavath";
public function method():void {
trace(a);
trace(b);
The above script, i got it from one of the ActionScript 3.0 book. i just work it out in flash. But it shown error 5000: The class 'priyan' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
[Code]...
View 1 Replies
Jan 29, 2012
If I have three classes:
public class Example {
public function Example () {
}[code]............
You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like
function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()
View 3 Replies
Nov 8, 2009
I have question regarding removing instantiated objects. Let's say i have a main class in which i instantiate a custom video player (or whatever) class:
[Code]...
From my experience, if i don't destroy for example event listeners from my VideoPlayer class and just remove VideoPlayer class the way described they still get fired with null exception messages etc. This is something that's bugging me for a while so i would really like to know what's best thing to do here?
View 1 Replies
Mar 15, 2009
When I use MouseEvent.MOUSE_OUT the target is [object MovieClip], but when I use MouseEvent.ROLL_OUT I get [object Bildspel] - and Bildspel is my class. The thing is that when I use ROLL_OUT I'm not able to delete the targets ENTER_FRAME event.
[Code]...
View 2 Replies
Sep 14, 2010
Ok. So heres what I am trying to do. I want one movie clip to follow another one that I move around with actions on the main timeline.The problem is that the follower clip is linked to a class file and I cannot find a way to find the players position.
[Code]...
View 8 Replies
Aug 18, 2009
I found myself loading a new XML file every day and so decided to create a small class that will load the xml file and return it.The class is loading the file but when i try to return it to a new xml object in the document class it doesnt load it.I think that it's something to with the return being in a nested function but i tried a few ways and non seems to work.
[DOCUMENT CLASS]
loadXML:LoadXML = new LoadXML();
myXML:XML = new XML(loadXML.loadXMLFile("gallery.xml"));[code].....
View 1 Replies
Jan 6, 2011
I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.
Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
This is the code for testClass1:
ActionScript Code:
package
{
import flash.display.*;
[Code].....
So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?
View 3 Replies