Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








No Default Constructor Found In Base Class Ball


i don't even understand why this error shows up.
searched with google, but people seem to get this error for slightly different reasons

i've got 3 classes: Ball, PlayerBall and ShootBall, the last two extending Ball.
this is the Ball class:


PHP Code:




public class Ball extends MovieClip    {        public var nSpeedX:Number;        public var nSpeedY:Number;                public function Ball( X,Y,NSpeedX:Number, NSpeedY:Number):void        {            nSpeedX = NSpeedX;            nSpeedY = NSpeedY;            x = X;            y = Y;                this.addEventListener(Event.ENTER_FRAME,onEnterFrameHandler);        }




FlashKit > Flash Help > Actionscript 3.0
Posted on: 10-05-2008, 01:04 PM


View Complete Forum Thread with Replies

Sponsored Links:

No Default Constructor Found In Base Class Ball
i want the class BeginBall to extend Ball, but when i do so, this error shows up.
this is my code:

PHP Code:



package
{
    import flash.events.Event;
    import flash.display.MovieClip;
    
    public class Ball extends MovieClip
    {
        public var nSpeedX:Number;
        public var nSpeedY:Number;
        public var ballNr:int;
        const BALLDIAMETER = 10;
        private var nStageWidth:Number = 500;
        private var nStageHeight:Number = 400;
        
        public function Ball ( X,Y,NSpeedX:Number, NSpeedY:Number ) : void
        {
            nSpeedX = NSpeedX;
            nSpeedY = NSpeedY;
            x = X;
            y = Y;
            
            this.addEventListener ( Event.ENTER_FRAME, onEnterFrameHandler );
        }
        
        private function onEnterFrameHandler ( E:Event ) : void
        {
            this.x -= nSpeedX;
            this.y -= nSpeedY;
            
            if ( this.x >= nStageWidth - BALLDIAMETER - 16 )
            {
                this.x = nStageWidth - BALLDIAMETER - 16;
                nSpeedX *= -1;
            }
            else if ( this.x <= BALLDIAMETER + 16 )
            {
                this.x = BALLDIAMETER + 16;
                nSpeedX *= -1;
            }
            
            if ( this.y >= nStageHeight - BALLDIAMETER - 16 )
            {
                this.y = nStageHeight - BALLDIAMETER - 16;
                nSpeedY *= -1;
            }
            else if ( this.y <= BALLDIAMETER + 16 )
            {
                this.y = BALLDIAMETER + 16;
                nSpeedY *= -1;
            }
            
        }
    }//end of class
    
    public class BeginBall extends Ball
    {
        //alles over spatieknop en muisknop etc.
    }
}




i tried to do public last class Ball, butit says access identifiers are not allowed with namespace attributes.
how can i let BeginBall normally inherit Ball's constructor, or if its not possible, make a new one for BeginBall?

View Replies !    View Related
1203: No Default Constructor Found In Base Class Flash.display:BitmapData
I'm trying to create a game that utilizes blitting and double buffering for performance. I have a PNG in the library called ball.png that's linked to a class called ball (seen below).

When I instantiate it, I get the following: 1203: No default constructor found in base class flash.display:BitmapData. Any way around this? I'd like to store relevant properties of the object in itself (as you can see by _posx, _vy, etc.).


ActionScript Code:
package {
    import flash.display.BitmapData;
    import flash.geom.Point;
    import flash.geom.Rectangle;
   
    public class ball extends BitmapData {
        private var _posx:Number = 0;
        private var _posy:Number = 0;
        private var _vx:Number = 0;
        private var _vy:Number = 0;
        private var _myRect:Rectangle = new Rectangle(0,0,19,19);
        private var _myPoint:Point = new Point(0,0);
       
        public function ball():void {
            trace('created ball')
        }
    }
}

View Replies !    View Related
Base Class Constructor Help.
Ok I have the 2 classes below. Page & CurrentPage. CurrentPage is a subclass of Page but whenever I create an instance of CurrentPage I get this error.


Quote:




1203: No default constructor found in base class classes.data:Page.




I've tried changing the constructor methods for both classes & no matter what I do I get this message. Could someone help me out here?

Page Class

ActionScript Code:
package classes.data {
   
    import flash.net.*;
   
    public class Page {
        protected var _title:String;
        protected var _showReel:Boolean;
        protected var _link:String;
        protected var _bgURL:URLRequest;
       
        public function Page(title, showReel, link) {
            _title = title;
            _showReel = showReel;
            _link = link;
            _bgURL = new URLRequest("images/"+title.toLowerCase()+"/bg.jpg");
        }
       
        public function get title():String {
            return _title;
        }
       
        public function get showReel():Boolean {
            return _showReel;
        }
       
        public function get bgURL():URLRequest {
            return _bgURL;
        }
       
        public function get link():String {
            return _link;
        }
    }
   
}

CurrentPage Class

ActionScript Code:
package classes.data {
   
    import classes.data.Page;
    import flash.net.*;
   
    public class CurrentPage extends Page{
       
        public function CurrentPage() {
           
        }
       
        public function changePage(page:Page):void {
            _title = page.title;
            _showReel = page.showReel;
            _bgURL = page.bgURL;
        }
       
        public function bgLocation(bg:String):void {
            _bgURL = new URLRequest(bg);
        }
    }
}

Thanks

View Replies !    View Related
The Definition Of The Base-class UIComponent Was Not Found
Hello,

I try to run the Lisp Interpreter in AS3 form here http://www.solve-et-coagula.com/?p=8
I load the fla-source into a fresh CS3.

When I want to publish it I get:

1017: The Definition of the base-class UIComponent was not found


import fl.core.UIComponent;

public class Console extends UIComponent =>This line throws the error


The help-file say that the keyword 'extends' in only allowed for publishing with Actionscript 2 ?
But setting it to 2 throws a whole bunch of other errors.

So what do I wrong?

I contacted also the developer Nate Lokers, but he told me that he has no problems to compile it.
(And that I must leave it under AS3)

Hans-Peter

View Replies !    View Related
Definition Of Base Class Movie Clip Not Found
i wrote this code and i dont know what happened
heres the code i wrote:

hello.as
Code:
package
{
import flash.display.Sprite

public class hello extends MovieClip
{
public function hello()
{
trace('Hello Ryland');
}
}
}
and heres what my terminal spit out:


Code:
ryland@ryland-desktop:~/Desktop$ mxmlc hello.as
Loading configuration file /usr/local/flex/frameworks/flex-config.xml
/home/ryland/Desktop/hello.as(5): col: 32 Error: The definition of base class MovieClip was not found.

public class hello extends MovieClip
^

ryland@ryland-desktop:~/Desktop$
what happened

View Replies !    View Related
Error: The Definition Of Base Class MovieClip Was Not Found
i wrote this code and i dont know what happened
heres the code i wrote:

hello.as
Code:
package
{
import flash.display.Sprite

public class hello extends MovieClip
{
public function hello()
{
trace('Hello Ryland');
}
}
}


and heres what my terminal spit out:


Code:
ryland@ryland-desktop:~/Desktop$ mxmlc hello.as
Loading configuration file /usr/local/flex/frameworks/flex-config.xml
/home/ryland/Desktop/hello.as(5): col: 32 Error: The definition of base class MovieClip was not found.

public class hello extends MovieClip
^

ryland@ryland-desktop:~/Desktop$


what happened

View Replies !    View Related
1017: The Definition Of Base Class MovieClip Was Not Found
I imported
flash.display.*;
then used
dynamic public class Anonymous extends Movieclip
{
//Other codes
}

But error is occuring showing
1017: The definition of base class MovieClip was not found.
I am working in a project & it includes a lot of as classes & it is one of them. Please reply what can be the problem?

View Replies !    View Related
1203: No Default Constructor...
Base Class

Code:
package
{
import flash.display.*

public class BaseDefaultConstructor extends MovieClip
{
public function BaseDefaultConstructor(foo)
{
trace(foo)
}
}
}
Extended Class

Code:
package
{
import flash.display.*

public class DefaultConstructor extends BaseDefaultConstructor
{
// 1203: No default constructor found in base class BaseDefaultConstructor.
/*
public function DefaultConstructor()
{
super("123")
}
*/
}
}
To work, I need to uncomment this constructor, or I get that error (1203:...)

Why Base classes on AS3 doesn´t directly inherity parent constructor?
Why I must have to redefine it?

View Replies !    View Related
AS Default Values In Constructor
Hi,

I have a class:

Code:


class elem{
var name:Number;
var date:Number;

function elem(name:Number, date:Number = 20) {
this.name = name;
this.date= date;
}
}



What I am trying to do is give a default value for date.

Example:

Code:


var obj1:elem = new elem(10);
var obj2:elem = new elem(10, 50);
trace(obj1.date); //would be 20
trace(obj2.date); //would be 50



would be possible in AS?

View Replies !    View Related
Default Constructors With Base Classes?
Hi,

I have a 3 movieClips, each with the same base class, I would like to set up basic positioning up when instantiating the clips:

var Mc1:MovieClip1 = new MovieClip1(x, y);

My base class has a default constructor such as this:


Code:
package classes {
import flash.display.MovieClip;
public class baseClass extends MovieClip {
public function baseClass (x:int, y:int){
//Do positioning stuff here
}
}
}
The problem is that I get 1203 errors about an incorrect number of arguments. Is it correct that base classes cannot have any arguments on their default constructors and is there any way around this?

Many thanks!

View Replies !    View Related
Error #1069: Property _scale Not Found On Scope.SiteTextUi And There Is No Default Va
I really need help fixing this error ...

ReferenceError: Error #1069: Property _scale not found on scope.SiteTextUi and there is no default value.

I am using Caurina Tweener

I've been informed on other forums that I can

1.) make _scale a dynamic class
2.) use a different tweener engine (like TweenLite)
3.) define _scale

I am a Flash Designer with some developer understanding however most error message look like gibberish to me, so the above may come across as simplistic for a developer with years of experience but for me I don't know how to do it. I was given this file as a .swf and decompiled it using sothink .. I just need the script to work so that I can change the graphics (update) and some of the xml.

Any Help Is Very Appreciated

Here is the Script from the scope.as class:

package scope
{
import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
import scope.events.*;

public class SiteTextUi extends MovieClip
{
private var xpos:Number;
private var captionsText:Bitmap;
private var indexPos:int;
private var minScale:Number = 0.2;
private var bg:Sprite;
private var ypos:Number;
private var bezierY:Number;
private var bezierX:Number;
private var blur:Number;
private var scale:Number;
private var soundEffect:Object;
private var mxml:XML;
private var randTime:Number;
private var maxScale:Number = 0.8;
private var targetAlpha:Number = 0.3;
private var view:view_btn;
private var parentObj:Object;
public static var ACTIVATE_UI:String = "activateui";
public static var FADE_UI:String = "fadeui";
public static var SHUFFLE_UI:String = "shuffleui";
public static var DEACTIVATE_UI:String = "deactivateui";

public function SiteTextUi(param1:XML, param2:int, param3:Object, param4:Object)
{
minScale = 0.2;
maxScale = 0.8;
targetAlpha = 0.3;
this.mxml = param1;
this.indexPos = param2;
this.soundEffect = param3;
this.parentObj = param4;
captionsText = UtilMethods.setUpTextBitmap2(String(param1.project label).toUpperCase(), 45, -9);
captionsText.smoothing = true;
addChild(captionsText);
bg = new Sprite();
UtilMethods.draw(bg, 0, 0, 0, 1, 1);
bg.height = captionsText.height;
bg.width = captionsText.width;
bg.width = 350;
var _loc_5:int;
bg.x = 0;
bg.y = _loc_5;
bg.alpha = 0;
addChildAt(bg, 0);
view = new view_btn();
view.x = 5;
view.y = captionsText.height - 10;
view.alpha = 0;
view.enabled = false;
addChild(view);
view.addEventListener(MouseEvent.CLICK, handleClickOnView);
bg.addEventListener(MouseEvent.CLICK, handleClick);
bg.buttonMode = true;
bg.useHandCursor = true;
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
return;
}// end function

private function fadeUiHandler(param1:Event) : void
{
if (param1.target !== this)
{
targetAlpha = targetAlpha * 0.4;
Tweener.addTween(this, {alpha:targetAlpha, time:3, transition:"easeOutCirc"});
}// end if
return;
}// end function

private function positionContent(param1:Boolean) : void
{
var _loc_2:int;
_loc_2 = 340;
xpos = randRange(20, stage.stageWidth - _loc_2);
ypos = randRange(this.height + 50, stage.stageHeight - 100);
bezierX = randRange(20, stage.stageWidth - _loc_2 * 0.5);
bezierY = randRange(this.height + 50, stage.stageHeight - 100);
if (param1)
{
scale = Math.max(1 / indexPos, minScale);
targetAlpha = scale;
blur = 8 - scale * 10;
}
else
{
scale = randRange(0.1, 0.8);
targetAlpha = scale;
blur = 7 - scale * 10;
}// end else if
randTime = randRange(0.3, 2.5);
Tweener.addTween(this, {alpha:targetAlpha, _scale:scale, time:randTime, transition:"easeOutCirc"});
Tweener.addTween(this, {xpos, y:ypos, _bezierx:bezierX, y:bezierY}, _blur_blurX:blur, _blur_blurY:blur, _blur_quality:1, time:randTime, transition:"easeOutCirc"});
return;
}// end function

private function layOutContent() : void
{
this.y = 100 + stage.stageHeight + this.height;
this.x = 100 + Math.random() * stage.stageWidth - this.width;
positionContent(true);
return;
}// end function

private function checkDisplayStatus(param1:ContentEvent) : void
{
if (param1.infoObj != "ProjectsSection")
{
dispatchEvent(new Event(SiteTextUi.DEACTIVATE_UI, true));
}// end if
if (param1.infoObj == "ProjectsSection")
{
dispatchEvent(new Event(SiteTextUi.ACTIVATE_UI, true));
dispatchEvent(new Event(SiteTextUi.SHUFFLE_UI, true));
}// end if
return;
}// end function

private function shuffleUiHandler(param1:Event) : void
{
if (param1.target !== this)
{
positionContent(false);
if (this.view.enabled)
{
Tweener.addTween(view, {alpha:0, time:0.4, transition:"easeOutCirc"});
view.enabled = false;
addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
bg.addEventListener(MouseEvent.CLICK, handleClick);
}// end if
}// end if
return;
}// end function

private function handleRollOver(param1:MouseEvent) : void
{
Tweener.addTween(this, {alpha:1, _blur_blurX:0.1, _blur_blurY:0.1, _blur_quality:1, time:0.4, transition:"easeOutCirc"});
return;
}// end function

private function handleRollOut(param1:MouseEvent) : void
{
Tweener.addTween(this, {alpha:targetAlpha, _blur_blurX:blur, _blur_blurY:blur, _blur_quality:1, time:1, transition:"easeOutCirc"});
return;
}// end function

private function activateUiHandler(param1:Event) : void
{
addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
bg.addEventListener(MouseEvent.CLICK, handleClick);
bg.useHandCursor = true;
if (this.view.enabled)
{
Tweener.addTween(view, {alpha:0, time:0.4, transition:"easeOutCirc"});
view.enabled = false;
}// end if
positionContent(false);
return;
}// end function

private function handleClick(param1:MouseEvent) : void
{
var event:* = param1;
dispatchEvent(new Event("VIDEOUITEXTCLICK", true));
removeEventListener(MouseEvent.ROLL_OVER, handleRollOver);
removeEventListener(MouseEvent.ROLL_OUT, handleRollOut);
bg.removeEventListener(MouseEvent.CLICK, handleClick);
view.enabled = true;
Tweener.addTween(view, {alpha:1, time:1, delay:1.5, transition:"easeOutCirc"});
Tweener.addTween(this, {alpha:1, _scale:1, time:1.5, transition:"easeOutCirc", onComplete:
function ()
{
dispatchEvent(new Event(SiteTextUi.FADE_UI, true));
return;
}// end function
});
Tweener.addTween(this, {x:stage.stageWidth * 0.5 - 340 * 0.5, y:stage.stageHeight * 0.5 - this.height * 0.5, _bezierx:bezierX, y:bezierY}, _blur_blurX:0, _blur_blurY:0, _blur_quality:1, time:1.5, transition:"easeOutCirc"});
dispatchEvent(new Event(SiteTextUi.SHUFFLE_UI, true));
parentObj.setChildIndex(this, parentObj.numChildren--);
soundEffect.playSound();
return;
}// end function

private function randRange(param1:Number, param2:Number) : Number
{
var _loc_3:Number;
_loc_3 = Math.random() * (param2 - param1) + param1;
return _loc_3;
}// end function

private function handleClickOnView(param1:MouseEvent) : void
{
var _loc_2:VideoDisplay;
_loc_2 = new VideoDisplay(mxml);
this.parent.addChild(_loc_2);
return;
}// end function

private function addedToStageHandler(param1:Event) : void
{
stage.addEventListener(SiteTextUi.ACTIVATE_UI, activateUiHandler);
stage.addEventListener(SiteTextUi.DEACTIVATE_UI, deActivateUiHandler);
stage.addEventListener(SiteTextUi.SHUFFLE_UI, shuffleUiHandler);
stage.addEventListener(SiteTextUi.FADE_UI, fadeUiHandler);
stage.addEventListener(VideoDisplay.VIDEO_WIDGET_C LOSE, activateUiHandler);
stage.addEventListener("CONTENT_EVENT", checkDisplayStatus);
layOutContent();
return;
}// end function

private function deActivateUiHandler(param1:Event) : void
{
removeEventListener(MouseEvent.ROLL_OVER, handleRollOver);
removeEventListener(MouseEvent.ROLL_OUT, handleRollOut);
bg.removeEventListener(MouseEvent.CLICK, handleClick);
bg.useHandCursor = false;
Tweener.addTween(this, {alpha:0, time:0.5, transition:"easeOutCirc"});
return;
}// end function

}
}

View Replies !    View Related
Adding A Class Constructor For My Class Gets TypeError..
I have a class Cannon, which is linked from my library..
When I don't have the constructor in, and on the first frame of my timeline I do:

Code:
addChild(new Cannon());
It works perfectly.

But, when I add the constructor, even if there is nothing in the constructor, i get this error at compile-time:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Cannon$iinit()
at cannon_fla::MainTimeline/cannon_fla::frame1()
Does anyone know whats going on?

This is my shortened code with the constructor:

Code:
package {
public class Cannon extends MovieClip{
...
public function Cannon(){
...
}
...
}
}

View Replies !    View Related
Linkage Class / Base Class Conflict?
I'm trying to create Flash components for Flex. Part of that is linking the library entry for a movie clip to the class definition of it. In this case, it's a simple blue square that I'm trying to link to view.BlueSquare which extends mx.core.UIMovieClip. It finds the class successfully, but I am unable to close the dialog box because I get an alert warning me that the base class will not be used as I click the OK button. The only way I am able to close the dialog box is if I do not enter the name of an existing class file in the "Class" field. This is very frustrating... what am I doing wrong?

View Replies !    View Related
Works As A Doc Class, But Not A Base Class?
I'm trying to get my head around working with classes in AS 3. The following as works as a document class just fine, but does not work if I try to use it as a base class (under linkage) . I'm not a programmer and am trying to self-teach so be gentle. Thoughts appreciated as I'm rather stuck here.

And while I'm at it: anyone have any good guides to learning as3?

Code:

package drawing{
import flash.display.MovieClip;
import flash.events.Event;
import line1;



public class simpleLoop extends MovieClip
{

var _line:line1;
var _lineX:Number = 100;
var _lineY:Number = 400;
var _lineR:Number = 0;
var _lineScale:Number = 1.0;
var _lineA:Number= 1;




public function simpleLoop():void{



for (var i:Number=0; i<3000; i++)
{
_line = new line1();
addChild(_line);
_line.x = _lineX;
_line.y = _lineY;
_line.scaleY = _lineScale;
_line.scaleX = _lineScale;
_line.rotation = _lineR;
_line.alpha = _lineA;
_lineA -=.002;
_lineR +=.5;
_lineY ++;
_lineX ++;
_lineScale-=.02;


}
}
}
}

//works as doc class but not as a base class for line.

View Replies !    View Related
Bouncing Ball Class Off Other Class Objects
Hello again people. Im getting far now with this AS3 learning and classes in general. Now im wondering how I will get my ball which is in a class and is called to the stage to bounce off my bats which are in other classes and are called to the stage. Heres my code all help would be great thanks in advance

Heres my Main.as class file which calls the classes onto the stage and moves m bats


Code:
package classes{

import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

import classes.nets.Nets;
import classes.bats.Leftbat;
import classes.bats.Rightbat;
import classes.ball.Ball;

public class Main extends Sprite{

// Variables
public var nets:Sprite;
public var myleftbat:Sprite;
public var myrightbat:Sprite;
public var myball:Sprite;

public function Main(){
nets = new Nets();
myleftbat = new Leftbat();
myrightbat = new Rightbat();
myball = new Ball();
//
addChild(nets);
addChild(myleftbat);
addChild(myrightbat);
addChild(myball);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);

}

private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y <-250) {
myleftbat.y =-250;
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y > 249) {
myleftbat.y = 249;
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myrightbat.y <-250) {
myrightbat.y =-250;
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myrightbat.y > 249) {
myrightbat.y = 249;
}
break;
}
}

}
}
And here are my bat classes, these just draw the bats

The left bat

Code:
package classes.bats{

import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.*;

public class Leftbat extends Sprite {

public function Leftbat():void {
graphics.lineStyle(1);
graphics.beginFill(0x2f9b4b);
graphics.drawRect(0,250,25,100);
graphics.endFill();
}
}
}
The right bat

Code:
package classes.bats{

import flash.display.Sprite;

public class Rightbat extends Sprite{

public function Rightbat(){
graphics.lineStyle(1);
graphics.beginFill(0x2a00ff);
graphics.drawRect(774,250,25,100);
graphics.endFill();

}
}
}
And Finally my ball class, this creates the ball and makes it move around the stage


Code:
package classes.ball{

import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class Ball extends Sprite

{

private var myBall:BallClip;

public function Ball( )
{
myBall = new BallClip( );
addChild( myBall );

var moveTimer:Timer = new Timer( 25 );
moveTimer.addEventListener( TimerEvent.TIMER , myBall.step );
moveTimer.start( );
}
}
}

import flash.display.Sprite;
import flash.events.TimerEvent;

class BallClip extends Sprite
{

private var xspeed:Number;
private var yspeed:Number;

public function BallClip ( )

{

graphics.lineStyle(1);
graphics.beginFill( 0xffffff , 1 );
graphics.drawCircle( 20 , 20 , 15 );
graphics.endFill( );

x = 400;
y = 300;

xspeed = Math.random( )*5;
yspeed = Math.random( )*3;

}

public function step ( timeEvent:TimerEvent ):void
{

if ( x + xspeed > 850 ) xspeed *= -1;
if ( x + xspeed < -50 ) xspeed *= -1;
if ( y + yspeed > 570 ) yspeed *= -1;
if ( y + yspeed < 0 ) yspeed *= -1;

x += xspeed;
y += yspeed;

}
}
Now I know it will involve checking the balls x posistion and then bouncing it back if it meets the bats x posistion, but how do I do this? Can I check classes within classes?

View Replies !    View Related
Bouncing Ball Class Off Other Class Objects
Hello again people. Im getting far now with this AS3 learning and classes in general. Now im wondering how I will get my ball which is in a class and is called to the stage to bounce off my bats which are in other classes and are called to the stage. Heres my code all help would be great thanks in advance

Heres my Main.as class file which calls the classes onto the stage and moves m bats


Code:
package classes{

import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

import classes.nets.Nets;
import classes.bats.Leftbat;
import classes.bats.Rightbat;
import classes.ball.Ball;

public class Main extends Sprite{

// Variables
public var nets:Sprite;
public var myleftbat:Sprite;
public var myrightbat:Sprite;
public var myball:Sprite;

public function Main(){
nets = new Nets();
myleftbat = new Leftbat();
myrightbat = new Rightbat();
myball = new Ball();
//
addChild(nets);
addChild(myleftbat);
addChild(myrightbat);
addChild(myball);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);

}

private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y <-250) {
myleftbat.y =-250;
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y > 249) {
myleftbat.y = 249;
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myrightbat.y <-250) {
myrightbat.y =-250;
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myrightbat.y > 249) {
myrightbat.y = 249;
}
break;
}
}

}
}
And here are my bat classes, these just draw the bats

The left bat

Code:
package classes.bats{

import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.*;

public class Leftbat extends Sprite {

public function Leftbat():void {
graphics.lineStyle(1);
graphics.beginFill(0x2f9b4b);
graphics.drawRect(0,250,25,100);
graphics.endFill();
}
}
}
The right bat

Code:
package classes.bats{

import flash.display.Sprite;

public class Rightbat extends Sprite{

public function Rightbat(){
graphics.lineStyle(1);
graphics.beginFill(0x2a00ff);
graphics.drawRect(774,250,25,100);
graphics.endFill();

}
}
}
And Finally my ball class, this creates the ball and makes it move around the stage


Code:
package classes.ball{

import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class Ball extends Sprite

{

private var myBall:BallClip;

public function Ball( )
{
myBall = new BallClip( );
addChild( myBall );

var moveTimer:Timer = new Timer( 25 );
moveTimer.addEventListener( TimerEvent.TIMER , myBall.step );
moveTimer.start( );
}
}
}

import flash.display.Sprite;
import flash.events.TimerEvent;

class BallClip extends Sprite
{

private var xspeed:Number;
private var yspeed:Number;

public function BallClip ( )

{

graphics.lineStyle(1);
graphics.beginFill( 0xffffff , 1 );
graphics.drawCircle( 20 , 20 , 15 );
graphics.endFill( );

x = 400;
y = 300;

xspeed = Math.random( )*5;
yspeed = Math.random( )*3;

}

public function step ( timeEvent:TimerEvent ):void
{

if ( x + xspeed > 850 ) xspeed *= -1;
if ( x + xspeed < -50 ) xspeed *= -1;
if ( y + yspeed > 570 ) yspeed *= -1;
if ( y + yspeed < 0 ) yspeed *= -1;

x += xspeed;
y += yspeed;

}
}
Now I know it will involve checking the balls x posistion and then bouncing it back if it meets the bats x posistion, but how do I do this? Can I check classes within classes?

View Replies !    View Related
Class And Constructor
Code:
class Iso {
private var xOrg:Number;
private var yOrg:Number;
//
function Iso(flashWidth:Number, flashHeight:Number, offsetY:Number) {
yOrg = flashHeight-offsetY;
xOrg = flashWidth/2;
}
//
private function yFla(xIso, yIso) {
return (yOrg-(yIso+xIso)/2);
}
private function xFla(xIso, yIso) {
return (xIso+xOrg)-yIso;
}
//
public function setPixelQuality() {
_quality = "LOW";
}
//
public function MoveIsoTo(x_iso, y_iso) {
_root.moveTo(xFla(x_iso, y_iso), yFla(x_iso, y_iso));
}
public function DrawLineTo(x_iso, y_iso) {
_root.lineTo(xFla(x_iso, y_iso), yFla(x_iso, y_iso));
}
}
i get an error:
**Error** C:Documents and SettingsBojan JazbinsekMy Documentsisoiso.as: Line 1: The class 'Iso' needs to be defined in a file whose relative path is 'Iso.as'.
class Iso {

tnx for help

View Replies !    View Related
Why Do We Need A Base Class For Mc's
hello;

if we must declare a 'class' for an mc, why do we also have to declare a 'base class'??

TRUE or NOT TRUE : the 'class' is a descendant of the 'base class';

if TRUE then the 'base class' declaration is necessarily implied via inheritance through the 'class' and thus it is redundant;

any thoughts?


thanks
dsdsdsdsd

View Replies !    View Related
Help With Base Class?
I am trying to apply a class to several movieClips in my library. My reading of essential actionscript 3.0 said that applying my class to the base class and letting flash generate the movieclip class would allow me to do this. However, if I want to have an initialize varialbe it crashes saying that the unique movieclip class isnt expecting a variable passed to it. What can I do?

I hear a lot about good programming practices using classes and importing classes over includes. Is there really any point in doing this? is it more efficient perhaps, because it seems like wasted effort.

View Replies !    View Related
Ref From A Base Class
I have 3 menus each one will have the same animation I have given each once an class id and used my main package class as the base class ie

menu1 class = config.property_nav
base = config.nav_controls

menu2 class = config.product_nav
base = config.nav_controls

how do I target mc's within the property_nav / product_nav from my main package class

View Replies !    View Related
Problems With AS 2.0 Class Constructor
I am trying to create a class named AddNumber, here is my code:

class AddNumber {

function AddNumber (digit) {
if (clear) {
clear = false;
decimal = false;
display = "0";
}
if (display == "0" and digit != ".") {
display = digit;
} else {
display = display + digit;
}
}
}
}


When I check the syntax I get this error:
Line 16: ActionScript 2.0 class scripts may only define class or interface constructs.

What am I doing wrong? Someone please help me!

View Replies !    View Related
Class Constructor Called Twice
Its easiest just to read the code:

Code:
class Spaceship extends MovieClip {
function Spaceship (startx:Number, starty:Number, LinkageName:String){
_root.attachMovie(LinkageName, "spaceship1", getNextHighestDepth());
_root.spaceship1._x = startx;
_root.spaceship1._y = starty;
}
}

mySpaceShip:Spaceship = new SpaceShip(150,150,"spaceship");
this basically calls the constructor twice, once when the Spaceship object is instantiated and again in attachMovie (thusly calling the constructor again). So i end up with spaceship1 on the stage and myspaceship just kinda floating around i guess. The actual movie clip im using for the spaceship is linked through the library and needs to remain that way. Is there so way i can just link mySpaceShip to the target in my library like:

Code:
this._target = _library.spaceship
bottom line, I cant have two constructor calls every time i instantiate and i can just place the clip on the stage before runtime. Thanks

View Replies !    View Related
OOP Class Constructor Problems
I have written a class which is working fine, but I'm having some problems when defining things from inside the class constructor.
On the root timeline this code works:

_root["p"+pNo].blahblahblah.....

but this doesn't:

_root[eval("p"+pNo)].blahblahblah....

whereas in the class constructor, only using eval() will work for the same thing, why is this?

But that isn't the major problem, my constructor creates a movieclip in the root that is associated with the object in my class. After creating the movie clip I have this code:

_root[eval("particle"+this.no)]._x = this.sx;
_root[eval("particle"+this.no)]._y = this.sy;
_root[eval("particle"+this.no)].no = this.no;
_root[eval("particle"+this.no)].onEnterFrame = function(){

It sets the _x and _y fine, but it refuses to define the no variable, and it refuses to define the onEnterFrame, both don't exist when i check the variables in the debugger. Maybe I can't define remote variables from inside a constructor?
Any help is appreciated. =)

View Replies !    View Related
Simple Class Constructor Help
i want to create a class in a variable on a different level to the code

e.g. instead of
var menu_button:MenuButton = new MenuButton();

i want to do

var myMovieClip.menu_button:MenuButton = new MenuButton();

but i can't figure out the syntax. I've searched for something on this but havn't had any luck.

Any ideas of the right syntax?

View Replies !    View Related
DoLater Within Class Constructor.
If I do blah.TextInput.doLater(this,later); inside a class constructor, and then define a function later(){} inside the class why doesnt later() get executed?

View Replies !    View Related
Reload A Constructor From Within The Class?
Hey,

Is it possible to reload a constructor (with new input) from within the class?

Thanks,
Guy

View Replies !    View Related
Onenterframe In Class Constructor
Hey all,
Im completely messed up about this maybe you guys can help. How on earth do you get onEnterFrame working properly within a as2.0 class. Im trying to simply set an MCs _y based on another MCs _y, onEnterframe. I have a feeling im caught into some sort of variable scope issue. Heres my code.....


PHP Code:



//buld main nav - button_holder
var button_holder:Object = _root.createEmptyMovieClip("button_holder", 6);
var button_holder_mc:Object = button_holder.attachMovie ("button_holder", "button_holder", 0);
button_holder_mc._x = 0;
                    
    button_holder.onEnterFrame = function(){
    trace(_root.div.div_bg._y);
    button_holder._y = _root.div.div_bg._y;
    } 




The trace in the onenterframe comes back undefined, so thats most likely the issue...but _root.div.div_bg._y is an absolute path Im ot understanding why it wouldnt work..if this is a varibble scope issue can someone explain what a scope issue is or point me to a good explanation of what they are and how to fix them?

Thanks.

View Replies !    View Related
[AS3] Class Constructor Question
hello.... i'm trying to create some code which would create instances of arbitrary classes. for example... i'm making a game which will be hosted on a site, and characters i create over time will eventually be selectable for use in game. but instead of uploading an entirely new game whenever i decide to add a new character, i'd prefer to just update an xml file listing the characters, as well as an swf file for each character class.

so during actual runtime, i'd have to create instances of these characters.... but i wouldn't necesarily know which character class constructor i'd be creating.... it would depend on who the user selects.

if it were up to me, i'd be able to decide what class instance i'd like to make from a string variable (taken from xml).

like this maybe...

var classname:String = "CharacterOne()";

var character:Object = new classname;

....instead of having to write: var character:CharacterOne = new CharacterOne();


any ideas? is there something simple i'm missing? by the way, i am using as3.

View Replies !    View Related
Constructor In A Class...please Clarify.
Hey all,

I am trying to start making more object-oriented apps with Flash. But there is something I am having trouble understanding.

When creating a class, what is a constructor?
Also, why does a class need a constructor?

Many thanks in advance.

View Replies !    View Related
Linked Class Constructor
I have a movieclip in my library that I have linked to a class with a constructor that takes a parameter. But I can't instantiate the library clip with the class constructor. It says the constructor should not take any parameters. Is it using the movieclip constructor instead of the linked class? Is it possible to get around this?


Code:

public class MessageBox extends Sprite
{
public function MessageBox(txt : String)
{
}
}

Code:

// MsgBox is the library clip that has linked the above class (MessageBox).
var msg : MsgBox = new MsgBox("blablablabablab");

View Replies !    View Related
Class Constructor.apply?
Does anyone know how to use the apply function on a class constructor? I know you can't do new Class.apply(), so I'm thinking that you're supposed to get the class' constructor function and use apply on that, something I can't figure out (typeof(class.constructor) returns a class??)

moveClass is already defined as the class I need to instantiate. The below, obviously, doesn't work, but it's what I'm trying to accomplish.

Code:
public static function moveObj(...pars){
var m=new moveClass.apply(null,pars);
}

View Replies !    View Related
Sound Obj W/in A Class Constructor
Has anyone been successful in creating a function that creates a class that also creates a sound object??

//Example

function jukebox(track){
this.audio=new Sound(this._name);
this.audio.start(this._name);
}


//somewhere in my fla

on(release){

myMusic=new _root.jukebox(this._name);

}

Please advise.

Thanks

BX

View Replies !    View Related
Concatenating Onto A Class Constructor
this one is so ridiculous i dont even know what to enter as a search criteria. anybody know if this is possible? i have some movieClips in the library, all connected to the same base class. they have class names like mcAltTag0, mcAltTag1, etc. i would like to spin them out in a for loop, and dont know if its possible to concatenate the value of var i:Number onto the constructor call. anyways, my humble attempt looks something like this:
Code:

for(var i:Number = 0; i < 5; i**)
{
      _altTag[i] = new mcAltTag + i; //this is the bit that is biting my bottom, should evaluate to mcAltTag0, mcAltTag1, etc.
   addChild(_altTag[i]);
   _altTag[i].x = 197;
   _altTag[i].y = 162.2;
}

i tried all of the old as2 methods that i could think of, but of course they dont work. is this even possible?
ps, maybe i should mention that the mcs have these names because they have a 3d text bit that i cant do via xml.

View Replies !    View Related
Change A Base Class
Hello, I have a movieClip with a custom base class in my library. I have about 300 of these movieClips with the same base class. What I would like to do is have the ability to switch out the base class with the default base class (flash.display.MovieClip). All I want is the symbol without the linked class attached. Any help would be great. Thanks, Jake

View Replies !    View Related
Base Class Import
where can i find a list of imports for classes? such as:

import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;


thanks

View Replies !    View Related
Base Class In Library?
Hey everyone

I have a movieclip on the stage.

In my library I go into the Linkage Properties of this movieclip, and set these properties:

Class: contactItem (suggested name)
Base Class: MenuItem

I have made a MenuItem class that extends MovieClip.

When I test this I get:

Code:
1046: Type was not found or was not a compile-time constant: contactItem.
What is the problem with this? I haven't made a class called contactItem, but shouldn't Flash make one on Export automatically?

Can anyone give me a guide on how to use the Base Class?

View Replies !    View Related
Constructor Of Class The Inherit MovieClip
How can I pass parameters to a constructor of class the inherit MovieClip?

View Replies !    View Related
Class Constructor And Memory Usage
Code:
class MyClass{
public var $test:String;
public var $foo:Function;
function MyClass(){
this.$test = "hello";
this.$foo=function(){}
}
public function boo():Void{ }
}


when i put in the constructor a function does it copy in memory every time an instance of the class is being made????
beacuse i know in other languages when u put a function out side the constructor
it dosent matter how many times u have made an instance of the class the function will always been made only once!
does it the same for function in constructors?
thnaks in advance
peleg

View Replies !    View Related
Class Constructor Function - Please Explain
I consider myself an intermediate Flash coder, and I've been teaching myself about classes. I understand how they work, except for one thing: Constructor Functions.

I've read the Flash documentation on what they are and what their function is. This, I do understant. I just don't understand how they work. Take, for example, the following code that is offered as an example by the Flash documentation:


Code:
class User {
// private instance variables
private var __username:String;
private var __password:String;

// constructor statement
public function User(p_username:String, p_password:String) {
this.__username = p_username;
this.__password = p_password;
}

public function get username():String {
return this.__username;
}
public function set username(value:String):Void {
this.__username = value;
}

public function get password():String {
return this.__password;
}
public function set password(value:String):Void {
this.__password = value;
}
}


The thing that I don't understand is: how is the constructor function calling the setter function without explicitly calling it? If it is callling the setter function, how is it doing that? All that I see is that it is setting a the variables "__username" and "__password".

You'd think that it would have to be written like so:


Code:

// constructor statement
public function User(p_username:String, p_password:String) {
username(p_username);
password(p_password);
}


Can annyone help me bridge the gap here?

Thanks!

View Replies !    View Related
Can I Make A Class With Inherited Constructor?
I have a class called EnemyBehavior that has a constructor where I give it some values and it works fine and all.

Then I have another class called DifferentBehavior that extends EnemyBehavior and the only thing it does is it overrides one function in it (not the constructor).

Do I still need to give DifferentBehavior it's own constructor? Shouldn't it use EnemyBehavior's constructor?

So I could call use them just like this
enemyBehavior = new EnemyBehavior(enemy, someParameters);
differentBehavior = new DifferentBehavior(enemy, someParameters);

This is what DifferentBehavior looks like

PHP Code:



package  {    public class DifferentBehavior extends EnemyBehavior{        override public function attackBehav(curEn:Enemy, hero:Char):void {            trace('DIFFERENT BEHAVIOR');        }            }    }




edit: I forgot about super(); so ignore this

View Replies !    View Related
Class Constructor Not Accepting Arguments
Ok, I feel kinda dumb asking this,

I moved all my code into a class and everything works. But then when I try to add parameters in my constructor function for the class I get the Error 1136: Incorrect number of arguments Expected 0.

Any ideas why it will not take any arguments?

Here is my code from the stage

Code:
var contentDSP_mc:ContentMenu = new ContentMenu("demoMenu.xml");


And here is the first part of my class

Code:
package com.vistage
{
import flash.display.MovieClip;
import flash.text.TextField;

public class ContentDsp extends MovieClip
{
private var _xmlFile:String

public function ContentDsp(xmlFile:String)
{..........

View Replies !    View Related
A Constructor With An Instance Of That Class As A Parameter?
I'd like a function to make an exact copy of an instance. Traditionally, I've always written clone functions with long lists of parameters, but it seems that the simplest thing to do is write a constructor that accepts one parameter: an instance of the class. Something like this:


Quote:




public function Box(originalBox:Box)
{
this.shape = originalBox.shape;
this.color = originalBox.color;
}




Is this doable? Is it bad form?

Thanks a lot. Any quick feedback is appreciated.

Dave

View Replies !    View Related
Assigning Tween Class Constructor?
hello,

Im building some functions using the tween class, and am having problems assigning the easing method as an object in the constructor

here is my script:

ActionScript Code:
import mx.transitions.*;
import mx.transitions.easing.*;
function gotoAndFade ( mcname:MovieClip, init8bit:Number, end8bit:Number, yposinit:Number, yposend:Number, xposinit:Number, xposend:Number, easingmethodtween:Object, tweenseconds:Number, fadeseconds:Number ) {
   
    new Tween(mcname, "_alpha", None.easeIn, init8bit, end8bit, fadeseconds, true);
    new Tween(mcname, "_y", myObject, yposinit, yposend, tweenseconds, true);
    new Tween(mcname, "_x", myObject, xposinit, xposend, tweenseconds, true);
    // usage: gotoAndFade ( test, 0, 100, 5, 50, 325, 325, Bounce.easeIn, 1, 1 );
};

I need to be able to assign the constructor easingmethodtween:Object with Bounce.easeIn for example, but when I trace it comes back undefined, unless i assign it as a string, but then it doesnt work...

Anyone have an idea of why my constructor wont work?

ive tried adding:

ActionScript Code:
var myObject = new Object();
    myObject = easingmethodtween;

to the function but it still wont assign the string I need, driving me crazy!

any help is MUCH appreciated!

Thanks,
Anthony

View Replies !    View Related
Class Constructor Function - Please Explain
I consider myself an intermediate Flash coder, and I've been teaching myself about classes. I understand how they work, except for one thing: Constructor Functions.

I've read the Flash documentation on what they are and what their function is. This, I do understant. I just don't understand how they work. Take, for example, the following code that is offered as an example by the Flash documentation:


Code:

class User {
// private instance variables
private var __username:String;
private var __password:String;

// constructor statement
public function User(p_username:String, p_password:String) {
this.__username = p_username;
this.__password = p_password;
}

public function get username():String {
return this.__username;
}
public function set username(value:String):Void {
this.__username = value;
}

public function get password():String {
return this.__password;
}
public function set password(value:String):Void {
this.__password = value;
}
}
The thing that I don't understand is: how is the constructor function calling the setter function without explicitly calling it? If it is callling the setter function, how is it doing that? All that I see is that it is setting the variables "__username" and "__password".

You'd think that it would have to be written like so:


Code:

// constructor statement
public function User(p_username:String, p_password:String) {
username(p_username);
password(p_password);
}
Can annyone help me bridge the gap here?

Thanks!

View Replies !    View Related
Class Issues After Constructor Runs.
I'm building this crossword game in flash, and things were going fine until all of a sudden I ran into issues.

One class of mine called "LetterGrid" seems to break after the constructor has run. Everything inside the constructor works, but if I try to call any functions of that class instance, they never work. Also if I trace out the instance of the LetterGrid in the class that initially created it, I only get "undefined". One person I treid to get help from said it was scope issues, but after analyzing my code I don't see how that is possible.

Here is the problem class:

Code:
class com.crossword.LetterGrid {

private var letterCount:Number

private var cols:Number;
private var rows:Number;

private var targetMC:MovieClip;

private var link_LetterCell:String;

function LetterGrid(_targetMC:MovieClip ,_cols:Number, _rows:Number, _link_LetterCell:String){
letterCount = 0;
targetMC = _targetMC;
cols = _cols;
rows = _rows;
link_LetterCell = _link_LetterCell;
generate();
trace("DONeE");
}

public function testFunction():Void{
trace("THIS SHOULD CALL");
}

public function insertWords(_wordArray:Array):Void{
trace("eee");
trace(_wordArray);
}

private function generate():Void{
for(var ii:Number = 0; ii<rows; ii++){
for(var jj:Number = 0; jj<cols; jj++){
var letterMC:MovieClip = targetMC.attachMovie(link_LetterCell,"cell"+jj+"_"+ii,letterCount);
letterCount++;
letterMC._x = jj*32;
letterMC._y = ii*32;
}
}
trace("DONE");
}

}
And here is the class where I create the instance of LetterGrid:


Code:
import com.crossword.LetterGrid;
class com.crossword.CrossWord {

private static var crossWordCount:Number = 0;

//Settings Default Values
private var cols:Number = 10;
private var rows:Number = 10;
private var link_LetterCell:String = "letterCell";

private var targetMC:MovieClip;
private var holderMC:MovieClip;
private var gridHolder:MovieClip;

private var lg:LetterGrid;

private var isCreated:Boolean;

private var crosswordXML:XML;

public var crosswordWords:Array;

function CrossWord(_targetMC:MovieClip, _crosswordXML:XML){
targetMC = _targetMC;
crosswordXML = _crosswordXML;

isCreated = false;

holderMC = targetMC.createEmptyMovieClip("crosswordHolder"+crossWordCount+"_mc",targetMC.getNextHighestDepth());
gridHolder = holderMC.createEmptyMovieClip("gridHolder",0);

parseCrossword();

crossWordCount++;
}

private function parseCrossword():Void{
crosswordWords = new Array();
var rootNode:XMLNode = crosswordXML.firstChild;
var aNode:XMLNode = rootNode.firstChild;

cols = Number(aNode.firstChild.nodeValue);
aNode = aNode.nextSibling;
rows = Number(aNode.firstChild.nodeValue);
aNode = aNode.nextSibling;

for (var aNode:XMLNode = aNode.firstChild; aNode != null; aNode = aNode.nextSibling) {
crosswordWords.push(aNode.attributes);
}

}

public function create():Void{
isCreated = true;
lg = new LetterGrid(gridHolder,cols,rows,link_LetterCell);
trace(lg);
lg.testFunction();
trace(lg);
trace(lg);
trace(lg);

//letterGrid.insertWords(crosswordWords);
//trace(crosswordWords.length);
}

private function error(){trace("There was an error");}

}
I've tried clearing my ASO, compiling the FLA on multiple computers, and reinstalling Flash. All with no luck.

Also, here is all my code and the .fla file. Any help is appreciated.

http://brentalan.com/crossword.zip

View Replies !    View Related
Change Textformat In Class Constructor?
change Textformat in class constructor?

i have a class of objects that when instantiated, create a child movieclip and text labels (part numbers) inside of it. problem is i can't figure out how to set the font size and style for those text fields when i create them. apparently you have to create a Textformat object, and then use the setTextFormat method of the textfield class to change that stuff.

problem is, since i'm doing this in a class, i need to declare the textformat object in the class properties. but it throws an error if i say

public var textFormat1:Object = new TextFormat();

because it says

"A class's instance variables may only be initialized to compile-time constant expressions."

don't have this problem if i do it in an .fla file. anyway, i'm lost. please help.

View Replies !    View Related
Constructor Class Does Not Accept Parameters
on the fla file :


ActionScript Code:
var d0:daire = new daire(3);

on the Daire.as :

ActionScript Code:
package
{
    import flash.display.MovieClip;
       
    class Daire extends MovieClip
    {
        function Daire (z:Number)
        {
            x=Math.random()*200+50+z;
   
        }
    }
}

I get "Incorrect Number Of Arguments"

View Replies !    View Related
Passing Arguments To A Constructor Of A Class
Hi, I'm having trouble passing arguments to a constructor of a class. I'm initializing a new object of a Class that has required parameters. The class is in a different package than the Class that is calling the object.
When I have both classes in the same package the object is successfully initialized, but when I move the classes to different packages, I get error "1136: Incorrect number of arguments. Expected 0.", but in reality it should be expecting more than 0.
I'm importing the packages correctly, any ideas why it is saying that it is expecting 0 arguments?

View Replies !    View Related
Calling A Variable From Another Class In The Constructor
public class Player{
public function Player(){
theTime = (MovieClip(stage.getChildAt(0))).gameTime;
}
}

So it won't let me access gameTime in the constructor (gameTime is a public variable). stupid $$iinit(). but i still need it to access the gameTime exactly upon the creation of the Player object. How do I do this?

View Replies !    View Related
Calling Constructor Function Within Same Class
Dear users,
I have a document class name elevator and my constructor is also elevator as usual
How to call this constructor function within elevator class? Is is possible or not?
Please guide me on this.

View Replies !    View Related
Class Constructor Won't Call Function
Hello,

I attached a pared down version of my .as file, which is imported into my flash (.fla) file. I can't seem to call the initCircularArray function from my class constructor. The trace function in the initCircularArray never gets called, and the onLoad(success) trace returns 'true'. Any idea what I might be doing wrong?

Thanks,
Dave









Attach Code

class CircularArray {
var circularArray:Array = new Array();
public function CircularArray(inXML:String) {
var newXML = new XML(); //the XML file
newXML.load(inXML);
newXML.ignoreWhite = true;
newXML.onLoad = function(success:Boolean) {
if(success) {
trace("XML loaded: " + success);
initCircularArray(newXML);
}
}
}
public function initCircularArray(newXML:XML) {
trace("

GOT HERE

");
}
}

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved