Flash :: Call A Class Public Function From Another Class?
Jun 30, 2010
can i call a class public function from another class? what's the cleaniest solution to do that?
[Code].....
a button wich is istanced in Menu, run showTheThumbs method, in Thumbs.
View 2 Replies
Similar Posts:
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
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
Oct 28, 2009
My question today revolves around a CustomEvent I'm trying to send from one sub Class to another.
I've used my CustomEvent class to pass an event from a sub Class to my main class fine, but I'm not sure who to do that between sub classes.
My Custom Event Class
package src.events {
import flash.events.Event;
public class CustomEvent extends Event
{
[Code].....
View 3 Replies
Jul 16, 2009
I have to know if a public method has been called from outside the class or from inside. The reason is that depending on this, one of the actions to be executed in this method vary a bit.
View 3 Replies
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
Nov 25, 2010
Lets say I have a Main Document Class called Main. I also have a child class called childClass that call a function from the Main class and is also imported in the Main class. How should I call the function? I tried this , but when calling the function, it's getting me error.
Main class :
Code:
package {
import flash.display.Sprite;
import com.childClass;
[Code].....
View 6 Replies
Jan 14, 2009
Is it possible to have a class with a public function [code]...
View 8 Replies
Dec 15, 2009
how do use a function from a doc class.... to call a function to work on in
[Code]...
View 2 Replies
Aug 2, 2010
Is it possible to externally override a public function of a class (as opposed to override via inheritance)?
For example:
Code:
Class Foo {public function doFoo():void {trace ("Foo");
}
}
Such that:
[Code]...
I know this is possible in JavaScript and ECMAScript, but the compiler won't let me get away with this kind of mischief in ActionScript, from what I've seen: It barfs up a 1168 Illegal Assignment error as soon as I attempt to assign a new function to doFoo.
I'm thinking specifically in terms of a "hot fix" solution where you deploy a small swf that replaces a specific chunk of code in a larger application, without the need to recompile/deploy the full application (or even see the sourcecode for that matter, just know the API).
View 9 Replies
Aug 7, 2009
What would be the scoping to reach a variable within a external class public function FROM a function on the main timeline?In menu.as public function buttonClick()Need to reach a starFunction variable(var starFunction = such and such.@fn) within an if statement within buttonClick function.On main timeline(menu.as declared on first frame main timeline as var menuH:Menu = new Menu()In function aboutUs()here is where I need to use that variable for an if statement
View 1 Replies
Dec 1, 2011
I'm trying to call a function in one child class (Circle.as) from another child class (Wedge.as). Circle.as is instantiated by the document class (Tree.as), and Wedge.as is instantiated by Circle.as. How do I do this? This is my code:
Tree.as
package com.treediagram
{
public class Tree extends MovieClip
{
[code]....
How to call a function in a Class from another Class?but it was a bit hard to follow as it relates to my problem. One of the solutions worked, but was commented as being bad form, and another did not work, so I want to make sure I structure my code properly.
View 3 Replies
Jul 23, 2011
I have this piece of code that has a problem.
[Code]...
View 2 Replies
Nov 24, 2011
I have the following inheritance structure:
var environment:AvEnvironment = new AvEnvironment(...);
addChild(environment);
environment.addChild(new Terrain());
environment.addChild(new Player());
I am trying to access a public property from AvEniroments class through the Player class, however I'm getting an undefined property error (#119). I've tried the following:
this.x = AvEnvironment.xs // public property in this class
this.x = parent.xs
I've also tried something like this:
var ev:AvEnvironment = AvEnvironment(parent);
this.x = ev.xs
but I get a TypeError. Error #1009: Cannot access a property or method of a null object reference.
View 1 Replies
Apr 28, 2011
I have created a class in which i have created instance of a movie clip.[code]Now i want play this movieclip on particular frame. say frame 10.
View 2 Replies
Feb 17, 2012
Here's what I intend to do. Create a base movie. Load a footer into the basemovie. When a button is clicked in the footer, I want to call a function in the base movie to load a page on the top.
refer to the attachment. Basemovie is the main class, that loads the footer swf. In footer.as, I want to be able to call basemovie.fLoadContent() from the function fClickNext().
View 4 Replies
Nov 14, 2010
I have two child classes ClassA and ClassB both inherit the same base class.
I also have a function that has a parameter which could be an instance of either child classes.
function Test(instance):void //instance is either a ClassA or ClassB instance
{
instance.DoSomething();
}
However, when I run the test, it's always the BaseClass.DoSomething() get called. How can I use the same function (DoSomething()), but call child class function instead of the base class one?
View 2 Replies
Nov 16, 2010
I'm having some trouble finishing an interface i'm working on,the function indica() adds a menu listing of items (indicadores) inside a mask because its too large, and i added a scrollbar that allows to scroll through the items but now i need to add the buttons inside the movie clip indicative,i can add symbols and buttons, but i'm having trouble having them call functions inside the same class that the function indica() is running.[code]
View 2 Replies
Oct 24, 2011
I have searched for this everywhere but it seems like every answer is either overcomplicated or simply does not work, and I know for sure there should be a more simple way of achieving what I need. So, until today, I have always coded from within the timeline. But now I realise why I should code in separate class files. However, I still want to include snippets of code in the timeline for simplicity's sake.
[Code]....
View 2 Replies
Apr 27, 2009
How do you call a function from another class in AS3? Functions referring properties/methods from instances created in that class. For example I have a class that creates a textfield and a scrollbar and another that load some images in a Scroll Pane component. I do it in that way because in some menus appears only text and in others text & images
What I need is with the scrollbar, scroll both text and images
View 2 Replies
May 5, 2010
This is what I can do..Write a Menu Class to build a panel of buttons.Add the event listener to the object in the Class.Instantiate the Class in the main document.
What I cant do or understand is how to respond to the events from the Menu Class in the Main document, say by calling a function that exists in the Main document.
I get around this by instantiating the menu Class and then assigning the listener to it in the Main document.
View 0 Replies
Jul 5, 2011
I have a mainIndex.as menu.as (extends movieclip-instantiated in mainIndex)
When a button is clicked in "menu" class I want passing the name of the menu item to a mainIndex so the swf with that name can be loaded.
View 2 Replies
Feb 17, 2012
I'm just beginning to learn AS3. Here's what I intend to do. Create a base movie. Load a footer into the basemovie. When a button is clicked in the footer, I want to call a function in the base movie to load a page on the top.
Please refer to the attachment. Basemovie is the main class, that loads the footer swf. In footer.as, I want to be able to call basemovie.fLoadContent() from the function fClickNext().
View 3 Replies
Dec 17, 2008
I like to call a function that is outside of the class file.
for example
main.fla
Code:
function callmepls(){
trace("yes");
}
[Code].....
View 8 Replies
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
Oct 3, 2010
I have an external class file that contains code to control the playback of a movie that is defined via FlashVars.
Within this class are functions like this to control playback of the movie:
[Code].....
What I'm trying to do is find a way to trigger those same functions from the 1st frame of the timeline itself. Basically after a certain amount of time I need to pause the video automatically.
how do I trigger functions like the doPlayEvent() function noted above from some AS that's inserted in the first frame of the movie?
View 4 Replies
Apr 30, 2010
Can anyone tell me if its possible to call a function or class from within a loaded MC?
mainMovie loads MC > MC calls function in a class of mainMovie
if so, what is the best method?[code]...
View 2 Replies
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
Jan 10, 2011
I have 2 files: Main.mxml with application and one MyObject.as.I create the instance of MyObject in mxml and can call its every public function from mxml. But what if for some reason I need to call some function declared in mxml from MyObject class?
View 2 Replies
Dec 8, 2011
I want to call a function that is inside the root timeline of Flash from an external class.
This code is from the class:
private function loadImage(event:Event):void
{
addToContainer()
}
[Code].....
View 3 Replies