ActionScript 3.0 :: Calling A Function From Another File?
Apr 4, 2011Im trying to call the resetLI function from LevelItems.as.
Main.as
ActionScript Code:
public function resetLI():void {
itemList = new Array();
[code]...
Im trying to call the resetLI function from LevelItems.as.
Main.as
ActionScript Code:
public function resetLI():void {
itemList = new Array();
[code]...
I'm calling a function:
public function playCover(){
this.gotoAndStop(2);
trace('1');
[code]......
I have 1 .fla and 2 .as files. The first .as file is called documentClass and is the document class for the .fla. The second .as file is called tracePrac contains a function that traces a varible in tracePrac.as. I want to know how i call for this function in my documentClass.as code?
Code:
package {
import flash.display.MovieClip;
[code].....
I have a basic mxml app which looks like this
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="800" height="600">
<mx:Script>[code].........
this swf is loaded into another swf using Loader and added with addChild(loader).i then need to call the init function from the parent swf. how can i do this? just calling
loader.content.init();
fails.another question is, what is the exact classname of this mxml file?
How do I call a private function from an external ActionScript3 document? I'm working in Flash Builder 4, and I need to call a private function from an external AS3 document. I think I've imported it correctly....
import myapp.utils.WebcamFaceDetector;
import myapp.utils.FaceDetector;
But I want to call a function from "FaceDetector". Here's the part of the code in FaceDetector...
public class FaceDetector
{
private var detector :ObjectDetector;
private var options :ObjectDetectorOptions;
[Code]....
I want to call "private function FaceDetector()" to initiate at a certain point in another AS3 file. How do I properly declare it and get it to run?
Can anyone help me in this regard? I have Actinscript file in which I have defined a function like below:
actionScript.as (file name)
import mx.controls.Alert;
public function abc():void{
Alert.show("Inside abc(): My Button Clicked");
}
Now I have a button in mxml and I am calling the above function in my buttion "click" attribute like below.
Importing script in mxml:
[Code]...
I've got a flash file that reads some links from an xml config file. These links look like:
<url target="_blank" method="GET"><![CDATA[http://www.google.com]]></url>
Instead of a link, I'd like to call a javascript method that opens up a modal dialog with a list of items. I've tried the following based on some things I found, but I can't get it to work.
<url target="_self" method="GET"><![CDATA[javascript:loadAsModal(#modaldiv, ajaxmenu.jsp?gid=3)]]></url>
and
<url target="_self" method="GET"><script type="text/javascript"><![CDATA[loadAsModal(#modaldiv, ajaxmenu.jsp?gid=3)]]></script></url>
loadAsModal() takes in an empty div that i put on the page, and then the menu.jsp which builds the menu given the group id. I made sure to import all of my js libraries on the page.
i have defined some functions in a component mxml file let us say addbutton() now i want to call this function in main mxml file.
View 2 RepliesI have an AS3 function that loads and audio file and then plays it. I have the pre-loader for the first audio file working - now I need to run the pre-load function before the 2nd audio file starts.
myMusic.addEventListener(ProgressEvent.PROGRESS, onLoadProgress2, false,0, true);
myMusic.addEventListener(Event.COMPLETE, playMusicNow, false, 0,true);
myMusic.load(soundFile, myContext); //This code works
[code].....
i'm trying to modify some code and can't figure out what the issue i'm having it. this is the(shortened) code:
public static function Lose():void {
trace("OVER!");
Clock.stop();[code]...
this is the error i get: 1180: Call to a possibly undefined method OverIt.i just want to call a function from inside of the public static funtion.both function are inside this class:
public class Game extends MovieClip {
}
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]...
function test1():void
{
function test2():void {..}
[code].....
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]...
how can i call a function that is inside another function.like:
Code:
function abc() {function uvw() {
}
function xyz() {[code].....
I'm trying to get this one function to be able to call many functions (not at once, but call many possible ones)In other words, I'm trying to get this variable to be named as a function. That way, this one variable can create multiple functions.example:
actionscript Code:
class Thing extends MovieClip{ var funcvar; var othervar; function onLoad() funcvar = "YYY"; othervar = "ZZZ"; function onEnterFrame()
[code].....
I hope that this is possible. I can't seem to find any info on it on the web. I need to call a function from within a function. I'm not sure if there is a name for doing this that I don't know of?This is some example code of what I'm trying to achieve:
Actionscript Code:
someTimer.addEventListener(TimerEvent.TIMER, functionWithin);function mainFunction():void{ function functionWithin():void }}
[code]....
how can i open "insider" function from "start_function"?
ActionScript Code:
start_function();
function start_function():void {
[code].....
I read online, and I understand kinda what the error is stating. Though, I can't find out why.So basically what I understand is that I am calling a function that is not a function?ere is the error and code portions that are required.TypeError: Error #1006: value is not a function.at VideoPlayer_fla::MainTimeline/startVideoPlayer()at VideoPlayer_fla::MainTimeline/frame1()
View 2 RepliesI am refactoring some code. I have a PHP page that contains a MySQL query and stores the result in a PHP variable $my_result. This result is then echoed to a Flash SWF during embedding with SWFObject. I now want to call this PHP page that makes the query from a javascript function like so - one change I have made to the PHP is that instead of storing the result in a variable $my_result I am echoing the result. Javascript function to call the PHP page and make the database query
[Code]....
I am making a character walk. This code will make him wobble to the right and when thats done it will trigger him to wobble to the left and then call the function again to continue the loop.I can get the loop to work fine by calling the function but how do I STOP the function? Also I want to call it later on. Is there a way to start and stop a function?
function wobble()
{
var ws = .1;
var dis = 1;
[code]....
I have a Flash movie which is embeded in 'base.aspx' file, when a button is clicked in the flash movie another 'something.aspx' file need to be called.When I run the flash movie from the Adobe Flash Professional CS3 IDE , it (the flash movie) calls the 'something.aspx' file just as expected.However when I embed the flash movie in to the 'base.aspx' file it doesn't work as expected .
View 4 RepliesI'm try to calling my sloppy global function by calling my global function class as u can see below.[code]
View 2 Repliesi have a movie clip of a square in the library exported as Square1, i place 2 instances of it on stage and push them to an array called ar i add event listeners to both ar[0] and ar[1] to do a certain function. i need flash to tell me wheter ar[0] or ar[1] called the function.
View 6 Repliesthe *who.say* in the following function refers to a var displayed inside a dynamic text box.
when I tryed to call the function twice, from the same MC, only with different Who's and What's, it didn't work. only one call displayed the text.
//*who is talking, what is he saying, and for how long his text is displayed**
function saythat(who, what, fortime) {
starttime = getTimer();
[Code].....
I'm writing a class that utilizes the whole screen resolution and need a movieClip to adjust itself in accordance to that. That "almost work". The problem is that I cannot call functions when the resize listener kicks (onResize = function()) in, and I don't understand why I want to call the function centreMe() from within the onResize function.
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.utils.Delegate;
class centre {
public function centre() {
[Code] .....
In my application in the first frame I have the following: this is a simplified version,
Code:
import com.Menu.Menu;
import com.Papervision.Papervision;
[code]....
I'm using FLex Builder and in my Main class I load an external swf. In the external swf there is a movieclip on the stage called house. In the library I have that movieclips Class name set to a class I defined called com.buildings.House
When I load the swf from the main class I'm trying to access a function called setup in the class called House. I have tried a bunch of different ways but I get errors for them all.
Code:
private function onLoadSwf( url : String) : void
{
var loader : Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoadComplete);
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoadInit);
[Code]....
I'm at a loss right now and its driving me mad. In flash I used to use the var externalSwf : MovieClip = evt.target.content; example and it worked but with Flex Builder its throwing error saying setup is not a function.
With the Imap interface its saying externalSwf is null.
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]...
I have a program that is displaying a number of images from an XML file. The images are being resized and displayed through a loop function. I'm creating a new Loader each time through the loop and adding it to the stage. The problem is, I then want to create an event listener that will call a function for a mouse event for each image. The first issue I'm running into: how do I determine which image is which after loading them to the stage (say I want to display a large version of the image when the small image is clicked)? Secondly, since I'm creating the Loader within the first function, how do I pass the Loader to another function, say the one called by the mouse event listener? I'm sure I'm going about the fundamentals the wrong way.
View 3 RepliesI have several buttons calling the bounceOut() function andthe bounceOut() function calls the onMotionFinish() function. Afterthat function is finished I want to go back to the original callingFirst a call is made to bounceOut() when a button is clicked.I have ten buttons.
function bounceOut() {
var smSlide:Tween=new
Tween(sideMenu_mc,"x",Regular.easeOut,200,-200,2,true);
[code].....