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


Similar Posts:


ActionScript 3.0 :: Reference Movieclip Instance On Stage From External Class File?

Nov 21, 2010

I've been searching around all afternoon, and am pulling my hair out. 1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.

2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)

Basically here is the bit of code I am trying implement within Hero.as :

[Code]...

This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1. I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable? Is there a really easy way to do this with some syntax/command that I have not learned yet?

View 3 Replies

ActionScript 3.0 :: Passing A Reference To Class

Nov 12, 2009

if i have multiple movieclips on the stage and i am writing a document class and in document class i import another class and i need to pass these movieclips to that class.

View 1 Replies

Flash :: Passing Parameters To A Function Reference?

Aug 17, 2010

I'm attempting to write a performance testing function that can take any function, run it X times and spit out how long it took that function to run in AS3. I've got it working just fine if a function doesn't take any parameters but it comes up with an error otherwise.Here's the code:

public static function testFunction(targetFunction : Function, object : Object, ... parameters)
{

[code]........

View 1 Replies

ActionScript 3.0 :: Passing A Simple MovieClip Reference?

May 3, 2010

I loaded a SWF and passed the reference to a Class called Portfolio:

Portfolio.as:

ActionScript Code:
package
{

[code]....

Now I keep getting one error or another. Right now, it's telling me:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I tried extending the thing but then I got a: "1203 No default constructor found in base class" error I just want to pass a simple MovieClip reference from one class to another.

View 1 Replies

ActionScript 3.0 :: Using An External Class To Reference Functions From Another External Class?

Mar 25, 2010

I have a Main.fla which loads Main.as as its document class. In Main.as I have a public function named "Main" which runs a trace. I also have another .as file called Preloader.as, which also has a public function in it, this one named "Preloader" with simple trace in it. I just cannot figure out how to use Preloader() from the Preloader class in Main() from the Main class. Main.as loads up fine when the SWF loads and traces.

View 10 Replies

ActionScript 3.0 :: Passing Parenting MovieClip Reference To Button Event?

May 10, 2010

I'm trying to reference a movieclip that's been passed through the class primary function (constructor/instance, tried both) but can't get a button event instance to recognize it. Since the button's based around an event, I'm not sure how to pass the reference. I stripped a lot of the code, but left the function sctructure as the button events are tied into a dynamic loop structure, a main reason why I can't move the buttons to a different class.

The example looks something like this:
package {
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.events.*;
[Code] .....

I'm trying to figure out how to get the site_mc reference to the button event so it can trigger other nested movieclips inside it (gallery_mc, etc). If this were AS2 it'd be a piece of cake but now I have all these invisible walls for variable passing.

View 11 Replies

ActionScript 3.0 :: Reference Movieclip On Stage From Custom Class Of Document Class

Dec 7, 2009

Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]

View 1 Replies

ActionScript 3.0 :: Reference Movieclip On The Stage From A Class Of The Document Class?

Dec 8, 2009

Is there a way to refer to a Movieclip on the stage from a class file of the document class

Lets say I have 3 MovieClips on the stage(a Circle, a Square and a Triangle)

I have the document class which calls another class that controls the MC on the stage

Example

ActionScript Code:
package {
public class Example extends Sprite {
//Create the instance of the class being called

[Code]....

View 1 Replies

Flash :: Use A New MovieClip As A Class Or To Copy It Without Reference To Its Class?

Jul 21, 2011

I am doing a looping background with 2 identical BG movieClip (B1 and B2). Those 2 are "new" by the same class.

var B1:MovieClip = new BG();
var B2:MovieClip = new BG();

But because this BG class picture is loader from the internet and the picture is rather big. When I addressed its loading by using progressEvent. The picture is really loaded 2 times. Is there anyway I create B2 based on B1 without using new BG() again? Since it definitely makes a new BG with Loader code inside.

[Code]....

View 2 Replies

ActionScript 3.0 :: Reference External Class Using It?

Feb 11, 2009

How do we create a class file and use it in seperate flash file

View 0 Replies

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

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 :: Change A Function Reference Of A Class?

Feb 10, 2010

Ok, I have a class like this:

public class Foo extends Sprite {
public function Foo(x:Number, y:Number):void {
this.x = x;

[Code]......

I'm getting this error from the compiler: "Error: Illegal assignment to function bar". How can I change the public function bar on the fly?

View 2 Replies

AS 3.0 :: Flash - Reference Parent Class Function?

Mar 23, 2010

I am trying to run a function of the main class, but even with casting it does not work. I get this error

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at rpflash.communication::RPXMLReader/updateplaylist()
at rpflash.communication::RPXMLReader/dataHandler()

[Code].....

View 2 Replies

ActionScript 3.0 :: Reference To A Global Function With The Name Same As Class?

Feb 4, 2011

How would one get a reference of String global function (not class). According to language reference this function does exist (and I'm ready to believe it does), but, say and you have a:

Code:
function foo(bar:Function):void { ... }

How then would you pass that String to it?

View 9 Replies

Flash :: CS, Reference Root From External Class?

Dec 21, 2010

I made this class and I put it in the same package of Timeline.as (the Document Class):

package {
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Counter2 extends Timer {
public function Counter2(delay:Number, repeatCount:int=0) {

[Code]...

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

ActionScript 3.0 :: Unable To Reference Function From Non-parent Class?

Sep 19, 2011

So I am trying to access a variable that is defined within my parent code from a class which has been called from my parent code. I am using this:Code:TileCode(parent).game_quests.add_quest(0);to try to access the game_quests variable (which is defined within TileCode). However, for some reason it is not picking that up. It is working for other variables which I have called and ran in a similar fashion

View 7 Replies

ActionScript 2.0 :: Passing Movieclip Name To Function?

May 12, 2007

Here is the code that I have right now (it obviousvly doesn't do what I want it to):

Code:#include "lmc_tween.as"
orig_x = mc_01.black_bkg._x;
orig_y = mc_01.black_bkg._y;
function buttonIn() {

What I want to be able to do is pass the name of the movie clip (ie mc_01, mc_02...) to the function, and have the function effect that particular movie clip. I had this code that didn't work

[Code]...

View 6 Replies

ActionScript 2.0 :: Passing Movieclip To Function

Oct 16, 2007

[code]how to get my target variable in my function to work? I am trying to make it the movieclip in which to make the text field.

View 2 Replies

Flash :: Loading External SWF W/ Stage Reference In Class

Nov 17, 2011

I'm unable to load forces.swf (assume I can't edit it, as I don't have the source code) through an external swf, due to Stage reference in the base class how would I go about loading it (and any other possible SWF) without errors being thrown?

Here is a link to the problem I am trying to fix:[URL]..

View 1 Replies

ActionScript 3.0 :: Loading External SWF With Stage Reference In Class?

Nov 17, 2011

I'm unable to load forces.swf (assume I can't edit it, as I don't have the source code) through an external swf, due to Stage reference in the base class.

How would I go about loading it (and any other possible SWF) without errors being thrown?

Here is a link to the problem I am trying to fix:

[URL]

View 14 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 :: Getting A Null Reference Of A Visible MC When Calling Function From A Class?

Jan 11, 2010

I've basically got an MC (menu_mc) that is on the first frame of the main timeline. I want menu_mc to call functions on the main timeline depending on its status. When the function is successfully called, I want to move menu_mc, however I get a null object reference despite the object menu_mc being visible on the stage.

here is the menu.as code

Code:

package {
import flash.display.MovieClip;
import com.greensock.*;
import com.greensock.easing.*;

[code]...

As you can see from the commented out lines, I've tried doing the same thing with eventDispatcher, but have been unable to listen to the event from the main timeline.It seems as if the function is being called before menu_mc is placed on the stage, despite the ADDED_TO_STAGE eventListener.

View 9 Replies

ActionScript 3.0 :: Reference A Movieclip Inside Another Class

Dec 13, 2010

I'm making a sidescroller for school and im trying to get my hit test working.

I'm having trouble because I'm not sure how to properly reference an movie clip that i added in my game engine (zombie_mc), to a seperate class for my bullets the code for adding my zombie to the stage

Quote:

if (zombieTime < zombieLimit)
{
//if time hasn't reached the limit, then just increment
zombieTime++;

[Code]....

View 4 Replies

Flash :: Passing A MovieClip To An External Script?

Nov 4, 2010

I've created a class that contains all of the movie clips from the stage. These variables are referring to the instance's name on the stage. Everything seems fine as long as I keep all of my functionality in a single class. However, when I try to use another class to manage the properties of a movie clip, I run into resource clean up issues.

//File (MainScreen.as)
import utils.Container;
class MainScreen extends MovieClip

[code].....

View 1 Replies

ActionScript 3.0 :: Reference Sprite Or Movieclip In Document Class

Dec 9, 2009

How do I reference MovieClips or Sprites created in the Document class from a custom class?[code]But I have a lot objects I want to reference so using the above method would take to long.I know I can do this to reference a MovieClip on the main stage from a custom class.[code]Would referencing the sprite created in the document class be similar?

View 1 Replies

ActionScript 3.0 :: Reference Document Class From Inside MovieClip?

Aug 11, 2009

I'm trying to reference the document class from inside a MovieClip that's dynamically added to the stage. I'm using this script:
Code:
documentClass(root).someVar;
Where "documentClass" is the name of my class (duh).

This works fine, however -- when I move the class file into a folder (and make all the necessary revisions to point to the file) this doesn't work (everything else still does). I get a "not found, possibly undefined method" error. The class name is technically com.documentClass now, how do I point to that? The file is an Adobe Air file.

View 5 Replies







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