ActionScript 3.0 :: Works Just In Constructor Function?

Jan 7, 2010

If I pass variable(s) like this in document class action script file(I'm not even sure if I can pass more than one variable):

Code:
ballPointRight = new BallPointRight(ball, xDir, padScreen) ;

And now the BallPointRight's action script file:

Code:
package {
import flash.display.MovieClip;[code]....

doesnt work since it doesnt recognize variables...

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Specify A Constructor Function For A Class?

Oct 11, 2009

I'm making a class called 'player', and really, I don't need a constructor function for it. Do you just outline the function, but don't put anything between the curly braces? Also, I'm a bit new with access levels. If I wanted my functions from my player class to be accessible from the main class, do I make them public?

View 3 Replies

Actionscript 3 :: Is A New Constructor Function Necessary When Subclassing

Jan 9, 2010

Basic OOP question... I want to add a couple functions to the Array class so that my program will be amazing and make me rich and famous overnight. So I create a new subclass NewArray which extends Array. Do I need to write a constructor method for NewArray? If I leave it blank will it just use the parent's (Array's) constructor method?

View 1 Replies

ActionScript 3.0 :: Store A Function Constructor In An Array?

Feb 14, 2009

Is it possible to store a function constructor in an array? I tried, but getting an error for example, say this is my function:

functiom openPages():void
{
trace("pages open");
}

and my array:

var myArray:Array= new Array(openPages);

View 7 Replies

ActionScript 3.0 :: Add Eventlistener In The Load Function And In The Constructor

May 14, 2009

I am trying to make a subclass of flash.display.Loader, which should do something when the loader completes loading the content. So I do addEventListener(Event.COMPLETE, onComplete) on my loader subclass. But this Eventlistener is never called. Is this supposed to happen? Can't I use an Eventlistener on the class that dispatches the event? My code looks like this: public class MyLoader

[Code]....

View 4 Replies

ActionScript 3.0 :: Pass A Child From The Constructor To Another Function?

Sep 6, 2010

I'm sure that I'm doing something daft here - I just need to remove a child that's created in the constructor through an event listener.My code is below but does not work. Can someone point me in the right direction please?

public class Main extends Sprite  public function Main()
super();
var rectangleIndex:uint = this.getChildIndex(playerBackground)

[code]......

View 5 Replies

ActionScript 3.0 :: Pass A Parameter To The Constructor Function

Mar 3, 2011

I´d like to know how could use the Timer class extended.I´m trying to pass a parameter to the constructor function, so I can use it inside the listener.
 
Here´s example:
 
[CODE]
package { import flash.utils.Timer import flash.display.DisplayObject public class ChangeColorTimer extends Timer {    public static const CHANGE_COLOR:String = "changeColor";    public var obj:DisplayObject    public function ChangeColorTimer(delay:Number, repeatCount:int, obj:DisplayObject ) {   super(delay, repeatCount)   this.obj = obj   } } }
[/CODE]
 
That was the ChangeColorTimer that extends Timer.Now, I´d want to know how would I use ChangeColorTimer.I thought it was the same as using Timer.I´ve tried this:
 
[CODE]
public function changeColor(mc:MovieClip):void  {   var colorTransform:ColorTransform = new ColorTransform()   colorTransform.color = 0xEE0000   mc.transform.colorTransform = colorTransform   var changeColorTimer:ChangeColorTimer = new ChangeColorTimer(400, 1, mc)   changeColorTimer.addEventListener(ChangeColorTimer.CHANGE_COLOR, setNormalColorListener)   changeColorTimer.start()     }  private function setNormalColorListener(e:Event):void{   trace("called")        }
[/CODE]
 
I called changeColor, but, I don´t get "called" in the output from the setNormalColorListener listener.

View 2 Replies

Actionscript 3 :: Receiving Name Of Calling Function Or Constructor?

Nov 7, 2010

is it possible to get the name of a calling function or the constructor from the called function? is it possible to determine the previous function of the thread?

i would like to call some setter functions from my constructor and have my setter functions determine if it was the constructor that called them.

currently, i'm setting a boolean for this functionality, but perhaps there is another way?

public function Constructor(myNumber:Number)
{
this.myNumber = myNumber;
}

[Code]....

View 2 Replies

ActionScript 3.0 :: Calling Constructor Function Within Same Class?

Jan 26, 2009

I have a document class name elevator and my constructor is also elevator as usualHow to call this constructor function within elevator class? Is is possible or not?

View 1 Replies

ActionScript 3.0 :: Passing Values From Constructor To Function(s)

Feb 11, 2009

I have a series values I'm passing (from an FLA) into the constructor of a class. I just want to make clear in my mind that, the only way to pass the variable params, to the function nowDoThis, you'll need a dispatchEvent or a custom event to send it along ?

As an example:

Code:
// constructor
public function MyFunction(_param1:uint, _param2:uint, _param3:uint) {
param1 = _param1;
param2 = _param2;

[Code].....

I have only a vague understanding of using objects and dispatch events. Isn't this something that people need to do all the time?

View 3 Replies

ActionScript 3.0 :: Flash Claims Function Is Not A Constructor But It Is?

Aug 18, 2010

Simplified ItemType Code, contained in Types/ItemType.as

Code:
public class ItemType
{
public static var SWORD:ItemType = new WeaponType(0, "Sword", null);
public function ItemType(id:uint, name:String, icon:Sprite)

[code]....

On attempting to compile, following error is displayed:

Code:
[Fault] exception, information=TypeError: Error #1115: Types::WeaponType is not a constructor.

View 3 Replies

ActionScript 3.0 :: Class With Static Function-like Constructor

Oct 15, 2010

I'm currently writing a class where I'd like to call the class constructor without having to instantiate the class itself. Something like this : Class:

[Code]...

trace(testString); //wil trace the text "test test123" Is it possible to somehow achieve this? When I write the costructor method like "public static function ClassName" it fails. Is there any other way?

View 3 Replies

ActionScript 3.0 :: Set Alpha To 30 Percent In Constructor Function - TypeError

Apr 7, 2009

I am new to AS3 and writing classes and keep having a hard time with these error messages I am getting. I have the following AS:
public class PrevNextNav {
public var back_next_nav:MovieClip;
public var next_btn:SimpleButton;
public function PrevNextNav() {
back_next_nav.next_btn.alpha = .3
} .... etc.

The class works fine, except when I try to set the alpha to 30% in the constructor function, I get this error in the output window.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at _classes::PrevNextNav()
at InteractivePilotDocument()
If I comment that line out, all is good. What does this mean?

View 8 Replies

ActionScript 3.0 :: Call Core Function/constructor By Its String Name

Jun 9, 2009

I worked out a way to call a function whose name is in a String variable. That is:
 
function myFunction()
{
trace("Hello!");
}

[Code]....

View 3 Replies

ActionScript 3.0 :: Unable To Run Next Statement In Constructor Main Function?

Jan 1, 2012

I have a main.as scipt whereby i put the following in the constructor main function.
 
L1: LoginScreen.enterBtn.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);
L2: map.visible=true;
 
it will execute checkLogin function but stuck at Line 1. how do i make it run Line 2?

View 1 Replies

Flash :: Make A Class Constructor Be Callable As A Function?

Dec 1, 2010

Some of the top level classes can be instantiated as well as called as a function (e.x. new Number() and Number(), new Boolean() and Boolean(), new Array() and Array()).

Usually this is used for type conversion or as a shortcut for instantiation. I would like to be able to do the same thing:

[Code]...

What I wanted to do originally was to create a logging class to interact with Flash/JavaScript, and be cross-browser compatible. I wanted to be able to use the log function as an alias of a method in the log class. This got me to wondering whether I could implement a custom casting function just because. I've now realized it's not possible, but was fun to play with anyway.

View 2 Replies

Actionscript 3 :: Loading SWF In AS3 But Flash Keeps Repeating Constructor Function?

Aug 22, 2011

I am importing several external files using the Loader-class, and one of them is an swf-file. When doing so (I had done it successfully before, so did not expect any issues), I ran into all sorts of errors, and finally Flash crashed.

I put down a trace in the constructor function, and it didn't trace just once, but kept on tracing, suggesting that the constructor was stuck on loop. I guess the loading of too many of the same swf is what causes flash to eventually crash.

Here is my code (the swf im loading is now a simple test-file which contains an image and no code):

private var slides:Loader = new Loader();
public function DocumentClass()
{

[Code]....

View 2 Replies

ActionScript 3.0 :: Do Something After Its Constructor Function Is Finished And The Object Has Been Created

Jun 10, 2010

I have a class which works with data and I want to do something after its constructor function is finished and the object has been created. If a class is a MovieClip, I can do this:

[Code]....

View 3 Replies

ActionScript 3.0 :: Flash Access Constructor Parameters From Another Function?

Feb 1, 2011

So I usually use an object in the constructor to receive the parameters like new Class({param1:00,param2:0099,etc).To be able to access those parameters from other functions inside the class I create an object, and copy it:

Code:
public class MyClass {
var params = {};
public function MyClass(p){

[code]....

View 6 Replies

ActionScript 3.0 :: Calling A DocumentClass Based Function From A Constructor Class?

Feb 17, 2011

I've got a simple program that consist of a document class and a buttonTemplate constructor class. I need to call a function called updateText that should be in the document class, when someone clicks on a button. So that after each button is clicked, it updates some text in my document class. My event listeners for the buttons are in the buttonTemplate class. My question is, how do you call a function in the document class from a constructor class? Here is my simplified code below

DOCUMENT CLASS

Code:

package {
import flash.display.MovieClip;
import flash.text.TextField;

[Code].....

View 6 Replies

ActionScript 3.0 :: Calling Constructor Function With Indefinite Number Of Parameters?

Mar 28, 2012

How do I call class constructor functions with indefinite number of arguments?

For example:(this piece of code doesnt serve any purpose, just to demonstrate an example)I wish to create a new class Foo with the parameters bar1, bar2, bar3, bar4.

[Code]...

View 9 Replies

ActionScript 3.0 :: Function Works Only Once?

Sep 19, 2009

I have a listener and a function for it on the main timeline, listening for TextEvents from links in a dynamic textbox nested somewhere in the movie. The problem is that everything works only once. I click on a link, it works, click again and it does nothing. I have to reload the objects for it to work again. What am I doing wrong? Do functions work only once when the main timeline is stopped?

View 1 Replies

ActionScript 3.0 :: Function Works Only On The Second Click

Dec 14, 2010

I created what I though was a pretty simple function for a mouse event listener. The funtion goes to a frame in the current movie clip as well as the parent movie clip. For some reason however the first time you click the button, it only effects the parent movie clip. When you click on it the second time, both movie clips are effected. Here is the script,

[Code]....

View 2 Replies

ActionScript 3.0 :: Function Works On Some Objects But Not Others?

Jun 10, 2011

And I don't know how to use the debugger in Actionscript. This is my code. It's in a class called GeoPiece and is being activated when a movieclip of instance GeoPiece is dragged over a movieclip of instance GeoPuzzle. lastObjOver is a place holder and is an instance of GeoPuzzle.

I want the mc from GeoPuzzle to highlight (goto frame "Over") when it is touched over and unhighlight (goto frame lock or out) when untouched. The script works perfectly - unless the GeoPuzzle piece was already locked. For some reason, it then sets itself to null and I can't figure out why.

ETA: The touchevent its responding to is a TOUCH_MOVE attached to the GeoPiece.

[Code]...

View 8 Replies

ActionScript 2.0 :: Function Works, But Not When Called By Interval?

Dec 14, 2009

I have a function ("advance_slideshow()") that ticks a slide show up by one, then it loops back at the end. It works when called from the key listener I set up for debugging. However it does not work when called from setInterval. I added a trace to the function to confirm that it was being called, which it is; it just doesn't work when called via the interval

Code:
//////////////////////////
/* IMPORTS AND INCLUDES */

[code].....

View 1 Replies

ActionScript 2.0 :: For Loop Works In Trace But Not In Function

Mar 9, 2010

I have 20 players in a game and cutting and pasting lots of code except for a few numbers. I have future features that would require over 400 lines of mostly repeated code. So I learned how to use "for", and practiced with a trace command. Traced the results exactly as I thought. However when I apply it to the guts of my function, the movie breaks down. I suspect it's because the function is being called on an EnterFrame command and the for loop I wrote is being executed over and over.

This works when I hand code:
Actionscript Code:
function drill(){GUESS0 = ((guess0min * 60)*1000) + ((guess0seconds * 1000))
GUESS1 = ((guess1min * 60)*1000) + ((guess1seconds * 1000))
GUESS2 = ((guess2min * 60)*1000) + ((guess2seconds * 1000))
GUESS3 = ((guess3min * 60)*1000) + ((guess3seconds * 1000))
GUESS20 = ((guess20min * 60)*1000) + ((guess20seconds * 1000))
//and then 300 more lines of other code}

And then a button later calls this when pressing:
Actionscript Code:
my_MC.onEnterFrame = function(){_root.drill ();
//so _root.drill is continually being called, which is good, because it has all sorts of data that needs to be refreshed, but I think it's screwing with my "for" loop.}

And the following is NOT working.
Actionscript Code:
function drill(){for (i=0;i<20;i++){
"GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));";}

But when I trace it in a separate test movie, it outputs exactly what I would hope it placed in the code:
Actionscript Code:
for (i=0;i<5;i++){trace("GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));");}

So at the end of the day, I guess I can trace these results in a test movie and use it to generate what I need, and cut and paste it into the project... but I thought 'for' loops were for saving time AND space. Am I using this code right? Maybe my use of "", or +, or i is misguided?

View 4 Replies

ActionScript 3.0 :: Function Only Works In Simple App But Not In Complex One

Mar 11, 2010

I made a simple app with 2 movieclip symbols containing photos of a butterfly with this actionscript:

import fl.transitions.Tween;
import fl.transitions.easing.*;
butterfly_mc.addEventListener(MouseEvent.CLICK, bigPic);
butterflyHand_mc.addEventListener(MouseEvent.CLICK, bigPic);
function bigPic(e:MouseEvent):void{ new Tween(e.currentTarget,"scaleX",Strong.easeOut, e.currentTarget.scaleX, (e.currentTarget.scaleX * 1.4), 4, false);
[Code] .....

I don't get any error messages but when I click on case1_mc.c1_mc.case1a_mc or case1_mc.c1_mc.case1b_mc nothing happens.

View 11 Replies

ActionScript 3.0 :: AddEventListener In A Function No Longer Works

Apr 23, 2011

Should that be avoided due to local scope factor? function resizeDisplay() below no longer works

[Code]...

View 4 Replies

ActionScript 3.0 :: Re-setInterval Each Time Function Works?

Mar 19, 2012

I have a function that draws a rectangle on the screen (see createInfoPanel())While drawing rectangle, I am adding 2 text fields on it.But as you may guess, it is adding those immediately. I want to delay adding these text fields, then I want to remove these panels after a while. The problem is, when I set an interval or timer, they won't work after I using once (I had to stop them by clearing/removing, it didn't set them again).Since my panel is being created each time image changes, I need them to work every time image changes.
 
So, I have 2 questions:1- How can I re-set interval each time my createInfoPanel() function works? It won't work anymore after setting and claring once. 2- You can see infoPanel.addChild(titleField); line in addInfoPanel() function. How can I work a smooth animation here? I mean, text appears slowly?

[Code]....

View 4 Replies

Actionscript 3 :: Measure How Long The Function Works

Sep 29, 2011

I am trying to compare the performance of several different algorithms. So created several functions each of them implementing different approach of solving the same task.What was thinking to do is to create 2 Date objects before and after the function runs, and to compare them afterwords.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved