ActionScript 3.0 :: 3 Instances Of 1 Class Share Variable?
Feb 22, 2009
I have a button class and I made 3 instances of that button class as.. btn1, btn2 and btn3 Is it possible for the btns to share a global variable or something? For instance what I am trying to do. if btn1 is pressed it triggers a global variable "isClick = true" and if I click on a different button (btn2 or btn3) it checks to see if isClick is true then it calls a function A if not then calls different function B.
View 1 Replies
Similar Posts:
Feb 12, 2011
i've made a Tile-class where i set "buttonMode = false" for each instance. I have been able to test that the value can be change from the main AS.-file, so this part works.
Code:
package
{
import flash.display.MovieClip;
[Code]....
This does change "buttonMode" but only on the very last instance. So this is where i'm at a loss -- i thought you could change all instances with one command like this but apparently not?
View 9 Replies
Sep 3, 2009
I am creating multiple instances of a movie class with the same variable name. The movie is then added random on the stage with a tween. On a mouse handler click, i want to remove the movie from the stage.
I am getting error -
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at Untitled_fla::MainTimeline/removeBlock()
Code:
import gs.TweenLite;
import flash.utils.*;
var block:block_mc;
var myTimer:Timer = new Timer(1000, 15);
myTimer.start();
[Code] .....
View 4 Replies
Jul 30, 2009
I'm using CS3+AS3 and I have a Flash project with a menu, the items in the menu can expand to reveal more items and this is currently done by having each state of the menu in a separate frame, and then doing "gotoAndStop" in this movieclip when buttons are pressed.Perhaps not the best solution, but works very well for this purpose, but as you can imagine, this means that the "same buttons" in "different frames" will do the same thing.All frames were constructed by duplicating the first frame, then moving the buttons around and adding more buttons where needed. So now I set instance names to the buttons in frame #1 and added event-listeners. But when I tested the project, the buttons that had event-listeners in frame #1 also had them in all the other frames. Now this could be an awesome feature, but right now it's more of a huge mystery to me.
ance names in frame #2, but yet they share the same instance. I searched all over the IDE but I could not find any functionality to actually determine what instances are linked, how to link instances or unlink instances. But I do know that two objects share instances when you duplicate them.So my question is, is there no functionality in the Flash IDE to actually make more efficient use of this?
View 1 Replies
Feb 16, 2012
This is the class text.as3
private function showTextArea():void{
textField = new TextArea();
canvas.addChild(textField);
}
This is the code to create the text area,i want to pass the text area to another class(text2.as3).Is it possible?
View 1 Replies
Aug 13, 2006
can global variable share its value in other scene as well?
View 2 Replies
Jan 12, 2011
How to share TextArea Component in multiple swfsaylib.swf (has TextArea Componenet)main.swf (Import TextArea Componenet from lib.swf)section.swf (Import TextArea Componenet from lib.swf)
View 1 Replies
Dec 6, 2011
I have a Singleton class instantiated in Main.swf located at domainA. The file loads Game.swf from domainB via LoaderMax [URL]. When I try to access the Singleton I guess this is not the same as the on instatiated in Main.swf.
View 2 Replies
Jan 23, 2012
I'm trying to load swf from 127.0.0.1 into my main.swf with Flash Pro
Both swfs have Singlenton class
How to make it that loaded swf use Singlenton of main.swf ?
I did
ActionScript Code:
var lc:LoaderContext = new LoaderContext();
lc.applicationDomain = ApplicationDomain.currentDomain;
myLoader.load( new URLRequest("http/127.0.0.1/loaded.swf"),lc);
anyway I have 2 different Singlenton classes one comes with loaded.swf another in main.swf and variables not shared
is any way I can merge this values?
View 5 Replies
Feb 24, 2009
I have a bunch of games each in there own directory with there own classes. I need to make 1 global directory with a class in it that all my games can use.
The reason for this is if I need to make a change to this class, I don't want to have to keep copying it into each game folder.
View 2 Replies
Sep 9, 2010
Is there a way to share common .as files with multiple swfs?
View 5 Replies
Dec 24, 2009
i have several flash projects and i have common classes. is there a way to share these classes between the project so i won't need to copy it to all the project when ever i modify something?
View 2 Replies
Jul 8, 2007
I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)
Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}
where "u" is another class, the Updater class with this code...
Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){
[code]....
PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?
View 2 Replies
Jul 16, 2009
I'm slightly new to Flash CS3 + AS3 combo, so its more of a lack of practice question. My question stems from the problem described here http:[url].... . Note, its not the same problem, its a new one.The Problem ,So I have multiple library assets (which are on teh stage) and I want to assign similar functionality to all of them.
Attempt 1: So I create the n assets, create a custom class in AS3, link them to Flash CS3 and obviously enough it gives me the error that multiple assets can't be linked to the same class.Obvious enough to understand (well not completely, because from a programmers background it doesn't make sense).
Attempt 2: Same as attempt 1, but instead of linking all the assets to the same class I make the base class the same class, and let the derived class be dynamically created by Flash on compile time.So the linking works, but the problem is, in my base class I have a method which does something (say an tween) on a child of the library asset. So if the assets on the stage/library are called asset1, asset2, asset3 (same name for asset name, class name, id name), each of them has a sub-movieclip called ... say 'foo'. now if I manually wrote a class for each asset, I could do 'this.foo' to play with the sub-movieclip. However since this functionality is in the parent class, I'm unable to do it.
P.S. If you're form a programming/OOP background, its basically a abstract class problem. My Base class knows how to doSomething(), but it needs aSomething, which is defined in the Derived classes. However I found out that AS3 classes don't support virtual(C++ )/abstract (Java) in the true sense of the word (unless I missed some obvious documentation).
View 3 Replies
Dec 23, 2006
Let's say i have a bunch of balls/cells. I'm having trouble figuring out how to make it so that every other ball bounces off of every other ball.
so in short, it's really one instance being able to check all other instances of the same ball class?
View 7 Replies
Jul 25, 2011
I've been hitting dead ends while programming lately all over, and I finally came to the realization all the code I have that is broken is because I don't know how to interact with instances of one class from within another. Here's the gist of what I am trying to do:
if(this.hitTestObject(targetClip)){
trace("hit!");
}
The problem is, if I address a single instance that is on the canvas, I get "access to undefined property targetClip", even though the document class can interact with it fine. If I target the class file of targetClip, I get "Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject". It isn't just a problem with hitTest either, I'm having this problem with other actions, so there is some basic syntax I'm failing to comprehend.
View 2 Replies
Nov 6, 2009
Is there a way to group a bunch of movie clip instances into a single variable? Reason is, I have a lot of movie clips acting as buttons that I have added to event listeners. All of the movie clips with do the same functions and I have a few different functions created.
For example. How can I change this
Code:
mc_aitkin.addEventListener(Event.CHANGE, changeAlpha);
mc_anoka.addEventListener(Event.COMPLETE, changeAlpha);
mc_aitkin.addEventListener(MouseEvent.MOUSE_OVER,hoverOver);
mc_anoka.addEventListener(MouseEvent.MOUSE_OVER,hoverOver);
[Code].....
View 3 Replies
Feb 17, 2009
Is it possible to create 2 instances of 1 class (for example: "Header"). Add these 2 instances to the stage on different positions. This Header class contains some buttons and what I want, is: when I rollOver one of these buttons, both buttons in the 2 Header instances are "rollingOver".
View 1 Replies
Oct 4, 2010
I have a piece of code, that moves an array depending on it's type. If the array is of TypeA objects, it will change TypeA. If it is TypeB it will change TypeB. The issue with the current code is the repeative blocks.
[Code]...
Which stops working whenever I need to access any property (user) selectedInstance.testSomething();
View 1 Replies
Sep 17, 2011
I need to get all the instances in my stage according to an especific class name. I'm doing this:
var class_ref:Class = getDefinitionByName('fran.MyOwnClass') as Class;
var element;
for (var i:uint = 0; i < this.parent.numChildren; i++)
{
[Code].....
But I want a better way (more efficiently, without checking all the MCs).
View 2 Replies
Jan 2, 2010
I'm trying to create a simple ripple effect made of circles created using the drawCircle() method. Afterwards I animate the circle by changing it's size and alpha value. The final radius of the circle and the position is random.
How do I create multiple circles/ripples?[code]...
View 7 Replies
Feb 16, 2011
Is it possible to create one or several instances of a movieclip from the library with variable names
my1_mc
my2 _mc
.........
my5_mc
so that I can make a function that will use the name of any of these movieclips.
View 4 Replies
Oct 8, 2009
I recently learned how to use gravity so I made a bouncing balls program but I have an issue with the interaction between the frame timeline code and the class.The problem is that when I create instances with a timer, I declare the variable inside the timer function. And I want to add a blackhole sort of thing when I click down on the stage but I cannot access the object from the blackhole function since it's declared inside the timer.
View 4 Replies
Aug 30, 2009
I have a class the extends a movie clip with some dynamic content in it.I need 15 instances of this class so i created a for loop for that.Im using the same variable name but im just initializing it again and again.
var thumb:MovieClip = new ThumbClass();
addChild(thumb)
my probem is that i need to find a way to control them after i created them.
[code]....
View 3 Replies
Apr 15, 2012
I got a ton of movieclips in a class. Is there a more efficient way to apply a function to every instance in the class other than this?
var textArray:Array = [
interludes.interludeIntro.interludeBegin1,
interludes.interludeIntro.interludeBegin2,
[Code]....
I have NO idea why the above doesn't work. I want to turn every single instance in the class interludeIntro invisible, but I want to turn specific instances visible later.
how to insert code on this website, pressing "code" doesn't do anything, so pardon the bad formatting)
View 2 Replies
Oct 8, 2009
Let's say I have created a class named Store. This class has several elements such as Name, PhoneNumber, Owner. I've created 2 instances of this class and want to know which values are different. So lets say that Store1 and Store2 are instances of this class.
Store1.Name = "John's Corner";
Store1.PhoneNumber = 111222333;
Store1.Owner = "John";
Store2.Name = "John's Corner";
Store2.PhoneNumber = 444555666;
Store2.Owner = "John";
[Code]...
Is there a way to automatically loop through all elements of a class instance and compare them to the same element in another class instance and return something when they differ?
This might be obvious but I can't figure it out.
View 5 Replies
Feb 23, 2011
I'm new to this OOP stuff, and I'm having a hard time understanding all of this.I'm trying to recreate in AS3.0 with classes a simple whack-a-mole game I created in AS2.0 using timeline coding.I've read through a lot of forums, but I still don't understand what exactly I'm doing wrong.Heres my setup:I have a movie clip named mrBunny (my girlfriend told me to change it to bunnies as moles were too ugly.). Now there are 6 instances of mrBunny on the stage, each named mrBunny0-5.The mrBunny symbol is linked to the com.mrBunny class.The class has a method called randomPlay(); which I use to randomize the animation times of mrBunny.I also have a button on the stage with the class stageBtn.
package com{
import flash.display.SimpleButton;
import flash.display.MovieClip;
[code].....
View 2 Replies
Dec 9, 2004
Is it possible to rename a class-instance that has already been created with a specific name?For instance:
// Step 1) Create and name class-instance
var myClassInstance_1:myClass= new myClass();
// Step 2) Change name of myClassInstance_1
[code].....
View 3 Replies
Jul 4, 2003
[Code]...
this's been bugging me, anyone know what's wrong?
View 14 Replies
Jun 11, 2009
I am making an AS 2.0 Class for polygons called "Shapes2". Shape2 is basically an array of Vectors (another Class I made) and is built using the function addPoint(x1,y1) to build the shape from a series of points. The points are then converted to vector-edges, etc etc.Here's the long and complicated construction:
Code:
var pent:Shape2 = new Shape2();
var rect:Shape2 = new Shape2();
if I comment out either instance, the other is functional when I test it. Trying to do two instances makes rect and pent point to the same array of vectors, but they keep other variables and properties separate, which means rect isn't just pointing directly to pent or visa versa.
View 1 Replies