ActionScript 3.0 :: Utility Functions Without A Class?
Nov 3, 2010
I have a web application created using Flash Pro and I want to use external ActionScript files to support it. I have a package with multiple classes. I want to be able to create utility functions to do things across classes. How do I make these functions accessible to any of the classes? I know I can create a class with these functions and then instantiate the class with a dummy variable to be able to access the methods but is there a better way?
View 4 Replies
Similar Posts:
Jan 25, 2011
If my main class I define
var arrItems:Array=[];
and in a utility class (in a different file) I define
[Code]...
View 4 Replies
Jun 27, 2005
i'm using Sephiroth XMLObject to parse Xml and it works nice (handling actions inside the Xml Onload event), but i would like to cut shorter coding writing a class calling Xml and XMLObject, it's possible?. This is an attempt but it doesn't work, or better, Xml file is parsed correctly but is not available.
This is the class:
Code:
import mx.utils.Delegate;
import XMLObject;
class XMLLoader {
private var xmlFileName:String;
[code]...
View 1 Replies
Jun 16, 2009
I want to create a utility class (my first one ). Trying the package thing first I'm stuck with a "1061: Call to a possibly undefined method abc through a reference with static type Class"
I have:
1. packagetest.fla: empty except the assignment of the class in its properties: packagetest
2. packagetest.as (same directory as packagetest.fla):
Code:
package
{
import flash.display.MovieClip;
import example.*;
[Code].....
View 1 Replies
Mar 22, 2012
I'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.
View 1 Replies
Feb 19, 2010
I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it
Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function
[code].....
View 6 Replies
Sep 25, 2011
Main is my doccument class . how can i call Main.Caller
package { import flash.display.Sprite; import flash.events.Event;
public class Main extends Sprite {
public function Main():void { if (stage) init(); else
[Code]....
View 2 Replies
Jul 12, 2009
I would like to create a class that simply houses all my custom functions that I commonly use. These are functions, not methods tied to a specific object. Is this possible?
View 6 Replies
Sep 21, 2010
Is there any utility that indicates in a comprehensible way what is referencing and object and why it can't be garbage collected.
View 2 Replies
Sep 24, 2010
I have a fairy sizable class, a`nd an mx:Application that will periodically instantiate a new object of this class, which results in member functions of the class being assigned as event listeners to the application, and also other member display objects of the class being added as children to the application. When the application creates a new object of this class the old object is destroyed: to accomplish this, removeEventListener and removeChild are called on various members of the old object (to decouple them from the parent application) and then the final reference to the old object is set to null, and then finally the well known localConnection hack is called to force FP to actually free the memory.
And the thing is, the above destruction procedure always works to deallocate an object - except for the very first object allocated. it has proved impossible thus far to release the memory of the first such object created, or find out what is preventing it (i.e. find out what is still referencing it). So my question is - is there any useful utility that will tell you what is still referencing an object and keeping it from being garbage collected. Someone implied to me that the flex profiler would do this (which I do not have access to) but another 3rd party profiler I found for flex would not do this (i.e. tell you what is referencing an object and keeping it from being deleted.)
View 2 Replies
Jun 7, 2010
In a custom queue, there's a push() and a pop() function. The pop() may be called any time on an Event.COMPLETE, so does this mean that code can be running in push() and pop() simultaneously? If so, is there a way to prevent the code from being run in both functions at the same time?
View 3 Replies
Apr 19, 2005
Can anybody tell where the class functions are defined?[code]
View 1 Replies
Nov 30, 2006
I was wondering if they found a better way of allowing the use of variables outside of an on function. For example in the script below I can use the variable bounds inside the target.onEnterFrame function because it's declared inside the constructor. However I can't use m_Bounds even though it's declared in the class.[code]...
View 7 Replies
Aug 2, 2007
I've been coding a bunch of movie clips as buttons (gives me more flexibility) and the lines of code is phenomenal... was wondering if i could create a template of functions, and instantiate it for each object?
ActionScript Code:
unimatic.onRollOver = function() {
unimatic.gotoAndPlay(2);
[code].......
View 2 Replies
Apr 19, 2005
where the class functions are defined?
e.g. the function function toUpperCase():String; in
C:Documents and SettingsuserIdLocal SettingsApplication DataMacromediaFlash MX 2004enConfigurationClassesString.as
View 1 Replies
Jul 22, 2009
I am trying to get a handle on interfaces with AS3 and am kind of at a sticking point. Someone tried to explain them to me using legos¯ and conceptually I get the idea of consistent interaction. Where I seem to get stuck is, I don't really see how the implementation of interfaces¯ accomplishes this.
[Code]....
View 3 Replies
Mar 25, 2010
I have a Main.fla which loads Main.as as its document class. In Main.as I have a public function named "Main" which runs a trace. I also have another .as file called Preloader.as, which also has a public function in it, this one named "Preloader" with simple trace in it. I just cannot figure out how to use Preloader() from the Preloader class in Main() from the Main class. Main.as loads up fine when the SWF loads and traces.
View 10 Replies
Nov 25, 2010
As above is there a way to access any function written inside main timeline from a class?
View 1 Replies
Oct 30, 2008
I have this Class:
package {
import flash.display.MovieClip;
public class MainClass extends MovieClip {
[Code]....
I had used it as a document class, when I call the sum function from the main time line it works, but I need to call it from inside a movieclip.
View 3 Replies
Mar 13, 2010
I'm new to writing several different class files.. and trying to make a set of boxes that expand/collapse by mouse click and timer..
I have 4 class files, Box, BoxGroup, BoxTimer, and Main.
I can call the functions in Box class from BoxGroup class, but not the functions in the BoxTimer class. it keeps throwing this error. I don't understand why since i'm using the same method between the other 2 class files...
ReferenceError: Error #1069: Property timer_start not found on
CollapsingBox and there is no default value. at
CollapsingBoxGroup/on_click()
[Code].....
View 4 Replies
Mar 25, 2010
i'm trying to make a website with sliding pages via clicking on the buttons, scrolling a mouse wheel and draging a scroller button just like in this wesite [URL].. for a moment i have done navigation via buttons, it works perfectly but i'm strugling with adding scrollbar (just like in that website) that i want to make it scrolable via mousewheel and that drager on the right side.
can anybody help me to add those functions for mouse wheel scroll and drager.
[Code]...
View 4 Replies
Apr 15, 2010
Call functions from document class?
View 11 Replies
Sep 25, 2011
Main is my doccument class . How can i call Main.showAlert function from Caller class.[code]...
View 5 Replies
May 29, 2010
how can i call public functions or vars of a sprite class from another class (or frame script)? i keep getting 1061: Call to a possibly undefined method getSide through a reference with static type flash.display:Sprite.
//Framescript
var a:Sprite = new customRect();
addChild(a);
[Code]....
View 2 Replies
Feb 17, 2011
Even I am programmer I am very, very, new to as3.
Problem: I have define a classA in aA.sp file.
package{
import flash.display.Sprite
.......[code]...........
When test on cs4 (contol>enter) I get following error 1061: Call to a possibly undefined method playVideo through a reference with static type flash.display:Sprite
View 2 Replies
Sep 26, 2011
Say I have the following set up of classes.
Road - extends MovieClip Car - extends Road
Controller - extends Car
And I want to incorporate some common Mathematical functions in them all to make them faster e.g.(replacing Math classes with some speedy bitwise versions).
What is the best way to incorporate these functions into all of them without writing the functions in the classes or extending from class of the functions. Is importing the class into each the fastest way or is their a better way?
View 2 Replies
Sep 9, 2009
I've made two custom classes ("banana" and "box"). As I start my application I create two new objects from these classes - first I create a banana object and then a box object. The banana class/object has a property/variable ("weight") that I set with information from an external XML file, thus it takes a while for it to receive a value.
My problem is that my box object needs to access the "weight" property of the banana project, just after the box object has been created. The problem is that the banana object hasn't finished initialising when I make the request from the box object...
Is there a way of either check the status of another class (initialisation status that is), or is there another way of preventing the box object to either be created before the banana object is initialised?
View 2 Replies
Dec 26, 2010
i want to be able to call the function keyDowns() from my main file on ENTER_FRAME. However, i can't seem to get the syntax/definitions right. here's the function within class Hero:
ActionScript Code:
public function keyDowns(event:KeyboardEvent){
if (event.keyCode == 65){
[Code]....
then in the main file i create an instance of Hero called turret i want to call turret.keyDowns() every frame. i'm trying to use this, but i get an error message "1120: access of undefined property event."
ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, turret.keyDowns);
turret.keyDowns(event);
View 4 Replies
Jan 29, 2012
I've been away from this forum for a couple of years but finally found the time to dig into AS3. Glad to be back (although motivated by frustration)
I have a main document (Main.fla), linked to a document class named "Main" in the AS-3-settings dialog box, but named "Main.as" on my harddrive.
I also wrote a simple tracing action and saved it as "xTrace.as"[code]...
View 6 Replies
Mar 14, 2010
I'm new to writing several different class files.. and trying to make a set of boxes that expand/collapse by mouse click and timer.I have 4 class files, Box, BoxGroup, BoxTimer, and Main.I can call the functions in Box class from BoxGroup class, but not the functions in the BoxTimer class. it keeps throwing this error. I don't understand why since i'm using the same method between the other 2 class files..ReferenceError: Error #1069: Property timer_start not found on CollapsingBox and there is no default value.at CollapsingBoxGroup/on_click()
View 11 Replies