ActionScript 3.0 :: Classes - Define The Objects & Variables?

Oct 27, 2010

m new to as3 & am trying to make a platform game. i'm just not sure how to define the objects & variables. like my character & any other object i want it to collide with will be sprites, but im not sure where to go from there.

View 2 Replies


Similar Posts:


ActionScript 2.0 :: Define A Custom Class To Be An AsBroadcaster In The Classes Constructor?

Feb 22, 2007

Can I define a custom class to be an AsBroadcaster in the classes constructor?

Code:

class myClass{
function myClass(){
AsBroadcaster.initialize(this);
}
}

And if so will that give me the ability to addListeners to an instance of that class?

The reason I want this approach is because I want to broadcast events from inside one of the custom classes methods and I want a textField on the stage to be listening for that broadcast message.

View 3 Replies

Actionscript 3 :: Flex 4: Can't Define S:layout For Subclasses Of Classes Extending Group?

Sep 9, 2011

I'm trying to create a base class for components by extending Group in Flex 4, but I can't seem to define the layout through MXML. Any time I try to move the definition to a subclass of my base component, I get the following error:

Error: Could not resolve <s:layout> to a component implementation.

Judging by that error, it seems that some magic from the framework's side goes into assigning it for a Group and thus the compiler fails when trying to assign it for any other classes. Does anyone know how this is supposed to work? how to allow me to define it in subclasses?

View 1 Replies

ActionScript 2.0 :: Define Variables In A Function?

Apr 19, 2005

Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this [code]...

View 1 Replies

ActionScript 2.0 :: Define Variables To Each MC And Detect It

Aug 2, 2006

How can I store variables like "true" or "false" to each movie clip I have on stage?Each Mc is duplicated thru AS, so when clicked the action would depent on the variable (true or false) that was definned to that particularly MC.lets say all of the MCs starts with a "TRUE" value defined to it.When it is clicked, a "FALSE" valeu have to be definned to that clicked MC and it alone.The rest of them should remain with the false value.

View 6 Replies

ActionScript 3.0 :: Define A Layer For Dynamic Objects?

Dec 5, 2009

I'm creating a number of dynamic text field objects in my Actionscript, but it looks like its being rendered on the wrong layer. I've written the actionscript in the first frame of my 3rd layer (which is masked), but the objects that are rendered dont appear to be affected by the masking effect (that does work with static objects). Is there a way to define programatically which layer an object is rendered in? Something like layerNo.stage.addChild(object)?

View 1 Replies

Actionscript 3 :: Flash Define Variables Before Or In Class Constructor?

Dec 15, 2011

what is the difference between something like

package {
public class Myclass {
var txt:TextField = new Textfield();

[code]....

View 1 Replies

ActionScript 3.0 :: Define Nested Objects And Then Retrieve Them Just By Entering Dots?

Jan 23, 2012

Is it possible to define nested objects and then retrieve them just by entering dots so that at each level the options are displayed e.g in FlashDevelop?

mainobject.levelA.levelB.levelC

View 9 Replies

ActionScript 2.0 :: Dyanmic Text Animation - How Many Textline Variables Define In The Text File

Mar 26, 2004

ok i have a movie clip with a dynamic text field being animated... i have a text file with this in it

&textline1=time
&textline2=place
&textline3=year
&textline4=month

now how do i make the movie clip to first go from frame 1 to 10( last frame in teh movieclip) with the text time and then when the movie clip starts again it should say place and so on and so forth.. depending on how many textline variables i define in the text file?

View 5 Replies

ActionScript 3.0 :: Traversing Objects Through Different Classes?

Feb 12, 2010

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; }

[code].....

View 8 Replies

ActionScript 3.0 :: Accessing Objects From Other Classes?

Jan 7, 2012

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.

View 7 Replies

ActionScript 2.0 :: Targeting Objects In Classes

Feb 7, 2005

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:

[CODE]...

View 7 Replies

ActionScript 3.0 :: Using Variables From Other Classes?

May 16, 2010

Imagine you have one main document class wherein you have some variables that make your objects move or roatate. Now, you make another class in which, for instance, you draw a rectangle (with the graphics class) and want the rectangle rotate in the same way your other objects on the stage rotate. You'd probably wish to access the variables from your main class, so as to asign their values to your rectangle rotation velocity. The question is: how to access those values? Is it even possible to share variabless across all the classes?

View 1 Replies

ActionScript :: Flex : Mapping Objects To Classes?

Jun 16, 2009

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
)

View 2 Replies

Flex :: Class - Create Own Classes / Objects?

Dec 7, 2009

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?

View 2 Replies

Flash :: Passing Data Between Objects/classes?

Dec 27, 2010

So i a building a categorized menu of different foods. I have a class for "categories" (buttons) which essentially will return a string "salads", "drinks", etc. I now have another class "menuItems" for items within categories and this handles sizes such as "small", "med", "large", etc. My problem now is that when i return "salads", i want to invoke an array which contains all the elements of salads, send it to menuItems which will populate the menu. So far i have both the category objects and the menu object setup. I just cant seem to be able to send the data that the category object is returning and pass it to the menu object. Both of which are added to the stage as shown below:

If there was a way that i could say add all these classes to one class so that they can talk to each other that would be great but i dont know how to do this.

View 1 Replies

ActionScript 3.0 :: Accessing Objects With Linked Classes?

Sep 15, 2010

So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?

Code:
package classes
{
import flash.display.*;
import flash.events.*;

[cODE].....

View 0 Replies

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.

Inside my class I have this

Code:
function onLoadStart(target){
baseClip.attachMovie("preloaderTemplate_mc", "preloader_mc", 500, {_x:0, _y:20, _xscale:75, _yscale:75});
baseClip.preloader_mc.gotoAndPlay(1);
}

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.

View 4 Replies

ActionScript 3.0 :: Why Can't Classes Access Objects On Stage

Jul 22, 2009

Im trying to get used to packages and classes in AS3. Im used to put all code on the first frame of the timeline, but now i have 442 lines of code on the first frame. Yeah 442. And this is for a game engine so i thought i should put it inside some classes to make it easier to read an reusable. But i have noticed that if i create a class called Code and make a instance of that class like this:[AS]var codeObject:Code = new Code();[/AS]i get a bunch of errors because the class cant Acess the stage and the display list.i found a workaround by linking the class to a movieClip and and do this:[AS]MovieClip(parent);[/AS?

View 1 Replies

ActionScript 3.0 :: Setting Variables In Different Classes?

Aug 13, 2009

I am trying to set the variable to classes in the loader like this

loaded_swf.content.classname.code = "AS3";

But that wont work for some reason?

View 1 Replies

ActionScript 3.0 :: Passing Variables Between Classes?

Sep 14, 2008

What I have is a list of videos (FLV) and when I click on avideo name (button) I want the menu page to close, open anotherpage (the video interface page) and play the video that was chosen.I do not want the video to play on the menu page but on it's owninterface page. I am guessing I will need to save the String namein an outside file for the video class to grab. Once the video hasfinished playing I want to go back to the menu page.

View 13 Replies

ActionScript 3.0 :: Access Variables Across Classes?

Aug 18, 2009

What I am trying to do is pull data from an XML file so that I can store paramaters for my FLV player (i.e. flv link, dimensions, video name, etc) I can get the data from the XML file and story it in a dictionary but I am unable to access the data from my main class. I know it has to be something pretty simple but I think i have been looking at it to long to see it.
 
// Main.as
package includes.action{    import fl.video.FLVPlayback;    import flash.display.*;    import flash.events.*;    import flash.net.URLLoader;    import flash.utils.Dictionary;    import includes.action.XMLData;        public class Main extends Sprite[code]..........
 
basically with all my traces this is what I get back...
 
// Trace dataVIDOEXML COUNT: undefinedELEMENTS: nullMAIN:LINK: nullWe are in LoadXMLname - no get: mortgagename - get: mortgage
 
 The trace for Elements and Main:Link should give me back the name of the video but as of yet its either returning NULL or undefined.

View 3 Replies

ActionScript 3.0 :: Pass Variables To Classes?

Jan 14, 2011

I want to send the contents of a variable to a class where it can be used in its functions. Since I have no experience with object orientated programming what so ever I tried to break it down into real simple code so I can understand  better what's going on and how I can implement it in my main code.I made a test file and a test class, basicly I just want to give a variable contents in my main code, then send the variable to the class so the class can trace it. But no matter how I try it i always get "Testoop.as, Line 6 1120: Access of undefined property test.Here is the code:

so this is the FLA:
import Testoop;
var test:String;

[code]....

View 2 Replies

ActionScript 3.0 :: Global Variables Outside Of Classes?

Aug 19, 2009

I've done a search and all I could find are creating global variables through Classes.

Is there a way of creating them on the timeline? I have a preloader.swf that loads another swf to itself and would like to read the values off of the parent.

View 2 Replies

ActionScript 3.0 :: Pass Variables Between Classes?

Aug 31, 2011

How to pass a variable from one AS class to another please?

View 4 Replies

ActionScript 3.0 :: References Variables Across Classes?

Jan 12, 2012

I'm building a simple Pong-esque game and I've 'hit' a problem. I'm having an issue with referencing one variable from one class into another. Sounds confusing to me, even harder to understand.

Basically I've got this in my "game.as" class:

ActionScript Code:
public var pongBall:ball;

and in my "player1.as" class I am trying to get said ball to bounce off the player's bat on contact. I think I have the coding right for it apart from trying to link it to the ball from game.as! So far I have this:

ActionScript Code:
public function bounceTest (event:Event) {
if (this.hitTestObject("game.as".startGame.pongBall)) {

[Code]....

View 7 Replies

ActionScript 3.0 :: Classes: (not So) Private Variables?

Feb 21, 2007

ActionScript Code:
class Vector2d extends Math {
private var x:Number;

[Code]....

I can't seem to get my private variable, x, to be private. From my understanding of private variables, tracing n.x should throw an error, and adding 150 should throw an error. I've tried changing the variable's name, and the cast type, to no avail. The first trace goes through, the addition goes through, and the second trace goes through.

I'm new to classes, so I could easily be overlooking something vital. But the vars need to be private, because I want to use get/set to update the variables when one or another changes. For instance, if 50 is added to the y value, the magnitude and unit vectors would change, so I want to update them using getMag and getUnit. That whole system would be thrown off if the user had direct access to the properties.

View 11 Replies

ActionScript 2.0 :: How To Pass Variables Into Classes

Mar 18, 2007

ive written a class to control my content panels on my site. They work well! Currently they controll all the positioning perfectly on there own. What I am having trouble with, is how do i pass variables into my classes. For instance, my main content panel, has variables in the class: public var contentState:Number; Now, what I would like to do, is have movieClips on my stage, or 'buttons' that will be able to change 'contentState' within my class.How do i go about passing these variables?[code]

View 1 Replies

ActionScript 3.0 :: Passing Variables From Down Classes

Mar 23, 2010

I'm trying to create a oop flash website, but I'm really struggling with some basic things. Example 1: We've got four classes

DocumentClass -> FormsClass -> Form1Class -> ListClass

Let's say someone clicks a next button in the FormClass. That dispatches an event "nextForm". Documentclass is listening for this event, and displays the next page. But it needs to read a value (selected radiobutton) from the ListClass. What would be the best way to get this variable to the documentclass?

[Code]...

View 7 Replies

ActionScript 3.0 :: Accessing Variables From Other Classes

May 3, 2011

I am having this issue were I can not access any variables from any other class![code]Now, from my other variables, that is what I do, I don't understand what I am doing wrong?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved