ActionScript 2.0 :: Making A Class And Creating An Instant Out Of It?
Oct 13, 2005i was making a class and creating an instant out of it see how it works.Here's my human class (human.as)[code].....
View 1 Repliesi was making a class and creating an instant out of it see how it works.Here's my human class (human.as)[code].....
View 1 Replieswhere i can get a simple tutorial for making a flash instant message application?
View 1 RepliesI normally use onEnterFrame = function(){} when I want the program to check every frame for things like coordinates, collision detection, if I pushed button, or clicked the mouse on a specific location.
Normally when I want to make a switch, I use a boolean statement, such as
if(conditionA == 0){effect;} or if(conditionA == 1){effect;}
if(conditionB == true){effect;} or if(conditionB == false){effect;}
[code]......
I'm developing a game which will feature a 'light' instant messaging system; 'light' in the sense that I want all logged-in players to receive a "new message!" notification if another player sends him/her a message. It doesn't have to be 'instant' like with a chat service, so I'm thinking about having the game check for 'new messages' every 20 seconds.Now, I'd prefer to use what I already know, which is using AS3 to call PHP pages, querying a database and receive a response in the form of XML which can be used in AS3.
So, my question is this: How feasible / stupid would it be to such a 'light' IM feature using this method: I call "checkForWaitingMessages.php" from my Flash game every 20th second, passing along the player's login id. The PHP page checks if there are any 'waiting messages' in my database under that player id, then returns all 'waiting messages' in XML form, which I use Actionscript to display to the player. This happens every 20 seconds.My main concerns are: - How much of a strain does it put on a nomal hosting service that I request an XML document every 20th second? - What if there are 100 players logged in, making it 100 requests every 20th second? What about a 1000? Is this all in the realm of trivialities, or will this become to cumbersome to realistically implement?
get a bunch of objects in my library to inherit from (or even be) one class that i have made, but without having to make .as files for every single one is this possible, or is there any other way to give objects another classes functionality in an auto-generated class?
View 3 RepliesIs there a way to generate an instance of a class that implements an interface based on the name of the class?
I am trying:
var ClassReference:Object = getDefinitionByName("movement.OuterSpaceMovement") as IMovement;
var m:IMovement = new ClassReference as IMovement;
trace("startup..." + m);
-But I am getting an error message ReferenceError: Error #1065 (OuterSpaceMovement) not defined.
I have several classes that implement the same interface (IMovement) but I need to be able to generate new instances of these classes and then pass these instances as a datatype (IMovement datatype) to other classes...
So then I tried:
var ClassReference:Class = getDefinitionByName("OuterSpaceMovement") as Class;
var m:IMovement = new ClassReference() as IMovement;
and this doesn't seem to work...but the following
var m:IMovement = new OuterSpaceMovement();
I'm trying to create a new instance of a MovieClip when the original one has been used. Would sound easy enough. Just use: var
instanceName:ClassName = new ClassName();
the class name/mc in the library im trying to duplicate is MCg1 so
var instanceName:MCg1 = new MCg1(); right?
However, the particular object in the library i'm trying to duplicate has a base class that is an external class file (just to control it's drag drop functionality)... i.e baseclass is not set to the standard flash.display.MovieClip, or whatever the case maybe. So i end out with a: TypeError: Error #1009: Cannot access a property or method of a null object reference.
I'm making movement of movie clip via creating new Tween in Action Script 3, Flash CS4 and it happens, when I mouse over button in another movie clip. The problem is that movement sometimes work perfectly, but sometimes it gets stuck in middle of movement and continues only if I mouse over again. Here is the code of function of first frame in main scene:
[Code]...
I'm creating a slideshow where each slide can have:- a video or a still- 1 audio track or many (up to 3)- 1 button or many (up to 3)I was thinking that each slide can be it's own object, and then I would pass the video, audio, buttons, etc., into it as parameters:
package
{
import flash.media.Video;
[code].....
I have a class that represents a turret in the center of my screen.When I hold down SPACE, I want it to create a "bullet"-object that moves in the direction of the turrets cannon, every frame the SPACE key is held down. I am having problems with this cause I am getting this error when I am trying to create the object:
Error #1009: Cannot access a property or method of a null object reference.
This is where the error occurs:
ActionScript Code:
public function chaingun(x_:int, y_:int, rot:int, cd:Number, spd:Number, sprd:Number, life:Number) {
this.Cooldown = cd;
this.Speed = spd;
[code]....
PS: What happens is that when I press the SPACE key, the "turret" class event handler runs the function "Shoot_Chaingun" and that function creates a new Chaingun-object (which actually is a bullet), that inherits the x, y, and rotation of the turret, along with some additional varaibles, including lifetime. Then upon creation, I use "addChild(this)" to add it to the main stage, and "removeChild(this)" once it's lifetime is up.
EDIT: And also, I just realized I don't have a MovieClip linked to this chaingun class. How do I make sure that every time a chaingun object is made, the MovieClip is also loaded?
I have a need to create a Ternary Plot graph from 3 different variables.
[URL]
I basically need to come up with the x/y coordinates of the point within the triangle, from the ratio of the 3 variables.
Is there any function / algorithm that anyone is using to create this? The language I am using by the way is ActionScript 3
I am looking for a instant messages server only, no media....is there any server..
View 1 RepliesI saw in some projects that ppl has their own "Debug class".So, instead of typing: trace("look at this!") you type Debug.trace("look at this!").The only advantaje I saw was that you can disable every single trace call with a single parameter in the Debug class.. but, thats all.
View 2 RepliesI was thinking of making a complex number class but then realized it would be a bit of a pain to have to call functions every time I wanted to perform operations on them. Would there be any way that I could set two complex numbers like so:
Code:
var z:Complex = new Complex(-0.7, 1.4); //where the number is then -0.7 + 1.4i
var c:Complex = new Complex(1, 1.1);
and then store the result in another?
Code:
var x:Complex = z + c;
In other words, is there a way to make the +, -, * and / operators behave in ways other than those they normally would?
I have created some code that creates a blue circle of random size on the stage, and startmoving it in a random direction, at a random speed.
But I'd like to create this as a static class, so that I can just import into a banner and make multiple instances appear at a time, but my limited knowledge doesn't allow me to
Here is my code:
Code:
var child:Shape = new Shape()
var childSpeedX:Number = Math.random()
var childSpeedY:Number = Math.random()
var childDirectionX:Number = Math.random()
[Code]....
I am just making the move to AS3, and in particular - moving my code to classes and packages. And right now, the penny hasnt dropped. I understand that packages group a group of related classes, but my brain just hasnt seemed to grasp a few concepts.
As a start, i thought i would port a dropdown i built in as2, to as3. The problem i am having specifically is making instances of the dropdown aware of each other. For example, I have a Dropdown Class that adds my dropdown to the stage. This class is responsible for building the dropdown, and adding the items to it.
But lets say i make another instance of this class. This brings up several issues that i dont fully understand. For example: - when one dropdown instance is open, it is the current_selected. When I open another dropdown, i want to send an event to the other instances that says "hey, if you are open you need to close" - a reset all function. Which would work similar to above. It would send an event all all instances of the dropdown class and trigger their internal "reset()" method
In as2, i would simply create some variables to keep track of these things. As far as i am aware, you can't add package level variables that instances can all see?
So, Do i need to add a customised version of the event dispatcher? and if so, how do i tie all these instances into a group of sorts.
I am trying to build a preloader class for loading external content (images in a gallery). I have no experience in this area and I could not find many examples of making preloader classes. I was wondering if and how would it be possible to trace bytesLoaded and bytesTotal from within the preloader custom class. I was trying to pass the Loader's variable into the class and then try to trace the bytes but no luck with that.
View 1 RepliesI am an amateur programmer attempting to make an adventure game and I need a little help. The basic setup is a panoramic engine that loads external swf's when you click on a specific area. I need a way to globally store the states of the puzzle variables so that you can save your progress.The basic idea for my save game class is as follows:
[Code]...
In AS2 I could just do onRelease() inside the class, and all the movies would be clickable, if the class extended a MC.
This is my AS3 code, not sure why it won't work. It's like nearly impossible to Google, spent like the last two hours doing it.
Code:
package
{
import flash.display.MovieClip;
[Code].....
I think I understand how to make a interface but the problem is im unsure as to how to add it to my existing code! To make a interface (as far as i know) You can create classes such as mainScreen, intructions and so on. Ok i get that, make the classes then add ther buttons from the library i these classes. But i followed a tutorial bu Emmanuel Feronto, and adapted that to the needs of my game.
So im unsure as how to add these 'Screens' to my current class, the I currently only have 1 class, Main which currently has 300 lines of code, and i dont know how to break it up into smaller classes. Thats the problem i think, The main is quite large, normally i have heard people keep this clear... But then say i made a bland main, and added the screens into that then how do i make the main that makes the game play on the play button?
I am making a circle countdown timer class. It works fine, however, the startAngle variable isn't really working the way I wanted it to. It seems to start at 45 degrees even though I have it set to 0. I want it to start at the top and work it way around like a clock. So it would start at 12 and end at 12. Here is my class
Code:
// Create an instance of the class in an empty FLA
import com.ronnieswietek.utils.CircleTimer;
var counter:CircleTimer = new CircleTimer(15,0xff0000,0x000000);
[Code].....
I am trying to stumble my way through learning AS3 while making a game and I would like to create a movie clip from a class but I don't want it to be a boring square, I wanna use a movieclip from the library, how would I do that?
View 2 RepliesAnyone tried TextAnim? It's brilliant for making your own text effects.I am making something real simple but cannot get it to work. I am sure just pure AS3 thinkers could probably solve this without even knowing the class.I store some lines of text in an array, and each time I click the stage - the text anim kicks into do its magic on the new line of text pushed at it.here's the code - i have an instance of myTextField already on the stage
Code:
var t1:String = "This is my first line to write";var t2:String = "This is the black hole I was talking about";
var t3:String = "And now TO END WITH CAPITALS";
var txt_ary:Array = new Array(t1,t2,t3);[code].....
I'm an actionscript beginner and trying to write a class to make the 'enemies' follow the 'player' (shown below). I'm trying to write it such that it takes two MovieClips as arguments, and moves the first one toward the second one. When I import the Class try to use it in Main.as by typing " var followPlayer:FollowPlayer = new FollowPlayer(fishMov0, player);", I get the following error:
"ArgumentError: Error #1063: Argument count mismatch on jab.enemy::FollowPlayer/followPlayer(). Expected 2, got 1."
[Code]...
I'm currently trying to make a class that changes the mouse cursor. I made it in a new class so that I can call it again whenever I needed it, but there are some errors and I don't know how to solve it. The class filename is Cursor. This class is not linked with the fla file.
Here's the ActionScript Code:
package {
import flash.events.MouseEvent;
import flash.ui.Mouse;
import flash.display.MovieClip;
public class Cursor extends MovieClip {
public function Cursor()
[Code] .....
This class will just let me type Cursor.makeCursor(cursorMovieClip); and the cursor will change. The problem is that Flash does not recognize "addChild" and "stage". Is it because the class isn't connected to the fla? Or do I need to import some stuff in? Also, flash does not recognize "obj" in the code line
ActionScript Code:
var cursor:MovieClip = new obj;
I have a large creation in process that requires a lot of heavy animations and movement with vectors and really processor intensive. Just want to know, regardless of whether the project is huge or small, how to totally stop a class from working? I have three classes I am calling. "class1 = new Class1();" etc. When I am in the level, say, class2, I can still talk to objects in class1 even though I removed the class listeners within that class1 after I was done using it. It still is able to be called upon, and still running something in the background that I can't figure out what it is. I just want to know, rather than searching for whatever is causing the problem, can't I simply null the class that I never ever need to use again?
I tried that, but then I ran a trace and it still tells me that it is a class object. I reckon its because I have a "public var class1:Class1" etc, which means they will always have those objects associated with them, but still. I want to totally get rid of it for garbage collection, and because I don't want to use some of them at all, ever again. So basically, what is the best way to get rid of classes so that they aren't hogging up resources any more?
When you initialize a new object, how can that class have access to a variable from the parent?In this case Blob needs to be able to access scale?[code]
View 2 RepliesI want to create a rectangular box and add it to the stage. Easy enough.
At the moment I create custom classes and attach them to movie clips in the library via linkage, but in my example there is nothing to attach it to as it does not exist. How can I create a "generating class" like this?
I just want to call it with a call like
createRectangle() or possibly have some parameters createRectangle("200", "400")
i've got a fair bit of text i'm trying to keep on an internal page by just making each section a scrolling content box. So there are 3 buttons at the top, each 'scrolls' onto a new section and I would like the ability for it to scroll back too, hence using the tween class to do this. I've managed to set it up and each button goes to each 'page' fine in reading order, so to speak (1, 2, 3), but if I got to 1, 2 then back to 1 it will start from 0 on the x axis.
Basically what i'm wanting to do is set the tween from the current _x value. So if I go 1, 2, then back to one, it will take the current _x value from 2, and scroll the opposite direction back to one. I am using the following code on the buttons:
[Code]...
Version: Flash CS4, AS3 is it possible to turn a given sprite into a Class with a given string as its name? The resulting class should then be available under that name in the current domain's definitions.ie.
createClass(someSprite, "someName");
....
var someClass:Class = getDefinitionByName("someName") as
Class;