ActionScript 3.0 :: Access A Function In The Main Class From Another Class?

Mar 1, 2010

i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a "Play Button" that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class.i have three files:

Main.fla
Main.as
loadScreen.as

the Main.as file:

Code:
package
{
import flash.text.*;
import flash.display.*;

[code]....

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Access Function At Main Class From A Sub Class?

Mar 3, 2011

My first experience is build an aquarium with a lot of fish swimming, and they can be clicked. When one of them is clicked we should receive a trace message saying ("I�m a Fish!"). To do this, I thought that the best way will be:

1- create a document class, named Main.as

2- create a base class, named Clicked.as

2- create a movie clip with a fish.

3- export the movieclip to actionscript. In the mc properties set Class as "fish" and Base Class as "Clicked".

View 6 Replies

ActionScript 3.0 :: Access Main Class Function From External?

Feb 9, 2009

I'm quite confused about how to do it, look at this [code]...

View 2 Replies

Actionscript 3 :: Access Variables In Main Application Class From Instantiated Class?

Apr 8, 2010

I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.

Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:

"Access of undefined property currentState."

View 1 Replies

ActionScript 3.0 :: Call Function, Pass Value, Access Variable In Movieclip Class From Main Stage?

Nov 20, 2008

I have a movieClip named MC, and it's enabled with action script, with the class name MC_Rectangle and a Stage.I override the MC_Rectangle class file in a mc_rectangle.as external file.here is the code:

package{
import flash.display.*;
import flash.events.*;[ code].....

I have new a object in the main stage var

mc_rect:MC_Rectangle = new MC_Rectangle()

in main stage:

1. how can i access the variable "sequence" in "mc_rect"

2. how can i pass parametre from main stage to mc_rect via function setSequence(data:int)?

3. how can i call the function in addSequence() in mc_rect.

in asp.net, i usually use mc_rect.sequenct,mc_rect.setSequence(data), mc_rect.addSequence() to achieve my goals......btw, can function in mc_rect return out result to main stage?

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

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

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 :: Access Main Class Objects?

Mar 1, 2011

I created an array in my Main class and populated it with instances of a seperate class. Is there a way I can access the original array from within the instances of the separate class.

View 1 Replies

ActionScript 2.0 :: Access Variables Within The Main MC Class?

Nov 18, 2007

I have a MC with a class attached to it, and I have other MCs within that MC. I need those MCs to be able to access variables within the main MC class. Here is a quick'n'dirty:

Code:
class Foo extends MovieClip{private var h:Number;
private var subMC:MovieClip;function Foo(_h:Number){h = _h;}
subMC.onEnterFrame = function(){trace(h);}}

How can I access variables in the Foo class from another MCs scope? I have tried using static var but aren't they constant regardless of instance?

View 1 Replies

ActionScript 3.0 :: Access Property Of Main Class In Loaded Swf

Aug 28, 2010

i have one main.fla, its document class is main.as. the code in main.as is package.[code]where val is the property of Loading class.so how can i access.

View 2 Replies

ActionScript 3.0 :: Access A Class Object From Main Timeline

Dec 29, 2010

I have a class, and I'm trying access an object outside of that class. For example, in my class I have function: onNodeLoad(node:Object)with that function I can access the properties of node just fine, but outside the class I cannot.In the function that is inside the class, I can trace (node. title)I want to be able to do that trace on the main timeline.[code]So right now, in my main timeline, trace(con.node) comes up null.I've tried to declaring _node public, private, public static.

View 1 Replies

ActionScript 3.0 :: Access Main Time Line From Class?

Feb 12, 2009

document class

Code:
package pages
{
import flash.display.*;
import flash.events.*;

[Code].....

the highlighted function is what i need to be working but it isnt.. have no idea whats going on... i basically need to jump between frames on the root timeline (superMain)

View 1 Replies

ActionScript 3.0 :: How To Access Instance Property Through Child In Main Class

Jan 23, 2011

I have make 3 classes objecthandler, box and nav. Nav is child class of objecthandler, I have make an instance of box into objecthandler and now I wanna access property of box through nav.
See the code:
Objecthandler class
package code{
import flash.display.MovieClip
import code.box
import code.nav
[Code] .....

View 1 Replies

Actionscript 3 :: Access Main Stage From Class Definition File?

Mar 22, 2010

I'd like to access the stage of the main timeline from w/i a class that extends a movieclip. Basically, I have a button in the main timeline that makes a HUD appear. The HUD is an extended MovieClip class. When people click on a button in the HUD, I'd like to remove the object from the stage of the main MovieClip.I think your confusion may come from the fact that I am running this code from a class definition file. Clicking on a button w/i this object should remove it from the DisplayList of the MainTimeline. Here's the code from the class definition file:

package classes {
import flash.display.Stage;
import flash.display.MovieClip;[code]....

trace(e.currentTarget.parent.parent) gets me the MainTimeline, and trace(e.currentTarget.parent.parent.stage) appears to return the main stage, but I cannot use removeChild w/o getting an error that I am trying to coerce the stage to be a DisplayObject (which it ought to be).What's on the stage of the MainTimeline: A single button that, when clicked, adds an instance of the Answers class to the stage.

View 2 Replies

ActionScript 3.0 :: Flash - Access Nested MCs From Main Document Class?

Mar 11, 2012

I have 3 dynamic textfields that are added to the stage through an external class, (I only add the main container from the Main.as) the textfields are nested under 5 MCs (that's what i see when i list objects in the debugger) how can i access those textfield from the Main document class?I've tried by path, by getchildbyname, i've exported the font for AS (the textfields have instance names)... and nothing works, i either get an error or it tells me it has no properties, or null..

View 14 Replies

Actionscript 3 :: Access The Main Class's Stage + Pass Functions As Arguments Like This?

Jan 22, 2011

There are two files in my actionscript project named "TestAPP", TestAPP.as and Draggable.as

TestAPP.as:
package {
import flash.display.Sprite;
import flash.display.Stage;[code].....

In "my actionscript theory", I'm supposed to see a circle that follows the mouse when I click it. (The draggable is not fully implemented) But the circle doesn't even budge .how to access the main class's stage property. I've googled for it, but still no progress.

View 4 Replies

Call Function In Main Doc Class From External SWF?

Jul 9, 2009

I have a main.swf that loads in an external swf called home.swf. I want to be able to call a function in main.swf's doc class from the loaded swf:

Code:

function loadArtist():void { // my function }

in the main timeline of home.swf I'm calling it this way:

Code:

function timeToGo(m:MouseEvent):void {
trace("button pressed");
MovieClip(this.parent.parent).loadArtist(); }

the home.swf compiles fine but when loaded in the main.swf & the button is pressed i get this error:

TypeError: Error #1006: loadArtist is not a function.
at home_fla::MainTimeline/timeToGo()

It seems that it thinks loadArtist is a property. Ack. I've got 3 objects loaded dynamically using addChildAt(mc, 0) ...

View 2 Replies

ActionScript 3.0 :: Button In A Class To Run Function In Main .fla?

May 15, 2011

Does anyone know of a way to have something in a class, run a function in the main .fla? I have a class that creates a drop down menu and I would like that when a btn is clicked, a function is run.....but it is important that this function is in the main .fla and not in the class.

View 2 Replies

Flash :: Access Top Level Function When Class Has A Function Of The Same Name

Dec 16, 2011

I have a class Debug with a function called trace inside it which puts a TextField on the stage and outputs the text. Now I am trying to get the Debug.trace() function to do a "normal" debug trace as well from within side itself. of course this causes a recursive loop. I am trying to figure out how I can access the top level separately. I tried using namespaces such as AS3::trace but to no luck.

I know a solution is to rename my function to stop the conflict, but I would like that to be a last resort. It is being used in quite alot of places throughout my entire code so replacing it everywhere is going to be a ballache.

View 1 Replies

ActionScript 3.0 :: Getting Loaded SWF To Use A Function From Main.fla Document Class?

Dec 16, 2009

I have a main movie with thumb movieclips that load new children and stops the main movie's animation. Within the child there is a close buttion that removes itself. I also wanted the close button to start the animation of the main movie again once it removed the child. Since I am using a document class to load everything for the main move, how can the close button from the loaded swf use a function from the main document class?

View 5 Replies

Professional :: Access Another Class Function?

Jan 27, 2012

I am trying to access another class function. I have 2 Classes and my main menu features are in my Main Class and I want to call that function from my Level ClassWhat is a good idea to approach this, some how I need to import it in a way but I don't know how I could do that.

View 2 Replies

Actionscript 3 :: Access A Function In One Class From Another?

Mar 25, 2011

I have a AS3 MP3 player. The player class is called Mp3PlayerFrontEnd and controls the play and pause buttons. The playlist class is called PlaylistBoxItem and loads the track names into a playlist from XML. On each line of the playlist is a download button. When the download button is pressed, I want the player to pause. I thought I could just _player.pause(); from the playlist class but it doesnt work.

So my question is... How do I access the function in the MP3 player class from the playlist class?

"Normally you will just have to get access to the Mp3Player instance in PlaylistListboxItem class and call pause() on it in download function. I guess the easiest way to achieve this is to create a public static instance of a holder class that could be used access the player from wherever in code."

View 1 Replies

ActionScript 3.0 :: How To Access A Function From A Class

Jan 26, 2010

I'm using actionscript 3.

How will i be able to access a function that is inside a class?

I mean, i would like to call those functions in my main.fla.

View 3 Replies

ActionScript 3.0 :: Access A Function In One Class From Another?

Mar 24, 2011

I have a AS3 MP3 player. The player class controls the play and pause buttons. The playlist class loads the track names into a playlist from XML. In the playlist is a download button. When the download button is pressed, I want the player to pause. I thought I could just _player.pause(); from the playlist class but it doesnt work.How do I access the function in the MP3 player class from the playlist class?I did not make this, I purchased it. I asked the guy who made it for help and he responded back."Normally you will just have to get access to the Mp3Player instance in PlaylistListboxItem class and call pause() on it in evthndlDownload. I guess the easiest way to achieve this is to create a public static instance of a holder class that could be used access the player from wherever in code."

I do not know how to make a public static instance or where to put it. Attached is the 2 AS files. I can send you the zipped source of the whole player in a PM if anyone needs. On line 25 of Mp3PlayerFrontEnd you will see the public class where the player is defined.On line 94 of PlayllistListboxItem you will see the function to download the file. It is from there I want to pause the player.

View 9 Replies

ActionScript 3.0 :: Access A Class Function With Another?

May 27, 2011

Current stage:Class 1 - box on right:

Code:
package
{

[code].....

View 2 Replies

ActionScript 3.0 :: Call Function In Main Timeline From Class File?

Jun 3, 2009

How can a function in main timeline be called from class file?

View 4 Replies

ActionScript 3.0 :: Pass Parameters To A Function In Main Class From Loaded SWF?

Aug 15, 2011

I've got a main.as that loads SWF to the stage. the loaded SWF seppoused to pass a link to the main.as and trigger a javascript function to popUp that photo from that link.

I know there are two ways:
 
((root as MovieClip).parent.parent as Object).somefunction(parameters);
 
and to dispatch an event. inorder to pass parameters throug the event i need to extend it with another class.
 
isnt the (root as... )  more efficient if all i need is to pass a link?

View 7 Replies

Actionscript 3 :: Call The Function That Is In Main.mxml App From A Class In Flex

Feb 24, 2011

i write a sound playback class that stop the older sound and play the new sound.After that i need an extra method in this class that trigger when the sound play is complete.I successfully achieve this, but i need to inform the main app (main.mxml) about the completion of that sound playing.

here is my sound playback class.

package com.m2b.data
{
import flash.events.Event;
import flash.media.Sound;

[Code]....

View 3 Replies

Actionscript 3 :: Call A Function In The Main Timeline From A Class In A .as File

Feb 15, 2012

I have some functions defined at the main timeline, and I need to call them from a class, how can I do this?

I've tried object(parent).function();

and object(root).function();

but didn't worked

those functions need to be on the main timeline because they removeChild() of the class

View 2 Replies







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