ActionScript 3.0 :: Accessing Functions In Separate File?
Feb 5, 2010
I'm working on an mp3 player. It makes use of a custom scrollbar I found here: [URL]
I've gotten it to work so far, but there is one bit I would like to add. I would like it to scroll to specific y-coords when a button is clicked. The code for the scrollbar is all in an external AS file, which is referred to by an exported movieclip in the main fla.
how I would go about referring to this file, or just some other method of doing this? I'll paste the AS code as well as the basic fla code.
fla code:
Code:
var s:Sprite = new Sprite();
txt_mc.spacer.visible = false;
sb.init(txt_mc, "easeOutBack",0,true,2);
[Code]....
View 3 Replies
Similar Posts:
May 5, 2010
I would like to know if this is actually possible in AS3. I'm not really fluent in Java-style programming, but very used to C++'s .cpp and .h file system. Right now my functions are defined where my class is defined, so as you can imagine, my classes look incredibly untidy and disorganized.
[Code]...
View 6 Replies
Jan 31, 2010
i'm kind of beginner/intermediate level (more so beginner i'd say) at AS3, and i'm trying to make a tower defence style game... ATM i'm using internal code, but would it be better to switch to external?Anyway, the problem is, at the moment i'm not sure how to impelment a way of saying, if an enemy spawn hit tests "icearea" then just trace ("in range"); but i get errors no matter where i insert the equivlent code...[code]
View 3 Replies
Jul 30, 2009
This is doable in almost every language ive coded in. I would like to place a function in a separate .as file, as to not clutter up my main .as file. Ive already got about 15 classes in separate files and I know there must be some way to do this and its got to be pretty obvious.
View 7 Replies
May 15, 2011
Okay, so I'm creating a game. I currently have 2 scenes. The first scene is called Opening, the second is Main.The first scene has a title screen and then a button that the user will click to start the game (essentially go to the second scene).However, I'm getting the error: Error #1009: Cannot access a property or method of a null object reference.at code:ocument()t's throwing this error where I'm calling my event listener for start_btnMy code is below:
Document:
ActionScript Code:
{
[code].....
View 6 Replies
May 4, 2010
When my document class attempts to instantiate a class in a separate package I get the error:1137: Incorrect number of arguments. Expected no more than 0.This is in reference to the following line:[code]As you can see, I have imported the package:[code]And here is the class that expects 0 arguments:[code]As you can see I properly labeled the Level1 class as part of the Levels package:[code]
View 4 Replies
Sep 17, 2010
I've managed to create a button which on MOUSE_DOWN scales its parent object- it works just like windows in your OS, where you grab the corner and can change the scale of the window.
Here's how I've done it, (minus the MOUSE_DOWN listener)
Code:
function scaleDragHandler(event:Event):void {
var mcWidth:Number = event.target.parent.width;
var mcHeight:Number = event.target.parent.height;
[Code].....
However, it throws the error, "Access to undefined property 'scaleMC'" on the removeEventListener line. My thought was to put another listener for mouse up inside the first, but that sounds wrong
View 2 Replies
Nov 18, 2009
I have just started learning AS3 (2-3 weeks) and I have to say its very enjoyable!I am trying to make a function that pulls in values to save me writing 15 separate functions!I have a "street mc" which has 15 "house mc's" inside.When the user hovers over a house I want the resident to appear above the house.The house instance name is house1 and there is a mc in the library linked using the MrsRoy() class.This is my code so far:
Code:
var house1Res:MovieClip = new MrsRoy();
function resIconIn(e:MouseEvent):void{
var currentHouse = "street." + e.target.name;
var currentRes = e.target.name + "Res";
[code]....
I get the error:
TypeError: Error #1006: value is not a function.
at Dignity_drive_fla::MainTimeline/resIconIn()
View 1 Replies
Jan 7, 2012
I am trying to load various swfs into a main swf. The initial swf loads in by default, the others load when buttons are clicked. All of the buttons also call a lengthy function called loadpic which appears later in the code - Currently the buttons load in the swfs as required, however the swfs are always behind the initial default swf. Is there a way to add removeChild to the buttons? I have tried creating seperate functions for each button and added the line removeChild(); however doing that means I would also have to repeat all of the later functions as well. If I add removeChild(); without placing it in a function the default swf doesn't show at all.
[Code]....
View 9 Replies
Sep 14, 2010
I would like to ask on how do you access a child's function in AS3 I have tried "ChildMovieClip.childfunction();" so far it does not work.
View 3 Replies
Jul 14, 2010
I'm trying to create a JW player plugin, a part of the source code is shown below:
public function initPlugin(player:IPlayer, config:PluginConfig):void {
api = player;
var streamUrl:String = 'xxx';
[code].....
View 1 Replies
Jan 15, 2009
I'm working on a flash video player and I'm trying to figure out how to access something inside the constructor that I know is set but it keeps telling me its not.
[Code]....
now in the metadata function its giving me the error, "Access of undefined property video" Now, am I just completely not understanding how classes work or is this a common problem?
View 4 Replies
Jun 30, 2010
I have a file which loads a series of SWFs. It loads one, allows it to play to completion, then stops. Right now, it will just wait for the user to press a button and select the next one. However, I need it to play them sequentially. Is there any way for the SWFs which get loaded to access the functions which control the SWF loading?
View 4 Replies
Sep 8, 2011
I've been working my way towards better OOP design lately and I've come across a problem with accessing functions in other classes from my Main class. Here is the code:
Main.as
ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
They are listening for functions that are within the Player.as class, these functions control the dynamics/movement of the player itelf. But for some reason I'm getting a 1120 error(access of undefined property). Basically how do you listen/access for functions within a different class?
View 5 Replies
Sep 8, 2008
I'm sorry if this has been answered 1,000 times, but I am so confused with everything!! In the main timeline of my movie, I have a container movieclip called "content". I want to load an external swf into content, and then access the functions in that swf. I can load it no problem, but I can't for the life of me figure out how to access the functions, I can't seem to find it anywhere!
View 3 Replies
Sep 22, 2009
How can i access a function that is in a movieclip from the root?
i've tried these :
mcName.functionName();
MoviClip(mcName).functionName();
but all of them didn't work at all.
View 1 Replies
Nov 21, 2005
I'm creating a soundboard, and and I've been using Flash for about 2 weeks and Actionscript for about a week, so you'll have to excuse my ignorance. I've used google to look for specific things to no avail so here I am.Okay, so, I have a soundboard that, when pressing a button, it will hide or show certain buttons on the page, to give the feeling of multiple pages. All my visibility stuff works like a champ.
Right now, in the working version of my soundboard, I'm not using functions to instantiate my linkable objects, create the array, or populate the array to hold the linkable objects. I would like to use functions to make my code less obtuse. I looked around for a while trying to figure out how to pass an array of objects into a function but i haven't had much success. I'm not quite sure if it's even possible to do. These are the errors I get:
1120: Access of undefined property playArraySound001.
1061: Call to a possibly undefined method play through a reference with static type Class.
1120: Access of undefined property playArraySound001.
1120: Access of undefined property GordonSoundArray.
1136: Incorrect number of arguments. Expected 1.
The first code is what works, the next code is the stuff that doesn't work.This is the working version
Code:
//////////// CODE FOR PLAYING SOUNDS
//// This is creating an instance of the Linkable object
var playArraySound001:Link_10_minutes = new Link_10_minutes();
var playArraySound002:Link_3_eggs = new Link_3_eggs();
[code]....
View 5 Replies
Aug 1, 2004
how to access variables that are declared in a movie clip from a function declared in that same movie clip.
i.e.
****************************
var int1 = 1
var int2 = 2
[Code]....
I'm trying to do this in the main movie clip of a movie that I plan on importing dynamically in another movie. I've tried to use this.int1++, but I think that flash was looking for a variable that belongs to "myfunction" when I did that. I could just use _root.int1++ but like I said, I plan on dynamically loading this into another movie, in which case it would be pointing to the wrong movie.
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
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
Aug 29, 2010
I use the following jQuery code to access functions in my SWF (FP 10.1 SWF embedded via SWFObject): $('#FlashApp')[0].someFunc(); This works fine in every browser.. except for Internet Explorer (surprise!). Surely, the point of jQuery is to make this code work across all browsers? I'd really rather not write extra code to check for IE. How can I talk to my SWF in a browser independent way?
View 3 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
Oct 24, 2009
I'm creating a soundboard, and and I've been using Flash for about 2 weeks and Actionscript for about a week, so you'll have to excuse my ignorance. I've used google to look for specific things to no avail so here Okay, so, I have a soundboard that, when pressing a button, it will hide or show certain buttons on the page, to give the feeling of multiple pages. All my visibility stuff works like a champ.
Right now, in the working version of my soundboard, I'm not using functions to instantiate my linkable objects, create the array, or populate the array to hold the linkable objects. I would like to use functions to make my code less obtuse. I looked around for a while trying to figure out how to pass an array of objects into a function but i haven't had much success. I'm not quite sure if it's even possible to do.
[Code]...
View 0 Replies
Mar 26, 2010
I'm trying to make a button that gets it's getURL address from an external text file. So, I load the text file and assign it to a variable:
[Code]....
View 5 Replies
Dec 14, 2004
Short description of my project:I'm making a "flash-car-damage-registration-program" where a user can click on a part of a car, make two choices (from two comboboxes) that describes the damage, and then save it in a datagrid withing flash.I have split up the code in different class files:I have a damage.as class file that describes the damage and its properties.I have a carPart.as class file that extends the Movieclip class. This sets all the propertiesof each carpart and where the roll-over/out eventlisteners are, pluss som escriptive text to each carpart. This works the way I want it to. This is just to quickly give you an idea of what I'm working on.So to the real question or problem: I have a LoadMyXmlData.as class file where I load some xml data, this works fine. A function in this class takes a combobox and a xmllist as parameters.
I want to populate the mentioned comboboxes from the xml data. Both comboboxes are on the stage within another movieclip, but I can seem to access them. (yes, they have instancenames etc) I get error 1120: 'Access of undefined property'. I have tried ways like: containingMc.comboboxMc' and so forth but no luck. I have been searching the web for days for a solution to my problem, but nothing so far.
View 1 Replies
Jun 22, 2009
How can one class access a nested function in another class.Examplish.
Code:
main class{
public function main(){
[code].....
View 3 Replies
Jun 2, 2011
Which of the following is better in terms of performance/effectiveness?
public var a:int = 0;
public function Addition():void {
a += 5;
[code].....
View 7 Replies
Jan 27, 2008
class fial
{
public var num = 5;
[code].....
View 1 Replies
Jun 8, 2010
I am having a situation with my actionscript/flex front end.
[Code]...
I am expecting to have 3 Alert windows containing A, B and C. But the actual result is 3 alert windows all showing C
View 1 Replies
Jan 15, 2009
I'm working on a flash video player and I'm trying to figure out how to access something inside the constructor that I know is set but it keeps telling me its not.
Here is the code
Select allpackage player {
import flash.display.Sprite;
import flash.media.Video;
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.utils.Timer;
[Code] .....
Now in the metadata function its giving me the error, "Access of undefined property video". Now, am I just completely not understanding how classes work or is this a common problem?
View 2 Replies