ActionScript 3.0 :: Passing An Object To A Class Function?

Apr 27, 2011

I keep getting this error #2007 i want to parse the stage and pass a bullet object to a class function that function is called every ENTER_FRAME in the class itself

because the bullet object is added to the stage and on the bullet, there is a event listener to call a function in a class every ENTER_FRAME

but now i want to delete this bullet as it leaves the screen on the top because bullets in this game can only fly upward.

this is some of the code so far in the class itself:

ActionScript Code:
package classes {
import flash.media.Sound;

[Code].....

View 5 Replies


Similar Posts:


ActionScript 2.0 :: Passing Variables Class And Function?

Feb 8, 2006

when I have access to my variables. I have the the follow code:

class Slider {
var myVar = 4;
function Slider () {[code]....

The slider function is being called first to update the myVar value then the findValue function is called. How do I get the find Value function to output 6 ? I want a function that updates the main classes' variable so thet I can use it from any function.

View 1 Replies

ActionScript 3.0 :: Inheritance / Interface - Override A Function That Return An Object Of Class A And Make It Return An Object Of Class B Which Extends A?

Aug 4, 2009

I'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):

[Code].....

View 3 Replies

ActionScript 2.0 :: Flash8 - Passing MC Coordinates To A Function Within A Class

Jul 21, 2009

I have a class named Test in Test.as file :

Code:
class Test{
public function set movePlayer(_Playah:MovieClip):Void {
trace(_Playah._x);

[Code]....

and when I "run" this function in my .fla file, its says "undefined" (for this position) how to "pass" MC informations to a function inside a class (x,y coordinates, rotation..) although when I trace only "_Playah" it shows the correct name of MC i've passed to it.

View 2 Replies

ActionScript 2.0 :: Delegate Class - Passing Parameters With Function?

Jan 31, 2008

I am wanted to know how can i pass a parameter to the function which I'm calling using Delegate class. I know to pass params having static values such as true / false or a static string "hello".

Code:
var myFunc:Function = btn.onRelease = Delegate.create(tihs, releaseHandler);
myFunc.str = "hello";
function releaseHandler()

[code]....

Here str can be retrieved as 'arguments.caller.str' inside the function.But in case i want to pass the reference of the 'btn' button. Then how can i do this ?

View 3 Replies

JavaScript :: Passing Object To Flex Using Callback Function

Jul 11, 2011

My web application pass a javascript object to flex application using addCallback function.
when the flex application is in modal dialog in safari browser, the object in the flex application is null and when I open the flex application just in a new window, the object is passed correctly. But, I need the showmodaldialog to show the flex application.

The flex code:
ExternalInterface.addCallback( "handleEvent", handleEvent );
override public function handleEvent( event:Object ):Object {
Alert.show(String(event)); .....

View 1 Replies

ActionScript 3.0 :: Passing Entire Doc Class As Function Argument - Good Or Bad?

Sep 8, 2009

I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I'm wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.

EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER_FRAME scrolling function that's 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it's impractical. So my question is: good or bad practice to pass the entire class?

[Code]...

View 4 Replies

ActionScript 3.0 :: Passing A MovieClip Reference To A Function In An External Class?

Mar 25, 2010

I want to create a MovieClip, pass this MovieClip to a function in another class where it will be modified.The problem is, when I pass the MovieClip as a parameter to a function and start making changes, the changes are only made locally. The "copy" of the MovieClip inside the function gets changed, but the "real" MovieClip back in my main game class remains unchanged. Here's the code from my Main class:

Code:
var resourceLoader:ExternalResourceLoader = new ExternalResourceLoader();
var myMovieClip:MovieClip;[code].....

View 4 Replies

Flash :: Access Object Property Or Function On Extended Class That Isn't In The Super Class?

Jan 29, 2012

If I have three classes:

public class Example {
public function Example () {
}[code]............

You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like

function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()

View 3 Replies

ActionScript 3.0 :: Testing Hit Object Function To Many Object In Same Class

Oct 20, 2010

im creating multiple objects (the number is dynamic)they move randomly, but i want dont want them to be able to pass thru each other.i'm having dificulty on writing the hitTextObject code because I dont know how to refer the other objects.[code]

View 5 Replies

ActionScript 3.0 :: Make Self Destruct Function For Class Object?

Feb 6, 2010

How can i make a self destruct function for class object?[code]

View 3 Replies

ActionScript 2.0 :: Scope : Function Call From Inside An Object In A Class?

Feb 7, 2009

I have an object and would like to call a function from it, which the way I am trying to do it, does not seem to work. Here is what I have:

Code:
private function setTimer():Void
{

[code]......

View 0 Replies

ActionScript 2.0 :: __proto__ - Assign A Class To Each Object In Function Of An Array?

Sep 25, 2007

I'll try to make this as clear as possible. Let's say i have 4 "classes".

[Code]...

Let's say now i use a loop to create 8 obj. I'd like to assign a class to each obj in function of an array like : array = [class1, class2, class1, class3, class2, class4... ] so obj0 class' should be array[0]

View 4 Replies

ActionScript 3.0 :: Execute Callback Functions Dynamically By Passing A Function In As An Argument To Another Function?

Apr 21, 2010

How do I execute callback functions dynamically by passing a function in as an argument to another function?

Look at this example:

Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {

[code]....

View 2 Replies

ActionScript 3.0 :: Passing Variable From Document Class To Movie Clip Class?

Oct 12, 2010

i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!

ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";

View 1 Replies

ActionScript 3.0 :: Passing Data From Document Class To Base Class?

Mar 1, 2011

I created a movieclip with a star. Then, I creates a document class and I named it as Main.as.

In that document class I wrote:
package
{
import flash.display.*;
public class Main extends MovieClip

[Code]....

I´m not posting here all the code, but you can easily see that I´m using x_origin and y_origin variables to keep the original position of the movie clip. I will use them to move the star back to the original position.
 
The problem is that instead of being 20 and 30 respectively, tracing them I see that they are both ZERO. So when I drop the star, instead of going to x=20,y=30 it moves back to x=0 and y=0. I´ve to get the star position relative to stage, but I can´t find anyway!

View 4 Replies

ActionScript 3.0 :: Passing A Variable From The Document Class Into A Custom Class?

Dec 28, 2009

I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.

Here's what I have so far:

DOCUMENT CLASS

ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;

[Code].....

As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?

View 6 Replies

ActionScript 2.0 :: Passing Variable To Function Inside Function?

Sep 16, 2009

I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).

ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",

[code].....

View 1 Replies

Passing Name Of Video To Be Loaded From Document Class To Another Class?

Aug 6, 2009

I've got a document class (EgoGame.as) and another class (Ball.as) which has been duplicated to deal with several different video pieces. Inside the document class is a list of 'if' statements which decide which video should be played. At the moment I'm doing it the old fashioned way whereby if the condition is true....it tells the relevant Ball class to gotoAndPlay a certain frame within the linked movieclip...

[Code]...

View 1 Replies

ActionScript 3.0 :: Use A Function From A Doc Class To Call A Function To Work On In Another Class?

Dec 15, 2009

how do use a function from a doc class.... to call a function to work on in

[Code]...

View 2 Replies

ActionScript 3.0 :: Turning A Object Of Class A Into An Object Of Class B Extends A?

Jul 20, 2009

I have a class CoverPoint extends Pointwith some extra function.except for that ther is no difference. I would like to use the functions of Point with a return value of Point, to calculate those CoverPoints.Can i turn the return value into CoverPoint (since all the vars are the same, there shouldn't be a problem with that, right?), so that it can be stored in my var cP:CoverPoint;

View 2 Replies

ActionScript 3.0 :: Passing A Var From One Function To Another?

Apr 20, 2011

I im trying to pass one a var from one function to another, Im trying to pass 'THICKNESS' from 'moveMouse' to 'mouseDown'.

ActionScript Code:
var THICKNESS:uint = 1;
ActionScript Code:
function mouseDown(_x:Number, _y:Number):void {

[Code].....

View 4 Replies

ActionScript 3.0 :: Passing A Function Around?

Feb 24, 2009

so, i think it's just cause it's the end of the day and my brain wants to quit, but i would like some input.

im trying to pass a function to a question box that when you click the YES button the function passed in will fire for some reason im having a hard time holding the function until the YES is clicked.

here is what i got Code: //the call that opens the choice box and sets the info the gui_obj part is cause the //funciton is in a separate class file gui_obj.displayChoice("Add the cell phone to your inventory?", "YES", "NO", gui_obj.addToInventory(item))

[Code]...

View 5 Replies

IDE :: CS4 - Passing XML File Name To Function

Aug 19, 2010

I'm new to AS3, I have an index.swf that loads thumbnail images from this file (projects_list.xml). When the user clicks on a thumbnail image I want it to pass the selected thumbnails "link" node information to the callFull function. You can see that I have managed to get it to work when I use the real path name. I just can't figure out how to pass the link node text.

Projects_list.xml file set up
Code:
<project id="0" name="Con" thumb="portfolio/images/con/thumbs/web_1_200pix.jpg" htm="" link="portfolio/xml/desc/desc_con.xml"></project>
desc_con.xml file set up (details file)
[Code].....

View 1 Replies

Professional :: Passing URL From FLA To Class

Jul 24, 2010

I have a class that works with an external swf with play, pause and slider. Now that I have all that working, I'd like to be able to pass the URL of the external SWF to the class from the main fla AS. I managed to use a 'set' inside the class to retrieve the name, but it apparently doesn't trigger until after the external SWF gets loaded.

Code snippets follow:
CntlClass:
public var loader:Loader;
private var _urlName:String;
public function CntlClass() {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded);
loader.load(new URLRequest(_urlName));
public function set urlName(value:String):void {
_urlName = value;
}

Main FLA file - other than a controller (cntl_mc) containing a play button, a pause button, and a slider, the only thing in the FLA file is this code in the first frame:
cntl_mc.urlName = "extswf.swf";

View 5 Replies

ActionScript 3.0 :: Passing Class To Xml?

Oct 24, 2009

I am making a game project using tiles. I want to ask bout the xml.

I know how to load an xml data into the stage by using one class from library

However, rite now, I have 3 customer_mc with class for each: char1,char2,char3

And i have this xml data called customer_xml that contents the customer name,order and payment. So far i know how to call one class and do a for loop but i cant find a way to call three classes and put it into the for loop.

function init(xmlString:String):void {
customer_xml = new XML(xmlString);
for (var i:uint = 0; i<customer_xml.customer.length(); i++) {
var customer_mc:char1= new char1();

[Code].....

how can i put three customer mc into the for loop? Do I put it in an array?

Second, I don't want it to be put randomly on the stage but only on the right corner of the stage. Is that mean, I put a precise coordinate for the customers mc?

View 0 Replies

ActionScript 3.0 :: Passing Value To Different Class

Nov 23, 2009

I have those 2 function inside a class named MenuScreen.as, What I want to do is send a value true or false to another class named Game.as.If the user clicked mouse icon the value must be true and if user clicked keyboard icon it must be false.[code]

View 11 Replies

Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

Jun 16, 2011

I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.

I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function

var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:

[code].....

View 1 Replies

ActionScript 3.0 :: Passing A Variable Into A Function?

Mar 19, 2009

I have 3 movieclips in the Libarary, called (both by name and class) section0, section1 and section2.This works for instance to attach a movie clip to the stage:

Code:
var myMovie:MovieClip = new section1;
addChild(myMovie);

[code].....

View 2 Replies

ActionScript 3.0 :: Passing Variable To Function?

Feb 21, 2011

Trying to create a random movement for fish MCs:

//----------------------
var deg2rad:Number = Math.PI / 180;
var speed:Number = 1;// set to speed you want
var numFish:Number = 4;

[Code].....

Problem I have is that they all move to the same angle (the last one created).

How do I pass the different "my_angle" values to the "move_me" function...?

View 7 Replies







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