ActionScript 3.0 :: Calling Class Function From Timeline?
Dec 4, 2009
I have a MC1 with a class that controls it on my timeline. Within this MC there is a second MC2 which contains a short animation. During that animation i need a trigger that will call a method from the class attached to the main MC. MC1 is linked to CLASSMC1 contains MC2(short animation)MC2 calls a function in CLASS
Code:
package {
public class CLASS {
[code].....
View 1 Replies
Similar Posts:
Apr 7, 2009
in my menuButton class I add an eventlistener but moveAlong is on the main timeline how do I call it?[code]
View 1 Replies
Aug 12, 2009
i am getting a "ReferenceError: Error #1069: Property beginTargetLock not found on AimCursor and there is no default value."
[Code].....
View 2 Replies
Aug 26, 2010
I'm trying to call a function called checkForHit() located inside of my Hero class at a particular frame of an attack animation of my Hero object. Meaning, when his weapon is at the point in the animation where it could collide with any enemies, I want to call the function that performs the check.My Hero Movie Clip is set up where it contains a Movie Clip on different frames that coorespond to the different animations (attacks, movements, etc). So the Hero MC contains a bunch of other MCs. That way I can just use hero.gotoAndStop("attack1");
The problem that I'm having is that the code that I wrote to call the checkForHit() function is written on one of the frame of the nested MC's timeline, and it's not being recognized. In fact, even if I put a trace("HELLO") on any of the frames on the nested MC, it's not being output. I even tried to put something that I know should cause an error on one of the frames, and it ran without throwing an error. It's almost like the code on the timeline isn't being compiled, or it's being skipped over somehow.
View 1 Replies
Oct 13, 2008
I decided to rewrite my question from an earlier post...I'm using the TextMetric class: URL...The code below currently resides on the attachedMC timeline, and is written twice with different variables for each time called for each dynamicText.[code]What i am trying to do (emphasis on trying) is write the code on the main timeline, so that it can be called from any attached MC, a sort of global function if you will. Another thing to note is that there are multiple dynamic Texts using the function at the same time.[code]
View 4 Replies
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
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
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
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
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
Aug 5, 2009
I have a project which requires the loading and unloading of multiple "scenes". All my navigation is working (probably not the most efficient way) but I'm having one issue. I need a button on one of the loaded SWFs to call a function on the main timeline. Since Actionscript 3 no longer supports the _root functionality the way AS2 did, I cannot access the main timeline.
In general, how do I get to the root of the main timeline without using _root?
Also, how can I reference the loaded SWF and objects inside of it from the main timeline?
View 1 Replies
May 12, 2008
I've tried looking everywhere for this answer, but I'm still at a loss. I'm beginning to think it's not possible or I'm just not looking in the right places.I have three swf files. The main container and then two external swf files being loaded into the main swf. Swf 1 (frame.swf) has a function on the main timeline that needs to be called from a button in swf 2 (toolbox.swf). My initial thought was to place the actionscript of frame.swf into a movieclip and call it from toolbox.swf using:_root.callFunction("PH", "doPhone");Although this would work, I cannot use this option. The actionscript of swf 1 must stay in the main timeline. Using a class file is not an option either. Is there any other way to call a function from the main timeline of an external swf?
View 1 Replies
Sep 27, 2010
So this was quite simple in AS2, but considering that _root is no longer around, how can I call a function that is on the main time line from a nested movie clip?
This is what I have inside my movie clip:
Code: this.hit_mc.addEventListener(MouseEvent.CLICK, updateScore); I tried using Stage.updateScore, but that didn't work either. This is the error I'm getting:
1119: Access of possibly undefined property Stage through a reference with static type flash.display:Stage.
View 2 Replies
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
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
Sep 26, 2005
I have created a function on the root timeline, to be called at a certain point (when the character is on a certain frame and so is the certain item, he loses a life)the lives_mc advances frame by frame to show lives being lost.heres the function
Code:
function loseLife(){
if(_root.lives_mc._currentframe=1){
_root.lives_mc._currentframe=1[code].....
View 7 Replies
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
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
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
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
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
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
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
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
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
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
Sep 9, 2009
I have the following two classes and can't seem to figure to figure out how to call a function in the top one from the bottom one. The top one get instantiated on the root timeline. The bottom one gets instantiated from the top one. How do I call functions between the classes. Also, what if I had another call instantiated in top one and wanted to call a function in the bottom class from the second class?
package
{
import flash.display.MovieClip;
[code]......
View 12 Replies
Feb 25, 2010
Basically I have a function that is needs to tell 2 other classes to do something. It works for one of the classes: BigPlayButton, but not Background for some reason.TabMenu.as Class functionNote: The function below WILL call the hitPlayCircle function in my BigPlayButton class, but I get an undefined property error for the Background switchTitle function.
private function thumbClick(e:MouseEvent = null):void
{
trace("YOU CLICKED THUMBNAIL: " + e.target.id);
[code].....
View 2 Replies
Jan 3, 2012
I have a set function
public function set energy(value:int):void
when I try to call this function from the same class using
energy(10); or this.energy(10)
I get an error:
Call to a possibly undefined method energy.
There are no variables declared as energy in the class.
View 1 Replies
Mar 29, 2012
I have my main stage, and I have two objects (blocks), these two objects both extend from the "Block" class. The "Block" class is NOT extended from the Main Class.I would LIKE to call a function, in either the "Block" class or in it's subclasses, from the Main Stage Class. The functions will do slightly different things depending which object you are calling the function (Added different things, and different number of things to an array). What is the best way to implement this?
View 2 Replies