ActionScript 3.0 :: Calling A Function In The Document Class Form Another Class

Mar 9, 2011

I'm trying to have a class reference a variable within the document class and have scoured the web but can't seem to find a solution. It seems relatively simple, but is a major stumbling block for me.

I want the variable in the doc class to increment each time a draggable object is within bounds and snapped to a box in the subclass. By tracking successful snaps, the objects will be placed one under the other each time.

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Calling Function In Custom Class From Document Class?

Feb 24, 2009

I keep getting an "undefined property" error when I try to call an external function from within the Doc class. I added the error message to the Doc Class below so you can see where it occurs.

If I take the code from the Tooltip.as below and place it on the FLA's main timeline I can get things working fine, but I would like to move all script to classes. The document class structure looks like this:

Drag_and_Drop.as

Code:
package {
import Tooltip;// Import custom class
public class Drag_and_Drop extends MovieClip {

[Code]....

I realize that I could just combine all the code in the Doc class to get it working, but it would be nice to separate out this particular code which has only one use.

View 4 Replies

Actionscript 3.0 :: Calling Document Class Function From Another Class?

Jun 12, 2009

I want to call a function that is inside in a document class from another class how can i do this ??

View 1 Replies

ActionScript 3.0 :: Hang Calling Function After Document Class' Event.ADDED?

Aug 24, 2010

I was trying to load an external SWF (that contains the below code in its document class) with the Loader class but i keep on receiving Error #1009: Cannot access a property or method of a null object reference. So i tried to use the event listener Event.ADDED in MyDocumentClass constructor of the external SWF to let the document class be part of the display list before i invoke createRandomGraph. But when i place createRandomGraph( ) inside onStageReady, The compilation process hangs. When i leave the createRandomGraph( ) inside the constructor, it works perfectly as stand alone but will produce Error 1009 if loaded within the loader SWF

public function MyDocumentClass( )
{
this.addEventListener(Event.ADDED, onStageReady);

[code].....

View 3 Replies

ActionScript 3.0 :: Flash - Calling Method On Document Class From Another Class?

Jul 5, 2010

I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).

View 6 Replies

Actionscript 3.0 :: Calling Method On Document Class From Another Class?

Jul 6, 2010

I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).

I have tried everything and nothing seems to work. How do I do this?

View 8 Replies

ActionScript 3.0 :: Calling A Function From An Extended Class Inside A Top Level Class

Sep 23, 2009

package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt

[Code].....

I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.

So I added the if (defender._hp <= 0) this.win() which gives me the following error:

1061: Call to a possibly undefined method win through a reference with static type Character.

"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name

Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?

View 6 Replies

ActionScript 3.0 :: Call Function Of Document Class From MovieClip Class

Aug 8, 2008

How can I run function of the main document class from a class of a MovieClip? I usually just used MovieClip(parent).function(), but now my MovieClip has another parent. Or what do I have to pass to the MovieClip class when creating the MovieClip to acess the main document class?

View 9 Replies

ActionScript 3.0 :: Flash Call A Function From The Document Class In Another Class?

Apr 20, 2011

I have a Document class that instantiates a class named Other. I need to call a function in the Other class from the Document class.I'm getting this error: Call to a possibly undefined method OtherFunction through a reference with static type Other.I have read online that you need to use make the functions static or use a getter function but I'm unclear how to do that. I haven't been able to make it work and I feel like i'm missing something fundemental with this problem.below are simplified versions of the classes.

Document class

Code:
package {[code]......

View 1 Replies

ActionScript 3.0 :: Calling A Function Located On The Main Class From A Sub Class?

Nov 21, 2009

I'm not sure that I'm on the right track here. I've got what is essentially a 'gateway' movieclip and depending on the CLICK a corresponding movieclip (form) is loaded -- these all being in their own AS file. There are multiple corresponding pages that will all load/close in their own fashion but the 'gateway' will reload in it's own function-- consequently, I have this function on the main_AS.  Can I trigger this function from the sub class or do I need to move the 'reload' function to a 'reload' class.

View 2 Replies

Actionscript 3 :: Flash - Calling A Function From A Class Within A Separate Class?

Feb 4, 2012

I've been searching around trying to work this out for a while now. There's been various ideas popping up, like dispatchEvent etc but nothing that seems to be a clear, simple way of doing this.What I'm trying to do is call a function from a class seperate (but in the same folder as) my document class.Specifically, I want to 'spawn' an object and run a function within that object's class from my Main.as.The snippet I have at the moment is as follows;

In Main.as:
var object:class_Object = new class_Object();
object.spawn();

[code].....

View 2 Replies

Flash - Listener In Main Document Class For Custom Dispatch Event From Another Class Does Not Respond Or Call Function?

Apr 1, 2011

I have a document class called Main.as In the class constructor I have the following listener:

enter code here
var listeningFORModeChangeToStudent:Sprite = new Sprite;
listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp);
addChild(listeningFORModeChangeToStudent);

[code]....

In a third class I make a call to the despatcher in the previous class:

enter code here
var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent;
ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();

I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?

View 1 Replies

ActionScript 3.0 :: Class Calling Function From Another Class?

May 27, 2010

I have a two classes. One is linked to a menu and controls that. The other is linked to a 'viewer' movieclip. At the start (in the contructor function of the classes that relates to that mc) the 'viewer' mc feeds off an XML document, and an image is loaded into itself. When I click on a menu tab I want the image to change.

Both the viewer mc and the menu mc are on stage already. I tried to import the viewer classes into the menu class...

[code].....

View 6 Replies

ActionScript 3.0 :: Class Calling A Function In Another Class?

Oct 19, 2010

I;m converting some of my as2 classes to as3 and have run into a problem where my ships class cannot seem to call my vectorGraphics class. They are in the same folder (sprites).

The basic flow is this: On the main timeline I instantiate Ships and vGX.

ActionScript Code:
import sprites.ships;
import sprites.vectorGraphics;

[Code].....

View 2 Replies

ActionScript 3.0 :: Calling A Class Function Within Another Class?

May 8, 2010

I've been searching around the forums to find a solution of this problem. I have two classes: Monster and Player. Constructors are defined and the classes by themselves apparently works. My problem is that I want to get player.x inside the Monster class.

[Code]...

View 5 Replies

ActionScript 3.0 :: Calling Document Class Variables In A Movieclip

Feb 25, 2010

I have a variable, we'll call it helloNurse, defined in the document class, we'll call it Joy, as a public variable. Meanwhile, I have a movieclip within the FLA that uses that class as its document class that, simply put, needs to access that variable. I had read up that the following SHOULD work:

[Code]...

View 12 Replies

ActionScript 3.0 :: Creating A Sprite And Calling It With Document Class

Dec 14, 2009

I want a cass using drawing API which will create a sprite with 2 levels...(item.addChild(sprite.1)......... addChild(item))
 
I want a document class to call this sprite and place it on the stage for animation...
 
how to create a multilevel spirte and then instantiate it using doucment class.

View 2 Replies

ActionScript 3.0 :: Calling NavBar From Main Document Class

Jul 8, 2009

I am trying to rebuild an AS2 navigation in AS3. I built a button class (PortfolioNavItem.as) and a navigation bar class (PortfolioNav.as). This works if I use PortfolioNav as the Document class. However, I want to do things the proper way and call PortfolioNav from a Main document class (Main.as) but when I try it I keep getting that Error #1009.

Main.as
package com.tagehaun {
import flash.display.Sprite;
//import com.tagehaun.PortfolioNav;
public class Main extends Sprite {
//public var portfolioNavItem:Sprite = new Sprite();
public var portfolioNav:PortfolioNav = new PortfolioNav();
[Code] .....

View 0 Replies

Actionscript 3 :: Use Flash Document Class Only For Simple Form?

Dec 19, 2010

I'm very beginner in Flash. I'm trying to use document class only. I created a textBox and setting some value with

textBox1.text = 10;

When running, the stage flickers.How can I avoid this flickering effect without using code in timeline but only in document class ?

Update: Would like code in both cases:

all programmatically (no objects on stage at design time)put elements on stage with no actionscript in timelines and control them in document class with actionscript.

View 2 Replies

ActionScript 3.0 :: Flash - Dispatching An Event From One Document Class And Listening For It Via Another Document Class?

Dec 14, 2010

I am dispatching an event from one document class and listening for it via another document class.My code in class A.

Code:
this.dispatchEvent(new MYEvent(MyEvent.APERTURE_DONE));
trace("Dispatching APERTURE_DONE");

my code in class B.

Code:
addEventListener(MyEvent.APERTURE_DONE, onDoorsOpen,true);
trace("Lisetning for APERTURE_DONE");

[code]....

My listener is registering before the event is dispatched, based on my output window, however I never get the "Open Doors" trace statement to fire.

View 2 Replies

ActionScript 3.0 :: Reference Main Document Class From Document Class Of Loaded Swf

May 7, 2011

I have a FLA (say Main.FLA) document class with a child MovieClip on the stage: into the child MovieClip I load other swf files: each of the files contains its own Document Class (every swf is a somewhat independent application, say quizzes and so on).For some reason I must use the Main document class to store data (scores or so) from the child swfs loaded into the Main swf. HOW do I reference the Main class? I can't find a way.[code]and dispatch an Event this way from the loaded swf document class to the Main class:[code]Now, first of all I don't know if this could even work. Secondly, I tried to make it work by adding an event listener to my Main class but id did not work.

View 9 Replies

ActionScript 3.0 :: Moving Document Class .fla Cannot Find The Document Class - WTF?

Sep 22, 2008

So I had a working .fla, with a document class package in the same directory. Everything was fine, until moving both to a new directory, now the fla cannot find the document class. WTF?

View 2 Replies

ActionScript 2.0 :: OOP In Flash: Calling A Function W/in A Function Class?

May 12, 2004

Okay so I am reading through sens tutorial on OOP and updating my game that I am making. It is much easier to code this way (IMO) but still hitting snags.I am trying to get through this code:

[Code]...

View 3 Replies

ActionScript 3.0 :: Calling A Function From A Class?

Sep 26, 2010

I want to call a function on the "Driver" class which is the main document class, from another class.

but i always get this error. 1061: Call to a possibly undefined method Test through a reference with static type Class. here is the main document.

[Code]...

View 5 Replies

Flex :: Calling A Function From A Class?

Jul 27, 2009

package asas
{
public class main extends EventDispatcher[code].....

I have this class and a MXML file... how will i call the function doCheck in button. When i call like this, it throws me an error.

<mx:Button
styleName="LoginButton"
id="loginButton" [code]...

View 2 Replies

Flash :: Calling A Function In Another Class

Oct 27, 2011

I'm trying to call a function to another class after an event.

Here's my code:

From the doucment class:

public static function redrawMap():void {
removeChild(global.world);
var world:WorldHandler = new WorldHandler(40,30);

[Code]....

I can't get it to work correctly, I get weird messages like "Call to undefined method removeChild" and it pointing to the redrawMap function. Which means it found the function, but I can't seem to do anything with it.

View 3 Replies

Actionscript 3 :: Calling A Function From One Class From Another

Jan 11, 2012

I have two classes. One called Sledge and one called Sock, there is also the document class called Main. My issues are as follows: Inside of Sledge, I call a function that is defined inside of the Main document class. How would I go about telling the class to go to the document class and run that function? Would this also be the same for other classes or just for the document class? Inside Sledge, I have the following statement: if(hitTestObject(sock.myHitArea)) { /* somecode*/ }

sock is an instance of another seperate class, and by this point has already been created. However when I try and run this I am told it is not defined. How would i go about solving this?

View 1 Replies

ActionScript 2.0 :: Calling Function Of A Class?

Sep 29, 2008

I have done this type of thing a million times before, but I cannot for the life of me figure out why it isn't working this time. As of now I have three classes: Main, UI, and Bear.

Main creates an instance of UI and puts it on the stage. UI has, among other stuff, 7 instances of the Bear class sitting on the stage. The Bear class has a public function:

[Code]...

View 3 Replies

ActionScript 3.0 :: Calling Function In Another Class

Oct 7, 2008

Basically, I want to call a function that is in an external class: So I have my main class which is good, but then I want to call a function in another class, in as2 you'd do it like this foldername.foldername.asfile.functionname, but it doesn't seem to want to work in as3.

View 4 Replies

ActionScript 3.0 :: Call A Function From One Document Class From Another

Aug 30, 2010

I'm basically trying to call a function that is on document class from another document class. I have a document class called Main.as in it there is a function called tester(). I need to call this function from another document class called Step1.as.[code]Does anyone know how I can call the function? I cant seen to get it to work.

View 5 Replies







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