ActionScript 3.0 :: Import Vs Include - Basic Functions To Be In BasicFunctions.as And The Make A Library For More Specific Functions
Jun 6, 2010
I've got a project thats getting a bit big, so Im taking the actionscript out into separate as files. I want all the basic functions to be in BasicFunctions.as and the make a library for more specific functions. I find that a lot of people use the import statement but I cant get that to work with a simple Hello World trace, yet the include statement works fine (see attached). I understand that import/include work differently, but which is the better method? If import, then is that heavier to work with. Any rate, what's the best way to organise code when it gets to the 1000+ lines?
[Code]....
View 9 Replies
Similar Posts:
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
Jun 21, 2011
I'm creating a Flash file which pulls in external SWFs onto a container. The main SWF which has the container clip is called Main.swf then we have external swf's.
So basically, we have Main.swf, English.swf, French.swf, More.swf
More.swf has a load of buttons on it (contact.swf, about,swf etc etc)
To make things neater, I wanted to put all of my button code in the Main.swf, and I've got it sorted so that English.swf, French.swf and More.swf load correctly into holder_MC which is on Main.swf
Now, to get the buttons working, I can either have the code situated in More.swf (in which case, can I change the contents of holder_MC which is located in Main.swf from within More.swf? If so, how?)
Or, I can have an event listener to say that when Main.swf is loaded, create these functions to link to contact.swf, about,swf etc etc)
View 1 Replies
Feb 26, 2010
I have a bunch of .fla files laying arround here.They are basic flash files with actions coded on the timeline.I want to add a class to control the files.In order to enable to sync the flash files I have a bunch of code in this class which takes care of the synchronising the files.The problem is; there are a lot of files.Personally, being a lazy person I don't think replacing basic functions like 'gotoAndPlay' with my personal functions.I would prefer to just extend the basic function, or listen for it so I can 'inject' my own pieces of code. Question: Is there a way to have something like a listener that tells me which functions are started? Is there a way to extend basic flash functions like gotoAndPlay() or play().
View 1 Replies
Oct 11, 2010
I have a flash file (banner ad) that uses some jpgs that I imported onto the stage. When I publish the file... It won't include the images. If the images are in the same folder as the swf.. it will work. However, just the SWF on its own will not display the images. Any ideas?
View 1 Replies
Dec 29, 2010
I have a main actionscript file import other actionscript files into it to use their function. From the tutorials and training videos I have, other external classes apart from the document class always link to an object in the library or an object in the main.as is an instance of the other class, for example:[code]
The problem is I'm not creating any variables from the external class but only want to use the functions from it. When I test the movie, I get error 1180: Call to a possibly undefined method isPossibleNo, which is inside class ProjectileNo that is imported already.So my question is how I can use external functions without creating a new instance of the external class because they only hold calculation functions.
View 2 Replies
Oct 6, 2011
I have a series of calculations i'm doing over a bunch of objects stored in a array. Each function is pretty CPU demanding but if you only run one function, it just works fine.
[Code]...
View 2 Replies
Nov 4, 2009
I'm trying to find a way to have global functions in my as project, similar to how flash does with stuff like the util functions (describeType()...), where you can just call the function wherever you need it. For example:
[Code]...
So when I call Test(), it prints out "hello world" fine. My problem comes in that I can't change the name of the Test function, and I can't add any other functions without compiler errors. Is it possible to have a load of global functions in one file, or do I have to split them up into separate files like in the example? Also, I know that I can make a Global class and call static functions like Code: Global.doSomething() but I'd like to know if there's a way to do it as flash does it (describeType(), getDefinitionByName(), etc), or rather, how does flash do it?
View 9 Replies
Nov 25, 2010
Is it not possible to call other functions from generic mouse event functions?
Code:
_root.myButton.onPress = function(){
hide();
[code]......
View 6 Replies
Jun 17, 2004
I have one function that puts text in a text field and makes a button goto a url onRelease.The code is like this:
Code:
item.onRelease = function() {
myButton.onRelease = function() {
getURL("http://google.com", "_blank");
}
talk = this.txt;
}
the only problem is that the button doesn't work onRelease. i think that it is because there are too many functions there, but at the same time,
View 5 Replies
Dec 2, 2004
in this example why the values of (12) and (21,39) are lost at the geo and geo1 functions
[code]...
View 11 Replies
Mar 4, 2009
Is there a way to do that without using a bunch of "if" or "switch" statements, like shoving them all in an array?I have a rough idea of how it would work, but I have no idea how it would look in code.And just to clarify,I mean an order than can be changed.Otherwise I wouldn't need to think about this at all.
View 6 Replies
Oct 25, 2011
Im adding lot of simple functions to prototypes of top level objects ( Object , Array , String ...) and have 2 questions :
Is possible to add functions to top level's classes in compile-time ?
If not , is there a way to allow this functions to compile ? I dont like to turn off strict mode
ex:
string.removeWhiteSpace();
string.sliceStr("." , "end");
textField.scrollBottom();
this return compile-time error , cause there is no such function , i have to write it in braces :
string["removeWhiteSpace"]();
string["sliceStr"]("." , "end");
textField["scrollBottom"]();
and i like to aviod it )
View 2 Replies
Mar 16, 2003
Is it not possible to call other functions from generic mouse event functions? Surely it is !!??ie....
Code:
_root.myButton.onPress = function(){
hide();
[code]........
View 11 Replies
Feb 14, 2009
I am having a bit of a problem. I have my document class (documentClass.as) and a class for functions (functions.as).How would I go about importing functions.as so that I can use the functions in it?
View 2 Replies
Jan 14, 2011
Functions embedded inside other functions? In all my years of ActionScript programming, I've never seen this (this is part of legacy code written by someone else which I am adapting):
[Code]....
View 6 Replies
Mar 19, 2010
Its a complicated senario for me. I have a sound management singleton with an asset like dictionary storing all referances to my urls and assets and the guff inside it-
I have a function called addItem(id:String, url:String):Object
I would love to do something similar as soundManager.addItem(id:String, url:String).play() or soundManager.addItem(id:String, url:String).stop() of which it'll both add my item to my dictionary, and begin playing the sound
[Code]...
View 2 Replies
Dec 27, 2009
Let's I have a class Square that has a several functions. I want to call it from a class Grid, which is a group of Squares.So in the class file for Grid, how would I do this:
Code:
public function doSquareFunction(thisFunction:Function):void{
square1.thisFunction();
[code]......
View 8 Replies
Nov 9, 2005
I have a function with 4 necessary arguments (aka parameters) in order to perform the actions. I would like to have the ability to pass the same function to itself as an argument (sort of like a recursive function) along with its arguments. Basically I want to "base" to engage an onMotionFinished event handler if there is another function passed as an argument. Something like...
[Code].....
Would there be a way to use listeners to do this or the AsBroadcaster?
View 6 Replies
Oct 21, 2010
Is there a way I can find out all the classes that are related specifically to the iphone in CS5? (ie Accelerometer, Gestures...ec)
What I want to do specifically is try to access the camera and then if there is none (say it is an old ipod touch) then go to a photos/camera roll folder and show those. Apparently in the help files, in the Air 2.5 runtime there is a "browseForImage" function that allows you to go to said cameraRoll but it will not compile if I publish under the iphone OS option (does not have specific stuff I am importing from an example flash.media.MediaType, flash.events.MediaEvent, flash.media.MediaPromise). Upon looking up the errors, there is no mention whether it is for a specific device.
View 0 Replies
Nov 18, 2011
I'm working on a simple image processor in AS3 and as usual I almost had it finished when an annoying little problem appeared. I want to open an image using a dialog box, and once the image is open I want the "selectBtn" (which is in my Library) to disappear. However when I try the code below I get a: "Error #1009: Cannot access a property or method of a null object reference". I'm sure it's something simple but I just can't figure it out!
// declare variables
var image:Bitmap;
var loader:Loader = new Loader();
[code]....
View 1 Replies
Aug 18, 2009
I`m using flash cs3 for my works , but i have one problem!when i use File=> Import=> Import to Library... or Import to Stage...the flash environment becomes terminated.I changed my flash version to CS4 and I have this problem again.
View 2 Replies
Jul 7, 2010
following code:
[Code].....
even once i'v executed "getMcInfo", I get "null" from the trace statement in "changeBorderColor", I should get [object blabla]. I know this has something to do with the scope of the variable "MC" but i just can't fine a solution..
View 1 Replies
Jun 10, 2009
The XML file is structured this way....<Node myURL="images/cow.jpg" myTitle="Cow" myDesc=" libero sed dapibus aliquet, quam risus luctus lacus, vitae tincidunt dui diam dictum mauris. Morbi tempor, Nunc eleifend sapien ut odio pharetra eu aliquet eros fermentum.Proin et nisi vel risus eleifend pulvinar. "myThumb="images/thumbs/cow_thumb.jpg" here it is...
allOnlinelink.push(element .@onlinelink); allOfflinelink.push(element .@offlinelink);
the next function pulls the url of the current index
[code].....
View 1 Replies
Dec 9, 2011
i have 4 buttons below
ActionScript Code:
home_btn.addEventListener(MouseEvent.CLICK, goto_home);
about_btn.addEventListener(MouseEvent.CLICK, goto_about);
portfolio_btn.addEventListener(MouseEvent.CLICK, goto_poftfolio);
contact_btn.addEventListener(MouseEvent.CLICK, goto_contact);
[code]....
View 9 Replies
Apr 28, 2004
Is it possible to make global functions, much in the same way you make a global variable, reachable from anywhere in the project?
View 1 Replies
Aug 19, 2010
can you make a button have multiple functions? as in if i click a button one and imahe will pop up and then click that same button and another different image will pop up??
View 1 Replies
Apr 13, 2011
So I've been trying to make dynamically named functions, and while it works, I've run into a couple of problems.
ActionScript Code:
var uServer:String = "irc.epic-chat.net"
var lol:String = "lolz"
var num:Number = 3
[Code].....
If I had something like that ^ what could I add to func to distinguish between whether it is being called by lolz0, lolz1, or lolz2? I was thinking whether there was something like .name I could use, but I couldn't come up with anything.
View 9 Replies
Nov 9, 2003
wrote the code for motion straight into the action panel of the bubble symbol and simply duplicated the symbol alot to add more bubbles. What I wanted to do is change all that code into global functions that can simply be called by each movie clip thereby cleaning it up alot and making it more modifyable. The problem is that I can't figure out how to write and call the functions properly. Here is what I have:
Layers:
Actions: where the functions are defined
Bubble: contains symbols (clip calling the functions)
[code].....
View 6 Replies
Jul 14, 2003
how to move from one frame to another (once clips complete their actions). I had previously posted some questions regarding this matter, but I think the post got too long and confusing (at least to myself).SO I'm starting over from scratch and want to go step by step so I can understand. I have a line clip on stage that I move down the screen and center and expand it at the same time to fit the width of the stage. Now I have this code for that:
[AS]
goDownAndCenter=function()
{
[code].....
View 5 Replies