Actionscript 3 :: Refer To Multiple Instances Of A Single Class?

Jan 23, 2012

So I know how to target a specific instance using MovieClip(root).objectName which I think is nasty way of referring to it anyways, but right now I'm trying to make a fighting stick-figure game and I can only refer my code to one NPC right now using an "enemy" class but I would like it if I could spawn multiple NPC's at once using the enemy class and instead target the enemy class instead of the instance itself while still having the NPC instances being unique so when I hit one they don't all get hit.

View 1 Replies


Similar Posts:


Multiple Flash Instances Or A Single One?

Mar 25, 2010

I have a doubt: When you open various flash pages in tabs, for example in Firefox, all those pages share the same Flash instance or each one use an instance of flash??

View 1 Replies

ActionScript 3.0 :: Multiple Mc Instances (different Names) Into Single Variable?

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

ActionScript 3.0 :: Applying Single Color To Multiple Instances Of A Mc?

Nov 12, 2009

I was just wondering if there is a way to simplify this code. I have 3 identical movie clips and I use actionscript to alter the color to the same color. Right now I use 3 different colorTransform variables. Could I just use one since its all the same color? How would it look like.

So far, naming all the movie clips the same instance name did not work. Is there a better way?

Code:
var color1:ColorTransform = button1.transform.colorTransform;
color1.color = 0x99628B;
button1.transform.colorTransform = color1;

[Code].....

View 0 Replies

ActionScript 3.0 :: Multiple Instances Of Single External SWF - Loading PDFs

Nov 13, 2008

I'm trying to make a custom PDF viewer in flash. Currently I've found a freeware server side script that will convert the PDF into a single Flash AS3 SWF file with each page from the PDF on a new frame. Loading this is no problem. I can navigate through the pages with a simple gotoAndStop(frame); call.

Here's my problem: I want to display more then one page at a time. I want to be able to scroll through the pages and see one page going off the top of the screen while the next is coming up from below. So, how can I put multiple instances of this SWF on the stage? Do I have to load it with a loader and URLRequest multiple times? or can I make copies of the one I've already got somehow?

I still have to load PDF in flash, but if I could find a better way to create an SWF out of the PDF. I'm currently using pdf2swf and it's great and all. Maybe there is some functionality to that program that I'm missing. Some other way to organize the PDF pages in the SWF.

View 8 Replies

ActionScript 2.0 :: Multiple Instances Of Class?

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

ActionScript 3.0 :: Create Multiple Units Of A Single Class?

Mar 3, 2011

How do I create multiple units of a single class, but still be able to target it individually?

For example, I want to create 5 instances of Apple(), but I want to move the 3rd instance of Apple to a specific location. How can I target the 3rd one?

View 5 Replies

ActionScript 3.0 :: How To Avoid Multiple Instances Of A Class

Apr 14, 2011

new a class [code]Now ,I want call function newCourse many times and don`t new class again.

View 2 Replies

ActionScript 3.0 :: Multiple Instances Of A Class Having Conflictions?

May 22, 2010

I have a "Window" class, which will create a window with the parameters you specify. One of the functions inside of that class is to place an element inside the window - something such as a text field, button, etc.

Now my issue. I've created two windows with different names, slightly different parameters, etc. I am adding a text field to each one. On the screen, both text fields show up (have borders enabled). I can refer to both windows using getChildByName(), but for one reason or another I can only find one text field using the getChildByName method. The other one will give me an error.... "Cannot access a property or method of a null object reference."This is the code that I use to add a Text Field, keep in mind this is inside the window class:

ActionScript Code:
public function element(builder:Object) {
switch (builder.type) {
case "static_text" :

[code]....

This code is repeated twice, for different windows. The only thing that's different about them is their names, which are slightly different. It seems that whichever text field I add first gets to stay, while an subsequent ones appear on the screen, but I cannot refer to them. I've tried switching around the window definitions and that does seem to be the case.

View 7 Replies

ActionScript 3.0 :: Generate Multiple Class Instances?

May 27, 2009

This is how I create a Class instance of Container_, called "wall0":

var wall0:Container_ = new Container_();

I need dozens of these, numbered sequentially. Is there a syntax available that would plug into a while statement? Like:

var w:Number = -1; while(w < 100){var (wall+[w]):Container_ = new Container_();}

View 12 Replies

IDE :: Multiple Instances Of Movie Class With Same Variable Name

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

ActionScript 3.0 :: Loading Multiple Sound Files With A Single Class?

Nov 11, 2009

I am working on a simple game for kids. The game revolves around the alphabet and it is all voiced. So I have a good number of sound files that I need to call on at any given moment.In AS2 I would just link all of the sound files to variables at run-time and have them ready to play when the interaction dictated it.... with the way "linkage" has changed in AS3... I feel like it would be a bad idea to have over 50 different class files (one for each sound file) so I am looking for a cleaner solution... that and I am guessing that having redundant class files misses the point.I haven't had much luck finding a forum post or tutorial that talks directly about this type of issue but the idea is a little foreign right now so I am sure I have stared directly into the gold mine and not noticed. I am very interested any thoughts or links on the subject.

View 1 Replies

Flex :: Handling Multiple UIComponent With Single Skin Class

Aug 4, 2011

I have created a simple mxml file with code as follows:
<s:application..........>
<s:BorderContainer>
<s:SkinnableContainer id="firstRow"/>
<s:SkinnableContainer id="secondRow"/>
<s:SkinnableContainer id="thirdRow"/>
</s:BorderContainer>
</s:application>

Now I want to apply different font size, font color and font type and background color on each row i.e each of the three skinnableContainers.Currently I have defined 3 different skin classes for each of row but I think this is a bad programing. I should create a single skin class for outermost container i.e BorderContainer and any how provide different fonts and background color to all the 3 child containers through that skin class. So, is it possible that I can create single skin class that can provide different decorations to each of the child container.

View 1 Replies

ActionScript 3.0 :: Use Multiple Instances Of The Loader Class With One URLRequest?

Apr 21, 2010

I'm creating an image loader with a specific effects that requires layering multiple masks over the same movieclip. in the timeline it looks like this:

What I want to do is add an instance of the loaded image into each of these masked movieclips. I'm trying this:

create a new instance of the loader and store it in an Array

Code:
for (var j=0; j<allThumbs.length(); j++) {
imgLoader = new Loader();
img_arr.push(imgLoader);

[Code]....

The only way I've been able to get this to work is to create an entirely new Loader object for each movieclip instance. Doing it this way loads the same image 4 times... that's not acceptable.

how I can store the image that is loaded and reuse it in the different movieclip instances?

View 1 Replies

ActionScript 2.0 :: Array In Multiple Class Instances Aren't Individual?

Jul 7, 2009

The code works fine, but I am getting unexpected results; the array seems to be shared across multiple instances of the same class? I've coded an example to highlight what is happening:

Code:
import myClass;
var instance:Array = new Array();
instance[0] = new myClass;

[Code].....

keep all objects/arrays separate across multiple instances of the class.

View 5 Replies

ActionScript 3.0 :: Sub-class Refer/communicate With Super Class?

Jun 22, 2010

i have recently started a project that would require writing a set of classes and a small API.i know some basics of inheritance and extending classes but i still have some questions.

1) how should sub-class refer/communicate with super class.i think that dispatching events is the way to go but i have no experience on that. i have previously done it by having a parent set up a reference to itself in a subclass e.g

ParentClass.addChild(SubClass);
SubClass.myParent = ParentClass;

//i know that there is already a "parent" keyword in flash objects if i extend one but is that a decent way to communicate with super class

e.g SubClass.myParent.removeChild(this);//sounds a bad call

//but is it better if i dispatched an event that calls the removeChild() in the parent.i have is about dispatching events in a class that is likely going to be extended.

ActionScript Code:
public class Button
{
//add event listeners[code]....

//now if i extend the Button class into another class, let say ControllerButton and want that button to dispatch different event. e.g ControllerEvent, i am forced to override and rewrite all the common stuff in the handler functions.how to avoid having to override allot of common stuff.

View 3 Replies

ActionScript 2.0 :: Multiple Swf's Refer To One Xml Doc?

Nov 23, 2007

Is it possible to have one xml doc for more than one swf, so that i would only need to edit one xml doc as opposed to 12?

View 4 Replies

IDE :: Changing Colors Of Two Instances In A Single Click?

Apr 8, 2009

Can i change the colors of two mc's if i just click one of them? i tried to put the other mc (btn02) inside the function but only btn01 changes color when i click it.

here's the code;

var controlcolor:Color = new Color(btn01);
var controlcolor2:Color = new Color(btn02);
btn01.onPress = function(){
controlcolor.setRGB(0x000000);
btn02.controlcolor2.setRGB(0x000000);
}

View 1 Replies

Flex :: 'fake' Multiple Series For Single Chart Or Same DateTime Axis For Multiple Charts?

Apr 11, 2011

I want a chart that has several separate series running in rows across. They are largely separate charts and should not overlap, but all share the same horizontal datetimeaxis. They don't share the same y-axis, however and that's where I'm getting stuck.I have tried having a linechart series and then a plotchart series, but it will only allow a single <mx:series> per chart without having them inside the same series which as far as I can tell will place the charts on top of each other in the z-axis. I can stack them and have them completely separate charts, but it was proving to be somewhat irritating having them align correctly.

Is there any reasonable way of combining multiple charts into one like this? Basically having rows in a table where each row is a different chart but the columns are consistent. or am I going to be best served just by stacking separate ones? an illustration of what i'm going for is here: http:[url]........

View 1 Replies

ActionScript 3.0 :: Refer To The Stage From A Class?

Jun 7, 2010

I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this:  obj.x = stage.stageWidth / 2;  I get a message that I Cannot access a property or method of a null object reference

View 4 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip?

Jun 19, 2011

I have the class avanzada.as:

package
{
import flash.display.MovieClip;

[code]........

View 2 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip

Jun 15, 2011

I have this class:

package {
import flash.display.MovieClip;
import flash.filters.BitmapFilter;

[Code]....

Appears this error message:

"1137: Incorrect number of arguments. Expected no more than 0."

I try with:

new MovieClip(this.root).cambiaBlur(gift);

but also fails.

View 1 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

Flash :: Refer To Text Field By Class Instance Name?

Jun 17, 2011

I need to populate the text field tField (defined on stage) that resides inside ParentClass (MovieClip with same class name). I want to be able to set tField.text to whatever I want from AnotherClass. How do I do it?

View 2 Replies

ActionScript 2.0 :: Refer To A Variable In A Class File Separate From The Other One?

Feb 24, 2010

Is it possible to refer to a variable in a class file separate from the one you are working in? Say Class1.as had a variable named "exampleVar", and in Class2.as you wanted to put something like "exampleVar++;". Is this possible and if so how would it be achieved?

View 1 Replies

ActionScript 3.0 :: Multiple Scenes With Multiple Instances Of The Same Slide Show

Sep 8, 2009

Ok so here is my XML slideshow Actionscript:

ActionScript Code:
stop();
var xmlRequest:URLRequest= new URLRequest("graphicImages.xml");
var xmlLoader:URLLoader = new URLLoader(xmlRequest);

[Code]....

So I figured that the coding of separate scenes would work independently of one another, but I guess I was dead wrong, because when I apply this to a different scene and change the XML path for a different set of images, I get all sorts of conflict errors when I test the entire movie. I have my flash film set up so that each link send the user to a different scene, which plays a unique intro for each, and then the slideshow appears on screen and the viewer can navigate the images.

Is there a work around for this? Or am I going to have to break my flash movie into separate movies? Or should I just add a suffix to all my vars and functions so that they are unique for each scene?

View 1 Replies

ActionScript 3.0 :: Refer To A Class Linkage Set In Library From External Code?

Jan 12, 2011

If one uses [Embed] to refer to external graphic assets its easy to instantiate and use them.However, I've got a png in an Fla, with the Class identifier set to "Symbols", Base class is BitmapData.I need to instantiate it like this:

var symbols:BitmapData = new Symbols(1, 1);
addChild(new Bitmap(symbols));
 
Of course the compiler complains about a call to a possibly undefined method Symbols.For a temporary fix I guess i'll put the graphic external to the swf, but for this project it needs to be in the library along with everything else.

View 9 Replies

ActionScript 3.0 :: Main Class Path Without Carring Around Instance Refer?

Jan 6, 2007

I spent my holyday in studing new Flash 9, very good, powerfull but I doesn't find anymore my root, in teory is transformed in stage.root but it doesn't work.I want to understand if I make a mistake in my code or in my approach.I make a simple example with a few object containers.In the firsts lines of the constructor of the mail class I create the style class named tf and then the interface class called interf.Here is my class

Code:
package test {
import flash.display.Sprite;
import test.tf;[code]....

how to get the tf1 Object that as to be in stage.root.mytf.tf1 as some documentation say? If you doesn't comment that line you have an error. Obviously you can carry with you the object because is a small object with a few nidification but It seems to me very very bad for performance and code.

View 2 Replies

ActionScript 3.0 :: Refer The Main Time Line Or Stage From Inside The Class?

Apr 13, 2009

how to refer the main time line or stage from inside the class.

class sample{
function sample(){
trace(root); // its displaying as null
}
}

in actionscript 2 we use _root for this... in actionscript3 if we use root...why its not working inside the class....?

View 1 Replies

ActionScript 2.0 :: Make Class Instances Into Listeners And Broadcasters From Inside Each Class?

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







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