ActionScript 3.0 :: Making One Variable Available To Multiple Classes?

Jan 15, 2011

I'd have thought this to be simple, but nothing works. I have a game I'm working on, and in it, there will be a speed stat. The fast you are going, the faster everything else has to move to make it look like you are moving faster.The problem is, the speed stat (obviously not called speed) is one of the upgradable stats, and needs to be available for the class handling upgrades for it to be changed, and it needs to be read by the class handling moving objects.The second class however, has absolutely no idea the variable even exists. I've tried for weeks to look up a tutorial on it, but there doesn't seem to be any at all that I can find. (I am using public variables, and have tried various ways of trying to point at the class it's from but apparently I must be using the wrong syntax)

View 12 Replies


Similar Posts:


ActionScript 2.0 :: Multiple Classes Accessing The Same Variable Without Making It Public?

Dec 26, 2006

i've got two classes and i'm not extending to MovieClip. I like to attach the mc in the constructor just because i'll be working with different MC's that have the same purpose.

however, im using private var loadedMC:Movieclip and now i've got another class that needs to be able to access the instance's variable.

for example, myClass.loadedMC , but this would mean having to make it public and I rather not go that route.

View 2 Replies

Professional :: Making And Loading Variable Classes

Feb 13, 2012

AS3 says you need to load variables into a class?my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them but now I realse that I can't access or call them outside the movie clip they are in.[code] The Wholesale price. A wholesaler is usually a big shed where goods are stored.

View 7 Replies

ActionScript 3.0 :: Unexpected Errors, Multiple Helper Classes, Extended Classes?

Jan 9, 2010

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.

View 4 Replies

ActionScript 3.0 :: Making A Movie That Has Classes?

Apr 1, 2011

I am making a movie that has classes. There is one MovieClip in the movie and it needs to have a blank base class, because one of the classes is a Dynamic.

Flash 4 keeps auto-filling in the base class: flash.display.MovieClip . How do I stop this from happening?

There is no preference to change the setting.

View 5 Replies

Ajax - Making Multiple Asynchronous Calls To Fetch Result From Multiple Services In The Single Click Of A Button In Flex?

Dec 27, 2010

In one of our project we are using flex for front end, blazeds/java in the backend. Its an existing code where services are prewritten. I have to make calls to 3 services in the backend (basically 3 remote objects) and get their result and store the result in an object and show the data of this object in a view.
Now in front end we are using Flex and Parsley Framework. I was thinking of the following approaches.

1) Making commands for each service call and storing the result in a shared object (model) and then displaying this model in the view. In this approach the problem is some services are needed in some other web pages, but they donot need the same model. How should i handle this scenario ? Should i make a asynchronous remote call and fetch the result and then again dispatch and event with the event object storing the result.

2) Making a service call , wait for the result then make another call and wait for the result and then make other call, not sure if this is the right way ?

View 2 Replies

ActionScript 3.0 :: OOP - Making A Multipage File Using Classes

Nov 10, 2010

Basically I'm trying to make an air app which contains a variety of different pages - I was under the understanding that each page would have its own class file, with everything being instantiated for that page within the class file.

If that is the case, then how would I make the transition from class to class and also remove the previous class so it doesnt take up memory?

View 7 Replies

Flash :: Expose A Method In An Interface Without Making It Public To All Classes?

Nov 7, 2009

I have a issue where I'm working with a particular interface for quite a lot of things. However, I have a particular method that I want to be available only to a particular group of classes (basically, an internal method). [code]...

View 4 Replies

Flash - Making Starling FrameWork To Work With Classes That Uses Native DisplayObject?

Dec 6, 2011

I'm trying to use Greensock LoaderMax on a Starling Framework project, but since Starling have a lots of its own class, how I can make it work with other classes that is using the native class?

Exp:

package
{
import flash.display.Sprite;
import flash.events.Event;

[code]....

will return the error:

Error: Implicit coercion of a value of type com.greensock.loading.display:ContentDisplay to an unrelated type starling.display:DisplayObject.

View 2 Replies

ActionScript 3.0 :: Combine Multiple Variable Names Together To Target New Variable?

Jan 31, 2012

I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).

My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.....)

I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.

Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)[code]...

View 2 Replies

Actionscript 3 :: Combine Multiple Variable Names Together To Target New Variable

Jan 31, 2012

I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).

My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.....)
I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.
Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)

So my buttons as well as loading the image have the event listener:

image1_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection);
image2_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection);
(and so on..)
function setCurrentSelection(e:MouseEvent):void {

[Code]...

So within the rotateClockwise and rotateAntiClockwise functions i need to be able to recognise which is the currently active loader and have that number instead of the X - so if it is image1_loader - it needs to be image1_content, if 4 - image4_content... I had tried to do it as this but it doesn't like it being a string:

rotateAroundCenter((activeLoader+'_content'), 10, ptR);

View 3 Replies

ActionScript 3.0 :: Combine Multiple Variable Names Together To Target New Variable

Jan 31, 2012

I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.)I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)So my buttons as well as loading the image have the event listener:[code]So within the rotateClockwise and rotate Anti Clockwise functions i need to be able to recognise which is the currently active loader and have that number instead of the X - so if it is image1_ loader - it needs to be image1_content, if 4 - image4_content.I had tried to do it as this but it doesn't like it being a string:[code]

View 3 Replies

ActionScript 3.0 :: How To Subclass Multiple Classes

Nov 5, 2009

How do you subclass multiple classes. I have a class that subclasses MovieClip. I added a new feature. Now its yelling that my class needs to subclass SimpleButton. I know there both part of the display class. But how do you subclass that?

View 1 Replies

Flex :: Multiple AS Classes In One Swf File?

Oct 18, 2010

I'm trying to compile AS files using the mxmlc but the particular class depends on other classes. My command is something like this: mxmlc -includes classA classB -source-path=. com.example.com.classC.

This gave me classC.swf but when I loaded it, it was still looking for classA.swf and classB.swf. Is there anyway I can have just one swf file?

View 1 Replies

ActionScript 2.0 :: Multiple Classes And Movieclips?

Nov 14, 2011

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

View 2 Replies

ActionScript 3.0 :: Use Multiple Classes For One Package?

Nov 28, 2009

I'm trying to set up an AS3 project using a single package, that will have multiple classes coded in seperate files.I am looking for examples and tutorials for this kind of project.As I understand it, these files must have the same package, and their class must be public. This will allow the multiple files and various classes to be used in the single package.[code]Either of both of these files could then be imported into the main movie and their classes / functions used in the package.

View 6 Replies

ActionScript 3.0 :: Use One XML-file For Multiple Classes?

Dec 27, 2009

Is there a way I can load an xml-file in a separate as-file and use this for multiple classes? (Or, should I load the xml-file in every class I want to use it in)

for example i set up a basic xml structure

test.xml

Code:
<xml>
<first>use this data in the first class</first>
<second>use this data in the second class</second>

[Code].....

View 1 Replies

ActionScript 3.0 :: Multiple Classes In One File

Dec 5, 2009

So, what exactly are the rules on several classes inside of one AS file?So far, the only way I have been able to do this is by putting the class outside of the package brackets with no namespace selected (which I believe means 'internal' by default, right?)[code]So, using this notation, I'm wondering if a few things are possible:

1. Putting several 'secret' classes in the same AS file?

2. Making these classes public via the "Main" class, the one that the AS file is actually made for?Both examples applied here. Are these the right ways to do this?:[code]

3. Since these classes are marked as internal, they should be available to classes which extend the Main class AND classes in the same package without any import statements, correct?

4. Does embedding classes like this affect performance in any way?

5. Will these embedded classes always be compiled even if they are never accessed or referenced, similar to Library items or other classes?

View 3 Replies

ActionScript 3.0 :: Stripping Variable Between Sub Classes?

Dec 5, 2010

I was just wondering if this is possible and the best way to achieve the following.I have 3 classes. One base class and 2 subclasses. eg MyShape, Square, Circle. The Circle and Square classes both override the MyShape's assignProperties method which takes a string as its argument.What I do in this method is loop through a serialized string and assign variables.So the string looks something like p:10|x:200|f:300Because some of the properties are generic to the MyShape class I have the Circle and Square assignProperties call super.assignProperties()Now this all works great but I realised I'm going to get some repitition calling it at each level.

So I was thinking is it possible to get the supers.assignProperties to strip a property from the string if it is found before the assignProperties in the Circle and Square class is called.Here is sort of what I have with a little pseudo codeSquare Class assignProperties Method

PHP Code:
assignProperties(_properties:String) {
var properties:Array = _properties.split('|');

[code].....

View 4 Replies

ActionScript 3.0 :: Passing A Variable Through Classes?

Apr 4, 2011

I have two classes, IntroScreen.as and MainMenuScreen.as.I have an input text box on the IntroScreen that captures text and successfully traces it in the same class.

Actionscript Code:
public var nameEntry:String;public function startButton(event:MouseEvent):void {  trace("Start button clicked.")  nameEntry = enterName.text; 

[code].....

View 13 Replies

Accessing A Public Variable Between Classes?

May 25, 2009

I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code.  What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.

Document ClassEgoGame.as
package
{

[code].....

View 3 Replies

AS3 :: Flash - Pass A Variable Between Classes?

Mar 2, 2011

I've been having a problem with passing variables between classes.

I have one class called GlobeView.as

Within that is a function designed to add markers to a globe

GlobeView.as -
public function addAdventureMarker( latitude:Number, longitude:Number, name:String=null ):void
{

[Code]....

View 3 Replies

ActionScript 3.0 :: Return Variable Between Classes?

Jan 21, 2009

I have a problem with returning variable between classes. As far as I know there are some ways to do it but in this particular case I tried to use Getter.

So I have an XML file (content.xml), a class to read XML (LoadXMLExt.as), a class to display images, and the main class which first call the LoadXMLExt to get the information from and then call the displayimage class including passing the information from LoadXMLExt.

[Code]...

View 4 Replies

ActionScript 3.0 :: Pass Variable Through Classes?

Dec 9, 2009

How do you pass variables through classes?

View 7 Replies

ActionScript 3.0 :: Creating Multiple Timer Classes?

Mar 8, 2010

I am attempting to use multiple AS3 timers to run a short animation in flash but I'm having a problem with some of the instances running slowly or not being removed when they are supposed to. I found a way to make things work the way I want but in being new to AS3 I believe my runtime issues are due to jumbled code.

import fl.transitions.Tween;
import fl.transitions.easing.*;
var playerFadeTween:Tween=new Tween(thewebs, "alpha", Strong.easeOut, 0, 1, 2, true);
var playerXTween:Tween=new Tween(thewebs, "x", Strong.easeOut, 292, 10, 2, true);

[Code].....

View 1 Replies

Flex :: Extending A Class With Multiple Classes

Jul 16, 2010

I'm creating a class that extends another class.

public class ASClass extends UIComponent{
}

but I'm trying to make it extend multiple classes. Is this somehow possible? I read it may be possible through composition?

View 2 Replies

Actionscript 3 :: ASpecify Multiple CSS Classes For My TextField?

Mar 31, 2012

I'm adding a TextField with html text. I'm applying a StyleSheet to it.

How do I apply multiple classes on my html element like so

<span class='classOne classTwo'>my text </span>

I tried this and it looks like flash can't handle this, it renders text without any styles.

View 3 Replies

ActionScript 3.0 :: For Loops For Multiple Classes On Stage

Dec 31, 2009

I have a document class of particles and i'm trying to add multiple instances of the class...

[Code]....

is this the correct way to add multiple instances of the class to the stage?

View 3 Replies

ActionScript 3.0 :: Multiple Identical Classes In Different Packages?

Jan 13, 2012

Say if the structure of my game is set up like this:mainMenu- Classes inside the mainMenu package.instructions- MainMenuButtonClass.- Other classes inside the instructions package.game- MainMenuButtonClass.- Other classes inside the game package.The class MainMenuButtonClass is a button that, when clicked, directs the user to the MaiMenu and is identical in both the instructions package and the game package. Would it make sense just to save the same file in two locations or is there a better way to handle it.I'm not trying to access variables between the two classes. I'm not looking for any code either.

View 2 Replies

Actionscript 3.0 :: Document Classes And Multiple Scenes?

Sep 2, 2010

I've been searching the internet for how to use scenes in flash games, and from what I understand it got some problems? MY problem is that i cant really understand what the problem is and I cant find i "clean" explanation.

Some say you dont should use scenes in game development, some say you should?? Im confused.

Another thing that i dont understand quite is the document classes. Should i have one document class for every scene or one for all of them?

If i have 2 scenes with it's own document classes, how do i switch between them?

View 4 Replies







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