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




Working On An A*: TypeError



I'm attempting to make a pathfinding class based on the A* algorithm. I'm trying to find what's wrong with my logic and coding - this is a work in progress. It does not have any graphical stuff; it's all in the trace. I keep ending up with this error but I just don't know why:


Code:
TypeError: Error #1010: A term is undefined and has no properties.
at pathFinder3/findPath()
at main()
Just open the attachment, extract the files and run the fla. It's all in the trace output from there on. The code is quite commented, but I'll be around to clear anything up. Oh, and the gameField is just an array of zeros (unwalkable) and ones (walkable). Any help appreciated



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 01-21-2008, 08:02 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

TypeError?
I've been trying to figure out why I keep seeing a typeError in my logs for a stream archive system that I built using this popular online article:
http://www.informit.com/articles/article.asp?p=31667

The error I'm seeing is below:
2007-04-03 14:57:27 20741 (s)2641173 ---Current stream: av_2 -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.Reset -
2007-04-03 14:57:27 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:57:27 20741 (s)2641173 av_2 info.code = NetStream.Play.Reset, NaN -
2007-04-03 14:57:27 20741 (s)2641173 ---Current stream: av_2 -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.Start -
2007-04-03 14:57:27 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:57:27 20741 (s)2641173 av_2 info.code = NetStream.Play.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.PublishNotify -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Play.PublishNotify, NaN -
2007-04-03 14:58:00 20741 (s)2641173 av_1: Publishing started. -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Data.Start -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Data.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Record.Start -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Record.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 av_1: Recording started. -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = 0 -
2007-04-03 14:58:00 20741 (s)2641173 currentTime = 0, currentUser = Michael -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG 1 The timeArray = null -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG mrd = object -
2007-04-03 14:58:00 20741 (e)2641277 Sending error message: /opt/macromedia/fms/applications/pvtVM/startup.asc: line 68: TypeError: timeArray has no properties -
2007-04-03 14:58:00 20741 (s)2641173 0: name: recordTimes, code: success -
2007-04-03 14:58:00 20741 (s)2641173 0: name: recordTimes, code: change -
2007-04-03 14:58:00 20741 (s)2641173 1: name: recordTimes, code: change -



I believe the problem has to do with the timeArray.push line. I'm not sure that timeArray is actually an Array or just a reference to an Array. I'm not a skilled flash programmer so I'm probably way off here but any help would be very much appreciated.

application.streamStatus = function(info) {^M
trace("---Current stream: " + this.ref);^M
trace("DEBUG entered streamStatus function and info.code = " + info.code);
var currentTime = application.fetchTime();^M
var currentTracker = application[this.ref + "_timeTracker_so"];^M
if (!currentTracker.getProperty("recordTimes"))^M
currentTracker.setProperty("recordTimes", new Array());^M
trace("DEBUG about to get the timearray out of the current tracker");
var timeArray = currentTracker.getProperty("recordTimes")^M
trace("DEBUG The timeArray = " typeof(timeArray));
trace(this.ref + " info.code = " + info.code + ", " + currentTime);^M
if (info.code == "NetStream.Play.PublishNotify") {^M
trace(this.ref + ": Publishing started.");^M
this.record("append");^M
} else if (info.code == "NetStream.Record.Start") {^M
trace(this.ref + ": Recording started.");^M
this.isRecording = true;^M
if (!application.startTime){^M
application.beginTimer();^M
currentTime = application.fetchTime();^M
}^M
var currentUser = application[this.ref + "_so"].getProperty("speaker");^M
trace("currentTime = " + currentTime + ", currentUser = " + currentUser);^M
trace("DEBUG 1 The timeArray = " + timeArray);
//save start time of recording in SO for stream^M
var mrd = typeof(timeArray);
trace("DEBUG mrd = " + mrd);
timeArray.push({start: currentTime, user: currentUser});^M
trace("DEBUG The timeArray = " + timeArray);
currentTracker.setProperty("recordTimes", timeArray);^M
} else if (info.code == "NetStream.Play.UnpublishNotify") {^M
trace(this.ref + ": Publishing stopped.");^M
this.record(false);^M
} else if (info.code == "NetStream.Record.Stop") {^M
trace(this.ref + ": Recording stopped.");^M
this.isRecording = false;^M
//save stop time of recording in SO for stream ^M
timeArray[timeArray.length - 1].end = currentTime;^M
currentTracker.setProperty("recordTimes", timeArray);^M
if(this.callBack)^M
application[this.callBack]();^M
}^M
};^M

TypeError?
I may have posted this in the wrong forum the first time so I'm sorry for the repost, but no one has offered any help yet.

I've been trying to figure out why I keep seeing a typeError in my logs for a stream archive system that I built using this popular online article:
http://www.informit.com/articles/article.asp?p=31667

The error I'm seeing is below:
2007-04-03 14:57:27 20741 (s)2641173 ---Current stream: av_2 -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.Reset -
2007-04-03 14:57:27 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:57:27 20741 (s)2641173 av_2 info.code = NetStream.Play.Reset, NaN -
2007-04-03 14:57:27 20741 (s)2641173 ---Current stream: av_2 -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.Start -
2007-04-03 14:57:27 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:57:27 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:57:27 20741 (s)2641173 av_2 info.code = NetStream.Play.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Play.PublishNotify -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Play.PublishNotify, NaN -
2007-04-03 14:58:00 20741 (s)2641173 av_1: Publishing started. -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Data.Start -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Data.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 ---Current stream: av_1 -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG entered streamStatus function and info.code = NetStream.Record.Start -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = NaN -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG about to get the timearray out of the current tracker -
2007-04-03 14:58:00 20741 (s)2641173 av_1 info.code = NetStream.Record.Start, NaN -
2007-04-03 14:58:00 20741 (s)2641173 av_1: Recording started. -
2007-04-03 14:58:00 20741 (s)2641173 elapsedTime = 0 -
2007-04-03 14:58:00 20741 (s)2641173 currentTime = 0, currentUser = Michael -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG 1 The timeArray = null -
2007-04-03 14:58:00 20741 (s)2641173 DEBUG mrd = object -
2007-04-03 14:58:00 20741 (e)2641277 Sending error message: /opt/macromedia/fms/applications/pvtVM/startup.asc: line 68: TypeError: timeArray has no properties -
2007-04-03 14:58:00 20741 (s)2641173 0: name: recordTimes, code: success -
2007-04-03 14:58:00 20741 (s)2641173 0: name: recordTimes, code: change -
2007-04-03 14:58:00 20741 (s)2641173 1: name: recordTimes, code: change -



I believe the problem has to do with the timeArray.push line. I'm not sure that timeArray is actually an Array or just a reference to an Array. I'm not a skilled flash programmer so I'm probably way off here but any help would be very much appreciated.

application.streamStatus = function(info) {^M
trace("---Current stream: " + this.ref);^M
trace("DEBUG entered streamStatus function and info.code = " + info.code);
var currentTime = application.fetchTime();^M
var currentTracker = application[this.ref + "_timeTracker_so"];^M
if (!currentTracker.getProperty("recordTimes"))^M
currentTracker.setProperty("recordTimes", new Array());^M
trace("DEBUG about to get the timearray out of the current tracker");
var timeArray = currentTracker.getProperty("recordTimes")^M
trace("DEBUG The timeArray = " typeof(timeArray));
trace(this.ref + " info.code = " + info.code + ", " + currentTime);^M
if (info.code == "NetStream.Play.PublishNotify") {^M
trace(this.ref + ": Publishing started.");^M
this.record("append");^M
} else if (info.code == "NetStream.Record.Start") {^M
trace(this.ref + ": Recording started.");^M
this.isRecording = true;^M
if (!application.startTime){^M
application.beginTimer();^M
currentTime = application.fetchTime();^M
}^M
var currentUser = application[this.ref + "_so"].getProperty("speaker");^M
trace("currentTime = " + currentTime + ", currentUser = " + currentUser);^M
trace("DEBUG 1 The timeArray = " + timeArray);
//save start time of recording in SO for stream^M
var mrd = typeof(timeArray);
trace("DEBUG mrd = " + mrd);
timeArray.push({start: currentTime, user: currentUser});^M
trace("DEBUG The timeArray = " + timeArray);
currentTracker.setProperty("recordTimes", timeArray);^M
} else if (info.code == "NetStream.Play.UnpublishNotify") {^M
trace(this.ref + ": Publishing stopped.");^M
this.record(false);^M
} else if (info.code == "NetStream.Record.Stop") {^M
trace(this.ref + ": Recording stopped.");^M
this.isRecording = false;^M
//save stop time of recording in SO for stream ^M
timeArray[timeArray.length - 1].end = currentTime;^M
currentTracker.setProperty("recordTimes", timeArray);^M
if(this.callBack)^M
application[this.callBack]();^M
}^M
};^M

TypeError
I am getting this error, and Im not sure what it really means:

Quote:




null
TypeError: Error #1010: A term is undefined and has no properties.
at GMScores/loadXML()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()




In my fla file I have this:

ActionScript Code:
import GMScores;
var scores:GMScores = new GMScores();
var gameStamp = '0gwl9i1hflry8anvtk7hpc4fi3ojmtj';
var gameID = '1';

trace(scores.getScores(gameStamp,gameID));

Then I have the class its self, which looks like this:

ActionScript Code:
package {   
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequest;
    import flash.xml.*;

    public class GMScores extends Sprite{
        public var scores = new Array();
        public var xmlData:URLLoader = new URLLoader();
        public var xDoc:XMLDocument = new XMLDocument();
        public function getScores(gameStamp,gameID):Array{
            xmlData.load(new URLRequest("http://gmserver.publicsize.com/xml/"+gameStamp+"/"+gameID));
            scores = xmlData.addEventListener(Event.COMPLETE, loadXML);
            return scores;
        }
        public function loadXML(e:Event):Array{
            xDoc.ignoreWhite = true;
            var mXML:XML = XML(xmlData.data);
            xDoc.parseXML(mXML.toXMLString());
            for(var i = 0;i<xDoc.firstChild.childNodes.length;i++){
                scores[i] = new Array();
                scores[i][0] = xDoc.firstChild.childNodes[i].childNodes[0].firstChild;
                scores[i][1] = xDoc.firstChild.childNodes[i].childNodes[1].firstChild;
            }
            return scores;
        }
    }
}

TypeError?
I have a movie-clip with a roll-over,roll-out and on-click function; a pretty simple button. When I test my movie the button works just fine and when it is clicked the movie continues. However, when I click the button an error messages also appears. Below is the error I receive and the code applied to my movie-clip. Any thoughts on this error message?

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at career_flash_fla::MainTimeline/rollOutFunc()

********************************************************************************************

stop();

start_btn.buttonMode = true;

start_btn.addEventListener(MouseEvent.ROLL_OVER, rollOverFunc);
start_btn.addEventListener(MouseEvent.ROLL_OUT, rollOutFunc);
start_btn.addEventListener(MouseEvent.CLICK, clickFunc);

function rollOverFunc(event:MouseEvent):void
{
start_btn.gotoAndPlay(2);
}

function rollOutFunc(event:MouseEvent):void
{
start_btn.gotoAndPlay(7);
}

function clickFunc(event:MouseEvent):void
{
play();
}

TypeError #1034 ?
Hello everybody,

I keep getting this error:

TypeError: Error #1034: Type Coercion failed: cannot convert com.mydomain.unight::unight$ to com.mydomain.unight.unight.
at com.mydomain.unight::enterSite/::mouseRl()

I got a button in my library with the class: "com.mydomain.unight.enterSite"
In the enterSite.as is some code for a mouse release:

Code:
package com.mydomain.unight
{
import flash.display.MovieClip;

import flash.events.*;

import com.mydomain.unight.*;

public class enterSite extends MovieClip
{

public function enterSite()
{
this.addEventListener(MouseEvent.MOUSE_UP, mouseRl);
}

private function mouseRl(inEvent:MouseEvent)
{
unight(unight).removeLogo();
}
}
}
As you see i'm trying to start the function 'removeLogo' in 'unight(unight)' (my document class).

In this document class unight I got this code:

Code:
package com.mydomain.unight
{
import flash.display.MovieClip;

import com.mydomain.unight.*;

public class unight extends MovieClip
{
public var enterSiteBtn:enterSite;

public function unight()
{
var enterSiteBtn:enterSite;
this.enterSiteBtn = new enterSite();
this.addChild(this.enterSiteBtn);
}

public function removeLogo():void
{
trace("removeLogo");
}
}
}
Someone knows what is wrong, or what this error is saying?
The error shows up after the mouse is released..

Thanks a lot!

TypeError 1009 - Why Though?
The following code returns a 1009 error:


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at myfile_fla::MainTimeline/colorActiveItemEvent()
But I have no idea what it is referring to exactly. The thing is, the code works, except everytime I use it inside test mode I get this annoying typeerror...

Does anyone know the reason, or fix for this?

Here's my code:


Code:
import flash.geom.ColorTransform;

function colorActiveItemEvent(eventObject:Event):void {
var newColorTransform:ColorTransform = activeItem.transform.colorTransform;
newColorTransform.color = colorChanger.cpColor.selectedColor;
activeItem.objectColor.transform.colorTransform = newColorTransform;
currentHairColor = colorChanger.cpColor.selectedColor;
}

activeItem.addEventListener(Event.ENTER_FRAME, colorActiveItemEvent);

TypeError 1009?
Hello.

Can anyone see why this code gives me an error of type 1009:TypeError?


ActionScript Code:
//ingPhotoCircle master document class  ingenieurs ltd 2008

package {

    //imports
    import caurina.transitions.*;
    //flash imports
    import flash.display.*;
    import flash.events.*;


    public class ingPhotoCircle extends MovieClip {
       
        trace("ingPhotoCircle class is running");

        //any permanent variables can go here

        //this var is how we store which select which album we choose
        public var album:uint;

        //variables for preferences if we use them later
        public var textSpeed:uint=1;
        public var textBlur:uint=2;
        public var appAngle:uint=10;
        public var coneVar:uint=100;
       
        //variables used for arrow rotate
        public var bounds:Object={left:-90,right:90};
        public var currentRot:Number=masterClip.arrowMC.rotation;
        public var lastRot:Number=masterClip.arrowMC.rotation;
        public var vRot:Number=0;
        public var isDragging:Boolean=false;
       
        trace("variables declared");

        //constructor, start of the active code
        public function ingPhotoCircle() {
            trace("ingPhotoCircle is working");
            init();
        }
       
        public function init():void {
            trace("init function is working");
            //set everything to init states
            loaderScreen.x=640;
            loaderScreen.y=400;

            //add the listeners
            loaderScreen.addEventListener(MouseEvent.MOUSE_DOWN,loaderMove);
            masterClip.coneRing.addEventListener(MouseEvent.MOUSE_DOWN,coneBounce);

            //listeners for arrow rotate
            masterClip.arrowMC.addEventListener(Event.ENTER_FRAME,loop);
            masterClip.arrowMC.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
            addEventListener(MouseEvent.MOUSE_OUT,onUp);
            addEventListener(MouseEvent.MOUSE_UP,onUp);
        }

        //this section deals with the loader mover
        public function loaderMove(E:Event):void {
            Tweener.addTween(loaderScreen,{x:-650,time:0.75,transition:"easeInQuad"});
        }

        //this bit deals with cone bounce
        public function coneBounce(e:Event):void {
            //cone parts go down...
            Tweener.addTween(masterClip.cone,{z:coneVar,time:0.1,transition:"easeOutQuad"});
            Tweener.addTween(masterClip.coneRing,{z:coneVar/4,time:0.1,transition:"easeOutQuad"});


            //cone parts come back again
            Tweener.addTween(masterClip.cone,{z:0,time:0.1,transition:"easeInQuad",delay:0.1});
            Tweener.addTween(masterClip.coneRing,{z:0,time:0.1,transition:"easeInQuad",delay:0.1});
        }

        //this bit deals with the arrow rotation
       
        function loop(e:Event):void {
            if (isDragging) {
                lastRot=currentRot;
                currentRot=mouseX;
                vRot=currentRot-lastRot;
            } else {
                masterClip.arrowMC.rotation+=vRot;
            }

            if (masterClip.arrowMC.rotation<=bounds.left) {
                masterClip.arrowMC.rotation=bounds.left;
                vRot*=-1;
            } else if (masterClip.arrowMC.rotation>=bounds.right) {
                masterClip.arrowMC.rotation=bounds.right;
                vRot*=-1;
            }

            vRot*=0.9;
        }


        function onMove(e:MouseEvent):void {
            var dx:Number=mouseX-masterClip.arrowMC.x;
            var dy:Number=mouseY-masterClip.arrowMC.y;
            var radians:Number=Math.atan2(dy,dx);
            masterClip.arrowMC.rotation=radians*180/Math.PI-270;

            if (masterClip.arrowMC.rotation<=bounds.left) {
                masterClip.arrowMC.rotation=bounds.left;
            } else if (masterClip.arrowMC.rotation>=bounds.right) {
                masterClip.arrowMC.rotation=bounds.right;

            }
            e.updateAfterEvent();
        }

        function onDown(e:MouseEvent):void {
            isDragging=true;
            addEventListener(MouseEvent.MOUSE_MOVE,onMove);
        }

        function onUp(e:MouseEvent):void {
            isDragging=false;
            removeEventListener(MouseEvent.MOUSE_MOVE,onMove);
        }

        //end of file
    }
}

TypeError: S Has No Properties
Hello Everyone

I have FlashChat with Voice running. Ever since I run the voice chat, my server just randomly freezes and stops responding. This seems to happen when the voice chat gets 3 or more users. So I checked the log and it was giving this error

Sending error message: C:Program FilesMacromediaFlash Media Server 2scriptlibcomponentsconnectionlight.asc: line 100: TypeError: s has no properties
Sending error message: Failed to execute method (ping).

What does that mean? How can I fix this problem?

Thanks

Error Message TypeError...
I am getting the following error when I run the movie at the end:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-41()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()


I checked the names are ok and I can't find anything else that could be wrong. Can somebody give me some suggestions where the error could be?



Thanks.

TypeError: Error #1009:
HI All,

I'm trying to follow a lesson in the ActionScript 3.0 Cookbook and hitting a wall. This book is written for Flex Developers so the conversion to Flash is giving me some trouble (that's my story and I'm sticking to it).

So I've created a class:


Code:
package testing{
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.MouseEvent;
public class RemoveChildExample extends Sprite{
private var _lable:TextField;
public function RemoveChildExample(){
_lable = new TextField();
_lable.text = "Some Text";
addChild(_lable);
stage.addEventListener(MouseEvent.CLICK, removeLable);
}
public function removeLable(event:MouseEvent):void{
removeChild(_lable);
}
}
}
And a FLA File


Code:
import testing.RemoveChildExample;
var myText:RemoveChildExample = new RemoveChildExample();
this.addChild(myText);
And I get this error:


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at testing::RemoveChildExample()
at CircleText_fla::MainTimeline/frame1()
Any thoughts?

Thanks.

_t

TypeError: Error #1010
I'm new to this forum so greetings all!

I got this fine looking error earlier and cant find the actual caus for it.
The error didnt show up until i added the mc's in foodStore_mc.

TypeError: Error #1010: A term is undefined and has no properties.
at Main$iinit()


Code:
package{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Main extends MovieClip{
//new timers//
var hungerTimer:Timer = new Timer(1000, 0);
var hygieneTimer:Timer = new Timer(10000, 0);
//tamagotchi values//
var tamaName:String;
var happyness:uint = 50;
var hunger:uint = 0;
var toilet:uint = 0;
var anger:uint = 0;
var hygiene:uint = 100;
var life:uint = 100;
//food//
var wantedFood:int;
var foodCookie:Boolean; //random 1
var foodChicken:Boolean; //random 2
var foodPizza:Boolean; //random 3
var foodChineese:Boolean; //random 4

public function Main(){
//Timers//
hungerTimer.addEventListener(TimerEvent.TIMER, timerHunger);
hungerTimer.start();
hygieneTimer.addEventListener(TimerEvent.TIMER, timerHygiene);
hygieneTimer.start();
//buttons//
games_btn.addEventListener(MouseEvent.CLICK, onGames);
games_mc.back_btn.addEventListener(MouseEvent.CLICK, onBack);
foodStore_btn.addEventListener(MouseEvent.CLICK, onStore);
foodStore_mc.back_btn.addEventListener(MouseEvent.CLICK, onBack);
dmg_btn.addEventListener(MouseEvent.CLICK, onDmg);
//movieclips//
games_mc.visible = false;
foodStore_mc.visible = false;
foodStore_mc.iWantCookie_mc.visible = false;
foodStore_mc.iWantChicken_mc.visible = false;
foodStore_mc.iWantPizza_mc.visible = false;
foodStore_mc.iWantChineese_mc.visible = false;
hunger_mc.width = hunger;
anger_mc.width = anger;
happyness_mc.width = happyness;
toilet_mc.width = toilet;
}
////////////////////////
// BUTTONS //
////////////////////////

public function onGames(event:MouseEvent){
games_mc.visible = true;
hungerTimer.stop();
hygieneTimer.stop();
}
public function onStore(event:MouseEvent){
wantedFood = Math.round(Math.random()* 3 +1);
if(wantedFood == 1){
foodStore_mc.iWantCoockie_mc.visible = true;
}else if(wantedFood == 2){
foodStore_mc.iWantChicken_mc.visible = true;
}else if(wantedFood == 3){
foodStore_mc.iWantPizza_mc.visible = true;
}else if(wantedFood == 4){
foodStore_mc.iWantChineese_mc.visible = true;
}
foodStore_mc.visible = true;
hungerTimer.stop();
hygieneTimer.stop();
}
public function onBack(event:MouseEvent){
games_mc.visible = false;
foodStore_mc.visible = false;
foodStore_mc.iWantCookie_mc.visible = false;
foodStore_mc.iWantChicken_mc.visible = false;
foodStore_mc.iWantPizza_mc.visible = false;
foodStore_mc.iWantChineese_mc.visible = false;
hungerTimer.start();
hygieneTimer.start();
}
public function onDmg(event:MouseEvent){
if(life <= 0){
trace("Game Over");
}else{
life -= 1
life_mc.width = life;
trace(life);
}
}
////////////////////////
// TIMERS //
////////////////////////

public function timerHunger(event:TimerEvent):void {
if(hunger == 100){
hungerTimer.stop();
trace();
}else{
hunger += 1;
hunger_mc.width = hunger;
}
}
public function timerHygiene(event:TimerEvent):void {
hygiene -= 2;
hygiene_mc.width = hygiene;
}
}
}




Dont be afraid to post. Thanks

Edit: I noticed that the code is a little bit out of place. But its still readable.

//ref

TypeError: Error #1010
hello,

i keep getting this error:

TypeError: Error #1010: A term is undefined and has no properties.
at jxcs_index_fla::mov_galleryMenSs0708_5/loadMainImage()

and it appears to be happening in this function:

function loadMainImage(event:MouseEvent):void {
deActivateRollOver();
var imageRequest:URLRequest = new URLRequest(imageArray[0]);
event.target.imageHolder.load(imageRequest);
}

this is the line of code i use to set the listener:

galleryImage00_mc.addEventListener(MouseEvent.CLIC K, loadMainImage);

the strange thing is that if i change "event.target" in the function to "galleryImage00_mc" it works perfectly. But i need to use event.target so i can use the function for others.

Any help would be appreciated.

Thanks
Ben

TypeError: Error #1009
I'm new to Flash, and ActionScript3.

I'm trying to create a very basic "slideshow", when I compile, it runs, but I get the following error.


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at lab7_fla::MainTimeline/lab7_fla::frame1451()
On that frame is the following ActionScript.


Code:
menu2.addEventListener(MouseEvent.CLICK,menu2Listener);
next2.addEventListener(MouseEvent.CLICK,next2Listener);
prev2.addEventListener(MouseEvent.CLICK,prev2Listener);

function menu2Listener(event:MouseEvent):void {
gotoAndPlay(2,"Menu");
}

function next2Listener(event:MouseEvent):void {
nextFrame();
}

function prev2Listener(event:MouseEvent):void {
prevFrame();
}
What's weird is, the nextFrame is working, but not the prevFrame button.
I am using scenes, and the scenes are being displayed properly.

My only problem is the error, and the prevFrame not working.

Please help out this AS3 n00b.

TypeError: Error #1009
Good day everybody.. so yes im a complete noob at this.. i can handle most coding languages.. but this i just cant

so this is the AS 3.0 i have for a preloader .. that i used from a tut, is a simple fill up pre-loader. so the tut was made for AS 2.0 and i tried to migrate some parts like the on enterframe thing.. and the getbytesloaded.. so yah but when i try it i all ways get an error..

TypeError: Error #1009

and heres is the code..


Code:
stop();
mask_mc.height = 1;
addEventListener(Event.ENTER_FRAME,shizzy);
function shizzy(event:Event) {
var bytesLoaded:uint = 0
var bytesTotal:uint = 0
var loadedData:Number = bytesLoaded
var allData:Number = bytesTotal
var percent:Number = Math.round(loadedData/allData*100);
mask_mc.scaleY = percent;
if (loadedData>=allData) {
gotoAndStop(10);
delete this.onEnterFrame;
}
}

Most Annoying Error: TypeError
Hi all,

I'm working on a quiz, I have an xml file with all the questions and answers in, which can be found here, including the fla and the as3 file: http://users.pandora.be/Jinx-/xml/
The content doesn't really matter, but it's quite obvious anyway.
As you can see, the xml contains 17 questions, and I need to extract 10 random questions from the file

These are the steps I'm taking to get 10 random questions (The error will be at the end of this post)

Step 1: Declare variables

Code:
private var fullXML:XML;
private var xmlLoader:URLLoader;
private var vrg1XML:XML;
private var vrg2XML:XML;
private var vrg3XML:XML;
private var vrg4XML:XML;
private var vrg5XML:XML;
private var vrg6XML:XML;
private var vrg7XML:XML;
private var vrg8XML:XML;
private var vrg9XML:XML;
private var vrg10XML:XML;
private var xmlArray:Array;
Step 2: fill the vrgxXML with dummy xml

Code:
vrg1XML =
<vraag vrg="EMPTY">
<antwoord opl="EMPTY">EMPTY</antwoord>
<antwoord opl="EMPTY">EMPTY</antwoord>
<antwoord opl="EMPTY">EMPTY</antwoord>
</vraag>

This for all 10
Step 3: Load the quiz.xml file

Code:
private function loadXML():void{
var xmlRequest:URLRequest = new URLRequest("../xml/quiz.xml");
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, completeListener);
xmlLoader.load(xmlRequest);
}

private function completeListener(e:Event):void {
fullXML = new XML(xmlLoader.data);
fillXmlArray();
generateQuestions();
}
Step 4: Fill the array with the xml dummies

Code:
private function fillXmlArray():void{
xmlArray = new Array();
xmlArray.push(vrg1XML);
xmlArray.push(vrg2XML);
xmlArray.push(vrg3XML);
xmlArray.push(vrg4XML);
xmlArray.push(vrg5XML);
xmlArray.push(vrg6XML);
xmlArray.push(vrg7XML);
xmlArray.push(vrg8XML);
xmlArray.push(vrg9XML);
xmlArray.push(vrg10XML);
}
Step 5: Generate the 10 random questions, this is where it goes wrong

Code:
private function generateQuestions():void{
//Loop 10 times for 10 questions
for(var i=0; i<10; i++){
//Generate a random number
var rndNumber:Number = Math.random();
//Get the corresponding xml out of the array
var xml:XML = xmlArray[i];
//Devide 100 by the amount of questions from the XML
var partitions:Number = 100 / fullXML.children().length();
//Go through all the questions from the XML
for (var j=1; j<fullXML.children().length()+1; j++){
var compare:Number = (j * partitions)/100;
if(rndNumber < compare){
var bool:Boolean = false;
for(var k=0; k < xmlArray.length; k++){
//Check if the question isn't already picked
if(fullXML.vraag[j].@vrg == XML(xmlArray[k]).@vrg){
//If it is already been picked
bool = true;
}
}
if(bool == true){
//restart this loop
i--;
}
else{
//set the xml
xml = fullXML.vraag[j];
xmlArray[i] = xml;
j = fullXML.children().length()+ 10;
}
}
}
}
for(var l=0; l < xmlArray.length; l++){
//Check the questions
trace(XML(xmlArray[l]).toXMLString());
}
}
So here's the problem:
If I execute the following code, it might happen that it actually returns 10 random questions, however this almost never happens, most of the time I get this error:

Code:
TypeError: Error #1010: A term is undefined and has no properties.
at Quiz/::generateQuestions()
at Quiz/::completeListener()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
Now when I disable the text in red, I don't get the error anymore but for some reason it doesn't always return 10 questions but sometimes 9.

I really have no clue what's so wrong abut my code, if anyone has an idea then please tell me.

Wouter

TypeError: Error #1009: Help
Hey, i am relatively new to actionscript and xml and i just cant wrap my head around this problem!

This is the Error i am getting:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at dandeFly::Dandelion/doAddedToStage()
at flash.display::DisplayObjectContainer/addChildAt()
at dandeFly::DandelionManager/initLevel()
at dandeFly::Document/initLevel()
at dandeFly::Document/dandeFly::frame29()
Here is my xml code:

Code:
<?xml version="1.0"?>
<game freelifeat="5000" maxlives="3">
<butterfly initshieldcnt="90" levelshieldcnt="15" maxspeed="10"></butterfly>
<dandelion initastcount="4" levelastcount="2">
<large proto="2" scale="1.00" points="10" maxspeed=".5" maxspeedvar=".5" maxrot=".25" maxrotvar="1" />
<med proto="1" scale="0.75" points="20" maxspeed="1" maxspeedvar=".5" maxrot="1" maxrotvar="2" />
<small proto="0" scale="0.50" points="30" maxspeed="3" maxspeedvar="1" maxrot="3" maxrotvar="3" />
</dandelion>
<bullets gbulletspeed="12" gbullets="4" bbulletspeed="5" bbullets="1" />
</game>

Here is my XML actionscript loader file:

Code:
package dandeFly
{
import flash.display.*;
import flash.events.*;
import flash.net.*;

public class XMLLoader
{
private var pRequest:URLRequest;// Request from file or Internet
private var pLoader:URLLoader;// Content Loader
private var pFile:String;// Retains the file path
private var pDocClass:Document; // Reference back to the document class
private var pAM:DandelionManager;// Manager References
private var pGM:ButterflyManager;
private var pBM:BulletManager;

// Constructor - Executes content loading and retains information regarding
// all of the content managers passed in (as well as the document class)
public function XMLLoader(aFile:String, aDocClass:Document, aAM:DandelionManager, aGM:ButterflyManager, aBM:BulletManager)
{
// Keep around parameters
pFile = aFile;
pDocClass = aDocClass;
pAM = aAM;
pGM = aGM;
pBM = aBM;

// Set up the loader
pRequest = new URLRequest(pFile);
pLoader = new URLLoader();

// Set up the event listeners
pLoader.addEventListener(Event.COMPLETE, doComplete);
pLoader.addEventListener(IOErrorEvent.IO_ERROR, doError);
pLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doError);

// Load the content
// Requires an event to continue
pLoader.load(pRequest);
}

// doComplete - Event handler that reads in the loader content and
// parses it as XML

public function doComplete(anEvent:Event):void
{
// Convert loader content to an XML Object
var xmlData:XML = new XML(pLoader.data);

// Read information pertaining to the document class
pDocClass.freelifeat = xmlData.@freelifeat;
pDocClass.maxlives = xmlData.@maxlives;

// Read information pertaining to the ButterflyManager
pGM.initShieldCount = xmlData.butterfly.@initshieldcnt;
pGM.levelShieldCount = xmlData.butterfly.@levelshieldcnt;
pGM.maxspeed = xmlData.butterfly.@maxspeed;

// Read information pertaining to the DandelionManager
pAM.initCount = xmlData.dandelion.@initastcount;
pAM.levelCount =xmlData.dandelion.@levelastcount;

// Read information pertaining to the BulletManager
pBM.gBullets = xmlData.bullets.@gbullets;
pBM.gBulletSpeed =xmlData.bullets.@gbulletspeed;
pBM.bBullets = xmlData.bullets.@bbullets;
pBM.bBulletSpeed = xmlData.bullets.@bbulletspeed;

// Now, for each Dandelion Prototype, read all pertenent information
for each (var element:XML in xmlData.Dandelions.*)
{
var tempProto:DandelionPrototype = new DandelionPrototype();
tempProto.pProto = element.@proto;
tempProto.pScale = element.@scale;
tempProto.pPoints = element.@points;
tempProto.pMaxSpeed = element.@maxspeed;
tempProto.pMaxSpeedVar = element.@maxspeedvar;
tempProto.pMaxRot = element.@maxrot;
tempProto.pMaxRotVar = element.@maxrotvar;
pAM.addProto(tempProto);
}

// When all is OK, tell the document class to change to the
// instructions state
pDocClass.doInstructions();
}

// doError - This event handler tells the document class to change
// to the error state

public function doError(anEvent:Event):void
{
pDocClass.doError();
}
}
}
Here is the part of code from the dandelion AS file:

Code:
public function doAddedToStage(anEvent:Event):void
{
stop();
rotation = GameMath.randRange(0,360);
distance = GameMath.randRange(pProto.pMaxSpeed+pProto.pMaxSpeedVar,pProto.pMaxSpeed+pProto.pMaxSpeedVar);
angvel = GameMath.randMotion(pProto.pMaxRot-pProto.pMaxRotVar, pProto.pMaxRot+pProto.pMaxRotVar);
scale = pProto.pScale;
isActive = true;
gotoAndStop("dandelion"+pType+"active");
update();
}
And here is the code from the Document constructor as file:

Code:
public function initLevel():void
{
// Tell all the managers to init level data
pDandelionManager.initLevel();
pButterflyManager.initLevel();
pBulletManager.initLevel();


// Start the timer to do game updates
pUpdateTimer.start();
}
and lastly the code from the dandelion manager AS file:

Code:
public function initLevel():void
{
for (var x:int = 0; x < pCount; x++)
{
var tempPoint:Point = new Point(GameMath.randRange(0, pDocClass.stage.stageWidth), GameMath.randRange(0,pDocClass.stage.stageHeight));
var tempDandelion:Dandelion = new Dandelion(getProto(pDandelionProto.length - 1),this, tempPoint);
pDandelions.push(tempDandelion);
pDocClass.addChildAt(tempDandelion, 1);
}
}

Could anyone give me an idea as to why these errors are appearing?

TypeError: Error #2007
I was about to post a problem I was having with my gallery script, that was working in firefox but not in IE.
i've tracked the error down to an error in my XML parsing script, which is throwing the error TypeError: Error #2007 - in IE only...


ActionScript Code:
XMLloader.addEventListener(Event.COMPLETE, ParseGallery);

function ParseGallery(E:Event) {
    try {
      var XMLGallery:XML = new XML(XMLloader.data)
      var PictureNodes:XMLList = XMLGallery.children();
      var item:XML = new XML()
      for each(item in PictureNodes) {
        URLS.push(item.@url);
      }
      NextGalleryItem()
    } catch(e_) { error(new Event("An Error Occured within ParseGallery:" + e_) )};
}

XMLloader.load(new URLRequest("top_gallery.xml"));


I was about to ask for help, while, in the process of checking EVERYTHING thoroughly, i found that my XML file was to blame, the very first line was

Code:
<?xml version="1.0" encoding="utf-8"?>
but adding a space before the final ? making it

Code:
<?xml version="1.0" encoding="utf-8" ?>
sorted it out, just incase anyone else seems to be having some strange problems like that.

Edit: I've just removed the space to try and break it again... and it works in IE again... i am very confused

TypeError: Error #1009
Hello. I am getting a null object reference error on a button in Adobe Flash CS3 (ActionScript 3.0). The button is placed in frame 1 and has small roll over and roll out animations. When the button is clicked, flash resumes play at a point further down the timeline. I can avoid the error by removing the roll out animation or by having the gotoAndPlay command point to a frame earlier than the frame when the button was clicked. How can I change the command to keep the roll out animation and still have the button function as a skip button? Thank you.

AS 3.0 Command:
myBtn.buttonMode = true;
myBtn.addEventListener(MouseEvent.ROLL_OVER,animIn );
myBtn.addEventListener(MouseEvent.ROLL_OUT,animOut );
function animIn(event:MouseEvent):void {
myBtn.gotoAndPlay(5);
}
function animOut(event:MouseEvent):void{
myBtn.gotoAndPlay(11);
}
myBtn.addEventListener(MouseEvent.MOUSE_DOWN,skipi ntro);
function skipintro(event:MouseEvent):void{
gotoAndPlay(285);
}

Error Displayed:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/animOut()

TypeError: Error #1009
Hi. I need help im trying to do and asteroid game but for some reason since i put that an asteroid hit the ship Im getting this error did someone know how to fix it or at least what it means:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Reyes_Mora_10079475_ass3borrador_fla::MainTimeline/timedFunction()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()

Also, did someone have the code to make that the ship go in the direction where is pointing when i press the up key

thanks i hope someone can help me really quick

TypeError: Error #1009:
So, I am trying to write a pretty basic XML importer for a flash site i'm working on, and I have gotten it to work in a closed environment. I'm currently working on a class though, and whenever I try to make the proper class calls to use it from the main class, I get the TypeError: Error #1009: thrown.

Here is the code, if anyone could take a look it it would rock my face off, I've tried everything I can think of, and as I am just learning AS3 in Flex, I am not sure what the error even means. As far as I can tell it should work -shrugs-

This is the temporary AS3 class I am using to see if this thing works, all the output is via trace.


ActionScript Code:
package {
    import flash.display.Sprite;

    public class XMLLoaderTest extends Sprite
    {
        public function XMLLoaderTest()
        {
            var testvar:XML_Loader = new XML_Loader();
            testvar.loadXMLdata( "Sanctuary_units.xml" );
            var testArray:Array = testvar.getChildrenByAttribute( "one" );
            trace(testArray);
        }
    }


and here is the relevant part of the XML import class, this is not the final version but I need to get this working before I can start adding features and polishing it.

ActionScript Code:
package {
   
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.utils.*;

    public class XML_Loader {
       
        private var XMLData:XML;
       
        public function XML_Loader() {
        }
        private function handleComplete( event:Event ):void {
            try {
                XMLData = new XML( event.target.data );
            } catch ( e:TypeError ) {
                trace( "Could not parse XML file" );
                trace( e.message );
            }
        }
        public function getChildrenByAttribute( attribute:String ):Array {
       
        var childArray:Array;
       
            for each( var element:XML in XMLData.elements() ){
                if(element.@number == attribute){
                    for each(var children:XML in element.elements() ) {
                        childArray.push( children );
                    }
                }
            }
        return childArray; 
        }
        public function loadXMLdata( filename:String ):void {
            var XMLLoader:URLLoader = new URLLoader();
            XMLLoader.dataFormat = URLLoaderDataFormat.TEXT;
            XMLLoader.addEventListener( Event.COMPLETE, handleComplete );
            XMLLoader.load( new URLRequest(filename) );
        }
    }
}

Both AS files are in the same directory, so i'm not using any package declarations atm, that will all change later.

Thanks for any help, put almost 6 hours into trying to fix this, nothing yet.

TypeError: Error #1009
Hi,

I am calling a stored procedure that executes my passed query and returns the result back to me as follows:


Code:
<mx:HTTPService id="http2" url="http://192.168.0.3:7777/ns/SQL2XML" method="POST" resultFormat="e4x" />

<mx:Script>
<![CDATA[
private var params:Object = new Object;
private var attach_id:Object = new Object;
private var att_id:Object = new Object;

// Called on upload complete
private function onUploadComplete(event:Event):void {
numCurrentUpload++;

if (numCurrentUpload == arrUploadFiles.length && numCurrentUpload == 1) {

// To call the stored procedure which will get the uploaded attachment from the directory in
// which it is tored by the php script and store that file as blob in the wwdoc_document table
http2.send({s:"SELECT SEQ_ATTACHMENT_ID.NEXTVAL attach_id FROM DUAL;"});
att_id = http2.lastResult.row.attach_id; // This is where I am getting an error.

params.pfileid = att_id;
params.pfilename = refUploadFile.name;
params.pflag = 0;

Alert.show('1:'+refUploadFile.name);
http.url = main.URLprefix + "ns/email_p.store_attachment";
http.method = "POST";
http.resultFormat = "e4x";
http.send(params);

enableUI();
dispatchEvent(new Event("uploadComplete"));
}
}
]]>
</mx:Script>
Error : TypeError: Error #1009: Cannot access a property or method of a null object reference.
at comp.service::issueNoteDetail/onUploadComplete()[C:Documents and SettingsMayankMy DocumentsFlex Builder 3
s5srccompserviceissueNoteDetail.mxml:274]

TypeError: Error #1010, Why?
What am i doing wrong in this piece of code:


ActionScript Code:
private function ladenVanThumbnails() {
    for (var i:int = 0; i<thumbSpreadArray.length; i++) {
        selectBox = new Shape();
        selectBox.graphics.clear();
        selectBox.graphics.lineStyle(2, 0x000000, 1, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 10);
        selectBox.graphics.drawRect(thumbBreedte, 0, thumbBreedte, thumbHoogte);
        selectBox.graphics.endFill();
        selectBoxMC = new MovieClip();
        selectBoxMC.addChild(selectBox);
        thumbSpreadArray[i].addChild(selectBoxMC);
        //
        var thumbLoadL:Loader = new Loader();
        thumbLoadL.load(new URLRequest(thumbURL+thumbSpreadArray[i].links+".jpg"));
        thumbLoadL.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, thumbnailLaden);
        thumbSpreadArray[i].addChild(thumbLoadL);
    }
}
private function thumbnailGeladen(evt:Event):void {
    var thisLdr:Loader = LoaderInfo(evt.currentTarget).loader as Loader;
    var thisMC:MovieClip = thisLdr.parent;
    thisMC.addEventListener(MouseEvent.CLICK,clickthumb);
    thisMC.addEventListener(MouseEvent.ROLL_OVER,rollOverthumb);
    thisMC.addEventListener(MouseEvent.ROLL_OUT,rollOutthumb);
}
private function rollOverthumb(evt:MouseEvent) {//rollover
    trace("rollover "+evt.currentTarget.id);
    DisplayObject(evt.target).selectBoxMC.alpha = .5;
}

I'm trying to make the border around the thumbnails change when i rollover the thumbnail with the mouse. But whatever i try, i get the following error message:

ActionScript Code:
TypeError: Error #1010: A term is undefined and has no properties.
at com.iternity.pflp.pages::PageflipPage/rollOverthumb()

What am i doing wrong?

TypeError: Error #1009
I have a problem. I have created a loop which workes fine. But in that loop I would like to be able to click on my spaceship to then go to a specified frame. I get the error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at solarsystem_fla::spaceship_20/solarsystem_fla::frame20()

I'm sure this is a simple mistake, but I've tared my head apart and cannot find a solution! Please help me quickly!

This is my code:



ActionScript Code:
//in frame 10:

var loop:Number=0;





ActionScript Code:
//in frame 20:

loop = loop + 1;
if(loop < 3) {
    this.gotoAndPlay(10);
} else {
    this.stop();
}

 var shipArray:Array = [spaceship2, spaceship3, spaceship4, spaceship5 ];
 var i:Number;
 for(i = 0; i< shipArray.length; i++){
     var movieClipNames = shipArray[i];
     movieClipNames.buttonMode = true;
     movieClipNames.addEventListener(MouseEvent.CLICK, space);
 }


function space(event:MouseEvent):void {
    event.target.gotoAndPlay(21);
   
   }

TypeError: Error #1009
Hello,

I'm trying to modify the text in a dynamic text field. The particular value doesn't matter, I'm just trying to get any value in there.

I have the text box in my flash worksheet (named LivesText), and when I try to access it in my .as file using this code:
LivesText.text = new String("hello");
I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

Does anyone know why this is occuring? Thanks for any help!

TypeError: Error #1009
Essentially, I'm trying to recreate something I've seen on the MediaStorm website http://mediastorm.org/0024.htm a scrolling banner of images, each of which acts like a button to click through to a video player that I've managed to find.

But I've hit a problem with the above error which is driving me mad.

Can anyone help?

This is the code - which is far simpler than its length suggests:


PHP Code:



stop();

//set up event handler for the mousescroller
profilesMC.addEventListener(Event.ENTER_FRAME, profilesEnterFrame);

//enable the nested buttons layer to be contacted by the main timeline
profilesMC.mouseEnabled = true;
profilesMC.mouseChildren = true;
profilesMC.fence.mouseEnabled = true;
profilesMC.fence.mouseChildren = true;
profilesMC.fence2.mouseEnabled = true;
profilesMC.fence2.mouseChildren = true;

//enable the buttons so they are contactable by the main timeline
profilesMC.fence.arthurMitchell.mouseEnabled = true;
profilesMC.fence.arthurSimmons.mouseEnabled = true;
profilesMC.fence.basilAtkins.mouseEnabled = true;
profilesMC.fence.burtMitchell.mouseEnabled = true;
profilesMC.fence.ernieMorris.mouseEnabled = true;
profilesMC.fence.jimMurphy.mouseEnabled = true;
profilesMC.fence.johnWilde.mouseEnabled = true;
profilesMC.fence.kenBettany.mouseEnabled = true;
profilesMC.fence.lesHarrison.mouseEnabled = true;
profilesMC.fence.mauriceMurray.mouseEnabled = true;
profilesMC.fence.tomBerrisford.mouseEnabled = true;

//event handlers for ASimmons
profilesMC.fence.arthurSimmons.addEventListener(MouseEvent.MOUSE_OVER, mouseOverASimmons);
profilesMC.fence.arthurSimmons.addEventListener(MouseEvent.MOUSE_OUT, mouseOutASimmons);
profilesMC.fence.arthurSimmons.addEventListener(MouseEvent.MOUSE_DOWN, videoASimmons);

function mouseOverASimmons(e:MouseEvent):void
{
    profilesMC.fence.arthurSimmons.alpha = 0;
}
function mouseOutASimmons(e:MouseEvent):void
{
    profilesMC.fence.arthurSimmons.alpha =.4;
}
function videoASimmons(e:MouseEvent):void
{
    gotoAndStop("aSimmons");
    
}


//event handlers for basilAtkins
profilesMC.fence.basilAtkins.addEventListener(MouseEvent.MOUSE_OVER, mouseOverbasilAtkins);
profilesMC.fence.basilAtkins.addEventListener(MouseEvent.MOUSE_OUT, mouseOutbasilAtkins);
profilesMC.fence.basilAtkins.addEventListener(MouseEvent.MOUSE_DOWN, videobasilAtkins);

function mouseOverbasilAtkins(e:MouseEvent):void
{
    profilesMC.fence.basilAtkins.alpha = 0;
}
function mouseOutbasilAtkins(e:MouseEvent):void
{
    profilesMC.fence.basilAtkins.alpha =.4;
}
function videobasilAtkins(e:MouseEvent):void
{
    gotoAndStop("bAtkins");
}


function mouseOvertomBerrisford(e:MouseEvent):void
{
    profilesMC.fence.tomBerrisford.alpha = 0;
}
function mouseOuttomBerrisford(e:MouseEvent):void
{
    profilesMC.fence.tomBerrisford.alpha =.4;
}
function videotomBerrisford(e:MouseEvent):void
{
 gotoAndStop("tBerrisford");
}



function parallax(layer:MovieClip, speed:Number):void
{
    var distance:Number = (mouseX - (stage.stageWidth / 2));
    
    if (mouseX > (stage.stageWidth / 2))
    {
        layer.x -= (distance * speed);
    }else{
        layer.x += distance * -speed;
    }
    
    if (layer.x <= 0)
    {
        layer.x = layer.x + layer.width / 2;
    }else if(layer.x >= layer.width / 2){
        layer.x = layer.x - layer.width / 2;
    }
}

function profilesEnterFrame(e:Event):void
{
    parallax(e.target, 0.025);


var ourBoys:URLRequest = new URLRequest ("http://www.thisisstaffordshire.co.uk/ourboys");
var fallenHeroes:URLRequest = new URLRequest ("http://www.thisisstaffordshire.co.uk/fallenheroes.html");
var nostAlgia:URLRequest = new URLRequest ("http://www.thisisstaffordshire.co.uk/nostalgia");
var uploadPics:URLRequest = new URLRequest ("http://www.thisisstaffordshire.co.uk/poppies");
var triBute:URLRequest = new URLRequest ("http://lastingtribute.thisisstaffordshire.co.uk/poppyfield?content=homepage");



ourBoysBtn.addEventListener (MouseEvent.CLICK, ourBoysMouseClick);

function ourBoysMouseClick (e:MouseEvent)
{
    
    navigateToURL(ourBoys, "_blank");
}

fallenBtn.addEventListener (MouseEvent.CLICK, fallenMouseClick);

function fallenMouseClick (e:MouseEvent)
{
    
    navigateToURL(fallenHeroes, "_blank");
}

nostalgiaBtn.addEventListener (MouseEvent.CLICK, nostalgiaMouseClick);

function nostalgiaMouseClick (e:MouseEvent)
{
    
    navigateToURL(nostAlgia, "_blank");
}

uploadPicsBtn.addEventListener (MouseEvent.CLICK, uploadPicsMouseClick);

function uploadPicsMouseClick (e:MouseEvent)
{
    
    navigateToURL(uploadPics, "_blank");
}

tributeBtn.addEventListener (MouseEvent.CLICK, tributeMouseClick);

function tributeMouseClick (e:MouseEvent)
{
    
    navigateToURL(triBute, "_blank");





If I click the tomBerrisford button it generates this error, and I just can't work out how to fix it...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Remembrance10_fla::MainTimeline/mouseOuttomBerrisford()



The full package is here:

Can anyone help?

TypeError: Error #1009:
Hello

I have made a movie clip where I have used 3 buttons. This is for a drop down menu where top1_btn is the main button

My action script in the movie clip says the following

stop();
this.top1_btn.addEventListener(MouseEvent.MOUSE_OV ER , open);
function open (e) {
gotoAndStop(10);
}

This works and I can see the to remaining buttons

When I drag my movie clip to the stage I want to click on the buttons from the movie clip and go to a specific frame. I have made the following AS

this.Service.roller_btn.addEventListener(MouseEven t.CLICK, run);

function run(e) {
gotoAndStop("20");
}

This should make the it go to frame 20, but I get the error

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Menu_fla::MainTimeline/frame1()

Should I use another to call my button from the movie clip?

Thanks
Tanja

TypeError: Error #1009
I keep getting this error.


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpaceShooter/::addEnemy()
at SpaceShooter$iinit()
It is caused by this function:


ActionScript Code:
private function addEnemy(x:int, y:int):void{
    var newEnemy = new Enemy();
           
    // x & y position
    newEnemy.x = x;
    newEnemy.y = y;
           
    // random movement
    var dx:Number = (Math.random() * 2) - 1;
    var dy:Number = (Math.random() * 2) - 1;
           
        // add to stage and array
    addChild(newEnemy);
    enemysArray.push({enemy:newEnemy, dx:dx, dy:dy});
}

When i remove this code:

ActionScript Code:
enemysArray.push({enemy:newEnemy, dx:dx, dy:dy});
The error is gone.

How can I fix this?
The error means that i'm referencing to something that isn't there but how can that be? I created it at the top

TypeError: Error #1009:
This is a repost of some code I had recently asked help for but now it's a bit different as my brother, who programs C#, has helped me get a better grasp on what I need to do. I am providing both the class in question and the function that calls it from another class. When publishing, I'm getting the error in the subject line of this post.









Attach Code

package classes.tagwidget{

import flash.display.*;
import flash.events.*;
import flash.net.*;

class ListLoader extends EventDispatcher
{
public var record:String;
public var fulllist:String;
private var requestURL:String;
private var loader:URLLoader;
private var base:EventDispatcher;
private static var clientURL:String = "http://tagonline.tagworldwide.com/tagOnline/php/qry_clients_subclients_CB.php";
private static var ftpURL:String = "http://tagonline.tagworldwide.com/tagOnline/php/qry_ftp_logins_CB.php";
private static var phoneURL:String = "http://tagonline.tagworldwide.com/tagOnline/php/qry_tag_employees_CB.php";

public function ListLoader()
{
var base = this;
}


public function load(request:String):void
{
requestURL = request; // stored requested url inside of class to reference later

var urlVars:URLVariables=new URLVariables;
urlVars.action="listAll";

var urlReq:URLRequest=new URLRequest(request);
urlReq.method=URLRequestMethod.POST;
urlReq.data=urlVars;

loader = new URLLoader(); // added this
loader.addEventListener(Event.COMPLETE,completeHandler);

loader.load(urlReq);
}


public function completeHandler(event:Event):void
{
//trace("XML loaded");
XML.ignoreWhitespace=true;
var loadedXML:XML = new XML(loader.data);

if (requestURL == ftpURL) {
//trace("is ftp");
processFtpXML(loadedXML);
} else if (requestURL == phoneURL) {
//trace("is phones");
processPhoneXML(loadedXML);
} else if (requestURL == clientURL) {
//trace("is clients");
processClientXML(loadedXML);
}else {
//display error
trace("XML has not loaded");
}

var completeEvent:Event = new Event(Event.COMPLETE); // creates a new COMPLETE event to be dispatched
base.dispatchEvent(completeEvent);
}

function processFtpXML(loadedXML:XML):void
{
for each (var item in loadedXML.record) {
record+= item.company + " ";
record+= item.un + " ";
record+= item.pw + "
";
}
fulllist = record;
}

function processPhoneXML(loadedXML:XML):void
{
for each (var item in loadedXML.record)
{
record+= item.fname + " ";
record+= item.lname + " ";
//record+= item.title + " ";
record+= item.cell + " ";
record+= item.ext + " ";
record+= "<a href='mailto:" + item.email + "@tagworldwide.com'>" + item.email + "@tagworldwide.com </a>
";
}
fulllist = record;
}

function processClientXML(loadedXML:XML):void
{
for each (var item in loadedXML.record)
{
record+= "Client: " + item.client + "
";
record+= "Subclient: " + item.subclient;
}
fulllist = record;
}
}
}

//////
/////
/////from calling class////////////////
function addFTP():void {
var loadFTPList:ListLoader = new ListLoader();
loadFTPList.addEventListener(Event.COMPLETE, showList);
loadFTPList.load(ftpURL);
function showList() {
var ftp_panel = new SectionPanel();
ftp_panel.y = ftp_panel.yPos;
ftp_panel.x = ftp_panel.xPos;
ftp_panel._tabX=-150;
ftp_panel.addSubmit();
ftp_panel.addText();
ftp_panel.addTab("FTP LOGINS");
addChild(ftp_panel);
ftp_panel.addEventListener(Event.COMPLETE, myListHandler);
ftp_panel.addEventListener(MouseEvent.CLICK,tabClickHandler);
function tabClickHandler(event:MouseEvent):void {

MakeCurrent(ftp_panel);
}
}
}

TypeError: Error #2007
Aloha all.

When dumping to swf or Adobe Air, I get the following error:

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()
at fl.controls::BaseButton/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::ScrollBar/draw()
at fl.controls::UIScrollBar/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::TextArea/updateScrollBars()
at fl.controls::TextArea/drawLayout()
at fl.controls::TextArea/draw()
at fl.core::UIComponent/callLaterDispatcher()

I looks like everything is named correctly, with corresponding instance names and whatnot on the component. Is there something special you have to do to the component before its usable?

Thanks,
Chad

TypeError: Error #1009: ?
this.our_story.addEventListener(MouseEvent.CLICK,clickListener1);
function clickListener1(event:MouseEvent):void {
gotoAndPlay("storypage");
}

this.menus.addEventListener(MouseEvent.CLICK,clickListener2);
function clickListener2(event:MouseEvent):void {
gotoAndPlay("menuspage");
}

this.location.addEventListener(MouseEvent.CLICK,clickListener3);
function clickListener3(event:MouseEvent):void {
gotoAndPlay("locationpage");
}

TypeError: Error #1009 :(
I don't understand why I am getting this error....


package Classes {
public class HomePage extends Sprite {
public function HomePage():void
{
buildLogo();
}

public function buildXML():void
{
var xml:XML =
<navHolder>
<nav id="Blog"/>
<nav id="Store"/>
<nav id="Projects"/>
<nav id="Information"/>
</navHolder>;
}
public function buildLogo():void{
color.color = 0x000000;
LogoBg = drawSquare(200,150,0,0,color);
LogoBg.x = 200;
LogoBg.y = 200;
addChild(LogoBg);
}
}}

I have more functions but I am having trouble with nested classes.
Here is the code in the document class.

package Classes {
import Classes.HomePage;
private var c:Object = new HomePage();

public class BuildHome extends Sprite {

public function BuildHome():void
{
addChild(display);
fillTheBoard();

}
}
}

When I use the buildXML function in my constructor, everything works fine. but when I try to use buildLogo it gives me this error..

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Classes::HomePage/buildLogo()
at Classes::HomePage$iinit()
at Classes::BuildHome$iinit()

could it be addChild without a reference since I assume that this nested class couldn't access the stage? Or something like that.. gurus help please

and thanks in advance.

this is a great forum!

TypeError: Error #1009
All I have on my stage is one MovieClip, instance-named "box_mc".

On Frame 1 (which is the only frame out there), I have this code:


ActionScript Code:
import com.placement.LiquidLayout;var newAligner:LiquidLayout = new LiquidLayout(box_mc, 300, 300);addChild(newAligner);


And in my class file (which is based on the StageManager class by noponies.com) I have this code:


ActionScript Code:
package com.placement {    import flash.display.*;    import flash.display.StageAlign;    import flash.display.StageScaleMode;    import flash.events.Event;        public class LiquidLayout extends Sprite {                //declaring the variables        private var managedObject:InteractiveObject;        private var xAxis:Number;        private var yAxis:Number;                //building the constructor        public function LiquidLayout(target:InteractiveObject, xpos:Number, ypos:Number) {                        //getting local variables            managedObject = target;            xAxis = xpos;            yAxis = ypos;                        //executing the actions            setLayout();            stage.addEventListener(Event.RESIZE, resizeListener);                    }                private function resizeListener() {            setLayout();                    }                private function setLayout() {            managedObject.x = xAxis;            managedObject.y = yAxis;        }            }    }


And when I test my movie, everything works correctly, though I get this in the Output window:


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.placement::LiquidLayout$iinit()
at test_fla::MainTimeline/test_fla::frame1()
Can anyone explain, why this happens, and how I should fix the class file to have no such warnings in the future.

Thanks in advance, Here are the source files:

TypeError: Error #1009
Code:
postback
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at folio_fla::MainTimeline/folio_fla::frame1()
I'm getting the above error and I have no idea why. I don't know what it means because this is my first stab at AS3.

I've got a main fla that has a menu in it that is grabbing ext swf's and loading them onto the stage when a menu item is selected. It loads the first item in the menu automatically.

One of the ext. swf's is a gallery. When i set it to be the first item in the menu it loads automatically and perfectly. but when i select it again or set it to any other menu item i get the above error when a menu button is selected in an attempt to load it.

Your thoughts? Is it a type error as in type face or font?

TypeError: Error #1034?
Hi,

I'm new to AS3 and flash but I managed to learn from alot of reading. I have some code uploaded at this link: http://www.chuayou.com/pages/programs.htm but I'm getting an error. Namely this is the error I'm receiving:


Code:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::TimerEvent@70180b1 to flash.utils.Timer.
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()
This is the code for the main class that I'm using:


Code:
package com.chuayou {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import fl.controls.NumericStepper;
import fl.controls.ComboBox;
import fl.controls.TextInput;
import fl.controls.Label;
import fl.data.DataProvider;
import fl.managers.StyleManager;

public class Bubbles extends Sprite {
// Global variables
private var balls:Array = new Array();
private var numBalls:uint = 10;
private var centerBall:Ball = new Ball(100, 0xCC0000, 0xF0FD79, [0, 255], 0.5);
private var bounce:Number = -0.7;
private var spring:Number = 0.15;
private var hiSpeed:Number = 3;
private var lowSpeed:Number = 1;
private var gravity:Number = 0.6;
private var mass:Number = 0;
private var friction:Number = 0.6;
private var angle:Number = 0;
private var angleSpeed:Number = 0.015;
private var go:Number = 0;

// Component variables
private var bg:Sprite = new Sprite();
private var ns_numBalls:NumericStepper = new NumericStepper();
private var cb_mass:ComboBox = new ComboBox();
private var cb_friction:ComboBox = new ComboBox();
private var cb_bounce:ComboBox = new ComboBox();
private var cb_spring:ComboBox = new ComboBox();
private var lbl_mass:Label = new Label();
private var lbl_friction:Label = new Label();
private var lbl_ballCount:Label = new Label();
private var lbl_bounce:Label = new Label();
private var lbl_spring:Label = new Label();

// Global constants
private const yAlign:Number = 20;
private const ylblAlign:Number = 2;
private const cbWidth:Number = 70;
private const xPad:Number = cbWidth + 10;
private const blockIndent:Number = -2;
private const top:Number = 50;
private const bottom:Number = stage.stageHeight;
private const left:Number = 0;
private const right:Number = stage.stageWidth;
private const centerY:Number = bottom / 2;
private const centerX:Number = right / 2;

public function Bubbles() {
init();
}

// START: INITIALIZATION //
private function init():void {
addChild(centerBall);
centerBall.x = centerX;
centerBall.y = centerY;
drawBalls(numBalls);

// Initialize UI components and header here
drawBG(0x393939);
drawCBGravity();
drawCBFriction();
drawNumBalls();
drawCBBounce();
drawCBSpring();
drawLabels();
styleComponents();

// Event Listeners created here
addEventListener(Event.ENTER_FRAME, onEnterFrame);
centerBall.addEventListener(MouseEvent.MOUSE_DOWN, onHold);
ns_numBalls.addEventListener(Event.CHANGE, nsChange);
cb_mass.addEventListener(Event.CHANGE, cbGravChange);
cb_friction.addEventListener(Event.CHANGE, cbFricChange);
cb_bounce.addEventListener(Event.CHANGE, cbBounceChange);
cb_spring.addEventListener(Event.CHANGE, cbSpringChange);
}

private function drawBalls(numBalls:Number):void {
// Creates variable-defined number of smaller balls
for (var i:uint = 0; i < numBalls; i++) {
var ball:Ball = new Ball(Math.random() * 40 + 5, Math.random() * 0xffffff, 0xF0FD79, [0, 100]);
ball.x = Math.random() * stage.stageWidth;
ball.y = Math.random() * stage.stageHeight;
ball.vx = Math.random() * hiSpeed + lowSpeed;
ball.vy = Math.random() * hiSpeed * gravity + lowSpeed;
addChild(ball);
balls.push(ball);
}
}
// END: INITIALIZATION //


// START: DRAW UI COMPONENTS //
private function drawBG(color:Number):void {
bg.graphics.clear();
bg.graphics.beginFill(color);
bg.graphics.drawRect(0, 0, right, 50);
bg.graphics.endFill();
addChild(bg);
}

private function drawCBGravity():void {
var dp:DataProvider = new DataProvider();
dp.addItem({label: "Low", data: 1});
dp.addItem({label: "Medium", data: 2});
dp.addItem({label: "High", data: 3});
cb_mass.dataProvider = dp;
cb_mass.move(10, yAlign);
cb_mass.width = cbWidth;
cb_mass.selectedIndex = 1;
bg.addChild(cb_mass);
}

private function drawCBFriction():void {
var dp:DataProvider = new DataProvider();
dp.addItem({label: "Low", data: 1});
dp.addItem({label: "Medium", data: 2});
dp.addItem({label: "High", data: 3});
cb_friction.dataProvider = dp;
cb_friction.move(cb_mass.x + xPad, yAlign);
cb_friction.width = cbWidth;
cb_friction.selectedIndex = 1;
bg.addChild(cb_friction);
}

private function drawNumBalls():void {
ns_numBalls.move(cb_friction.x + xPad, yAlign);
ns_numBalls.maximum = 50;
ns_numBalls.minimum = 1;
ns_numBalls.value = 10;
ns_numBalls.width = 50;
bg.addChild(ns_numBalls);
}

private function drawCBBounce():void {
var dp:DataProvider = new DataProvider();
dp.addItem({label: "Low", data: 1});
dp.addItem({label: "Medium", data: 2});
dp.addItem({label: "High", data: 3});
dp.addItem({label: "Insane", data: 4});
cb_bounce.dataProvider = dp;
cb_bounce.move(ns_numBalls.x + xPad, yAlign);
cb_bounce.width = cbWidth;
cb_bounce.selectedIndex = 1;
bg.addChild(cb_bounce);
}

private function drawCBSpring():void {
var dp:DataProvider = new DataProvider();
dp.addItem({label: "Low", data: 1});
dp.addItem({label: "Medium", data: 2});
dp.addItem({label: "High", data: 3});
dp.addItem({label: "Insane", data: 4});
cb_spring.dataProvider = dp;
cb_spring.move(cb_bounce.x + xPad, yAlign);
cb_spring.width = cbWidth;
cb_spring.selectedIndex = 1;
bg.addChild(cb_spring);
}

private function drawLabels():void {
// Gravity
lbl_mass.move(cb_mass.x + blockIndent, ylblAlign);
lbl_mass.text = "Mass: ";
lbl_mass.autoSize = TextFieldAutoSize.LEFT;
bg.addChild(lbl_mass);
// Friction
lbl_friction.move(cb_friction.x + blockIndent, ylblAlign);
lbl_friction.text = "Friction: ";
lbl_friction.autoSize = TextFieldAutoSize.LEFT;
bg.addChild(lbl_friction);
// Ball Count
lbl_ballCount.move(ns_numBalls.x + blockIndent, ylblAlign);
lbl_ballCount.text = "Balls: ";
lbl_ballCount.autoSize = TextFieldAutoSize.LEFT;
bg.addChild(lbl_ballCount);
// Bounce
lbl_bounce.move(cb_bounce.x + blockIndent, ylblAlign);
lbl_bounce.text = "Bounce: ";
lbl_bounce.autoSize = TextFieldAutoSize.LEFT;
bg.addChild(lbl_bounce);
// Spring
lbl_spring.move(cb_spring.x + blockIndent, ylblAlign);
lbl_spring.text = "Spring: ";
lbl_spring.autoSize = TextFieldAutoSize.LEFT;
bg.addChild(lbl_spring);
}

private function styleComponents():void {
var format:TextFormat = new TextFormat("Arial", 12, 0xFFFFFF, true);
format.letterSpacing = 1;
StyleManager.setComponentStyle(Label, "textFormat", format);
format = new TextFormat("Arial", 10, 0x000000);
StyleManager.setComponentStyle(TextInput, "textFormat", format);
}
// END: DRAW UI COMPONENTS //

// START: EVENT HANDLERS //
private function onEnterFrame(evt:Event):void {
// Creating ball objects
for (var i:uint = 0; i < numBalls - 1; i++) {
var ball0:Ball = balls[i];
for (var j:uint = i + 1; j < numBalls; j++) {
var ball1:Ball = balls[j];
var dx:Number = ball1.x - ball0.x;
var dy:Number = ball1.y - ball0.y;
var dist:Number = Math.sqrt(dx * dx + dy * dy);
var minDist:Number = ball0.radius + ball1.radius;
// Bounce code
if (dist < minDist) {
var angle:Number = Math.atan2(dy, dx);
var targetX:Number = ball0.x + Math.cos(angle) * minDist;
var targetY:Number = ball0.y + Math.sin(angle) * minDist;
var ax:Number = (targetX - ball1.x) * spring;
var ay:Number = (targetY - ball1.y) * spring;
ball0.vx -= ax * friction;
ball0.vy -= ay * friction;
ball1.vx += ax * friction;
ball1.vy += ay * friction;
}
}
}

for (i = 0; i < numBalls; i++) {
var ball:Ball = balls[i];
// Movement code
move(ball);
// Blur checker
blurBalls(ball);
// Bounce or Spring code
dx = ball.x - centerBall.x;
dy = ball.y - centerBall.y;
dist = Math.sqrt(dx * dx + dy * dy);
minDist = ball.radius + centerBall.radius;
if (dist < minDist) {
angle = Math.atan2(dy, dx);
targetX = centerBall.x + Math.cos(angle) * minDist;
targetY = centerBall.y + Math.sin(angle) * minDist;
ball.vx += (targetX - ball.x) * spring * friction;
ball.vy += (targetY - ball.y) * spring * friction;
}
}

blurBalls(centerBall);
}

private function onHold(evt:MouseEvent):void {
centerBall.startDrag();
blurBalls(centerBall, false, true);
centerBall.addEventListener(MouseEvent.MOUSE_UP, onLetGo);
}

private function onLetGo(e:MouseEvent):void {
centerBall.stopDrag();
blurBalls(centerBall, true);
centerBall.removeEventListener(MouseEvent.MOUSE_UP, onLetGo);
}

private function nsChange(evt:Event):void {
var oldBalls:uint = balls.length;
numBalls = ns_numBalls.value as uint;
var newBalls:uint = numBalls;
var count:uint = Math.abs(oldBalls - newBalls);
if (newBalls > oldBalls) {
for (var i:uint = 0; i < count; i++) {
var ball:Ball = new Ball(Math.random() * 40 + 5, Math.random() * 0xffffff, 0xF0FD79, [0, 100]);
ball.x = Math.random() * stage.stageWidth;
ball.y = Math.random() * stage.stageHeight;
ball.vx = Math.random() * hiSpeed + lowSpeed;
ball.vy = Math.random() * hiSpeed * gravity + lowSpeed;
addChild(ball);
balls.push(ball);
}
} else if (newBalls < oldBalls) {
for (i = 0; i < count; i++) {
removeChild(balls.pop());
}
}
}

private function cbGravChange(evt:Event):void {
var e:String = cb_mass.value;
switch (e) {
case '1' :
mass = - 3;
break;

case '2' :
mass = 0;
break;

case '3' :
mass = 3;
break;

default :
mass = 0;
break;
}
}

private function cbFricChange(evt:Event):void {
var e:String = cb_friction.value;
switch (e) {
case '1' :
friction = 0.9;
break;

case '2' :
friction = 0.5;
break;

case '3' :
friction = 0.3;
break;

default :
friction = 0.5;
break;
}
}

private function cbBounceChange(evt:Event):void {
var e:String = cb_bounce.value;
switch (e) {
case '1' :
bounce = -0.2;
break;

case '2' :
bounce = -0.4;
break;

case '3' :
bounce = -0.7;
break;

case '4' :
bounce = -1;
break;

default :
bounce = -0.5;
break;
}
}

private function cbSpringChange(evt:Event):void {
var e:String = cb_spring.value;
switch (e) {
case '1':
spring = 0.10;
break;

case '2':
spring = 0.15;
break;

case '3':
spring = 0.3;
break;

case '4':
spring = 0.7;
break;

default:
spring = 0.15;
break;
}
}
// END: EVENT HANDLERS//

// START: MOTION AND PHYSICS GRAPHICS //
private function blurBalls(ball:Ball, stop:Boolean = false, keep:Boolean = false):void {
go = Math.random();
var range:Number = 10;
var frequency:Number = 0.4;
var flicker:Number = 5;
if (!stop && !keep && go < frequency) {
var blurX:Number = Math.cos(angle) * range + flicker;
var blurY:Number = Math.sin(angle * angle) * range + flicker;
} else if (!stop && keep) {
blurX = 50;
blurY = 50;
} else if (stop) {
blurX = 0;
blurY = 0;
}

var filterB:BlurFilter = new BlurFilter(blurX, blurY, BitmapFilterQuality.HIGH);
var filterArray:Array = new Array;
filterArray.push(filterB);
ball.filters = filterArray;
angle += angleSpeed;
}

private function move(ball:Ball):void {
// Create Boundaries
if (ball.x + ball.radius > right) {
ball.x = right - ball.radius;
ball.vx *= bounce;
} else if (ball.x - ball.radius < left) {
ball.x = left + ball.radius;
ball.vx *= bounce;
}
if (ball.y + ball.radius > bottom) {
ball.y = bottom - ball.radius;
ball.vy *= bounce;
} else if (ball.y - ball.radius < top) {
ball.y = top + ball.radius;
ball.vy *= bounce;
}
ball.x += (ball.vx * friction * gravity);
ball.y += (ball.vy * friction * gravity) + mass;
}
// END: MOTION AND PHYSICS GRAPHICS //
}
}
This is the code for the ball class that gets called in:

Code:
package com.chuayou {
import flash.display.Sprite;
import flash.display.GradientType;

public class Ball extends Sprite {
public var radius:Number;
public var color1:uint;
public var color2:uint;
public var ratios:Array;
public var focalPoint:Number;
public var vy:Number = 0;
public var vx:Number = 0;

public function Ball(radius:Number = 40, color2:uint = 0xCA2424, color1:uint = 0xF0FD79, ratio:Array = null, focalPoint:Number = 0.1) {
this.radius = radius;
this.color1 = color1;
this.color2 = color2;
ratios = ratio;
focalPoint = focalPoint;
init(focalPoint);
}

public function init(focalPoint):void {
var colors:Array = [color1, color2];
var alphas:Array = [1, 1];
var fp:Number = focalPoint
graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, null, null, null, fp);
graphics.drawCircle(0, 0, radius);
graphics.endFill();
}
}
}
I know this is a TON of code to look over, but can anyone please help me! Its incredibly URGENT that I resolve this ASAP!

TypeError: Error #1010: ..WHY?
Hello, I'm just starting with AS3 and am confused by this error:

TypeError: Error #1010: A term is undefined and has no properties.
at com.

It occurs when I don't remove an event listener that is called for Event.COMPLETE. I am building an app that loads external (local) swf files. When they complete loading, unless i remove the event listener for Event.COMPLETE within the handler function, it calls that error.

Thats fine with me, but I just want to understand what's going on.

Thanks.

TypeError: Error #1009:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at test_fla::MainTimeline/test_fla::frame1()

Everything was working fine until I added a new btn (btn_4XPress) on the branding page (Frame 4). I do not know why this is happening, can anyone help?

Test FLA

Thank you!

TypeError: Error #1034:
Hello everyone, I have a problem trying convert some timeline code into a class. I posted the whole class code but the problem I am having is at the beginning when I create the array photos.

This array consists in 6 movieclips placed on the stage. The error I am getting is the following: TypeError: Error #1034: Type Coercion failed: cannot convert one$ to flash.display.DisplayObject. at projects::ZoomViewer().

Any help would be greatly appreciated.


PHP Code:



package projects {                import flash.display.MovieClip;            import flash.events.MouseEvent;            import gs.*;    public class ZoomViewer extends MovieClip {                        public function ZoomViewer() {           var photos:Array=new Array(one,two,three,four,five,six);            var currentPage:MovieClip=null;            removeChild(borde);            removeChild(fondo);                        for (var i:int = 0; i<6; i++) {                photos[i].alpha=1;                photos[i].buttonMode=true;                setChildIndex(photos[i], i+1);                this[photos[i].name+"X"]=photos[i].x;                this[photos[i].name+"Y"]=photos[i].y;            }            addEventListeners();            function addEventListeners():void {                for (var i:int = 0; i<6; i++) {                    photos[i].addEventListener(MouseEvent.MOUSE_OVER, mouseOver);                    photos[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOut);                    photos[i].addEventListener(MouseEvent.CLICK, mouseClickHandler);                }            }            function removeEventListeners():void {                for (var i:int = 0; i<6; i++) {                    photos[i].removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);                    photos[i].removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);                    photos[i].removeEventListener(MouseEvent.CLICK, mouseClickHandler);                }            }            function mouseOver(e:MouseEvent):void {                var button:MovieClip=e.target as MovieClip;                TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{colorize:0xff6600, amount:0.3, brightness:1.1}});            }            function mouseOut(e:MouseEvent):void {                var button:MovieClip=e.target as MovieClip;                TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{amount:0}});            }            function mouseClickHandler(e:MouseEvent):void {                addChild(fondo);                fondo.alpha=0;                TweenLite.to(fondo, 1, {alpha:1});                setChildIndex(fondo, 7);                removeEventListeners();                var button:MovieClip=e.target as MovieClip;                currentPage=button;                currentPage.alpha=1;                setChildIndex(currentPage, 9);                var stage_ratio=550/290;                var page_ratio:int = new int();                page_ratio=currentPage.width/currentPage.height;                if (page_ratio>=stage_ratio) {                    TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,                    scaleY: (550/currentPage.width)* 0.9,                    scaleX: (550/currentPage.width)* 0.9,                    colorMatrixFilter:{ amount:0}});                    borde.width=550*0.9+10;                    borde.height = (currentPage.height * 550/currentPage.width)* 0.9 +10;                } else if (page_ratio < stage_ratio) {                    TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,                    scaleY: (290/currentPage.height)* 0.9,                    scaleX: (290/currentPage.height)* 0.9,                    colorMatrixFilter:{amount:0}});                    borde.width = (currentPage.width * 290/currentPage.height)* 0.9 +10;                    borde.height=290*0.9+10;                }                currentPage.addEventListener(MouseEvent.CLICK, currentPageClicked);                addChild(borde);                borde.alpha=0;                borde.x=550/2;                borde.y=290/2;                TweenFilterLite.to(borde, 1, {alpha:1});                setChildIndex(borde, 8);            }            function currentPageClicked(e:MouseEvent):void {                currentPage.removeEventListener(MouseEvent.CLICK, currentPageClicked);                TweenLite.to(fondo, 1, {alpha:0, onComplete:removeFondo, onCompleteParams:[currentPage]});                TweenLite.to(currentPage, 0.5, {scaleX:1, scaleY:1, x:this[currentPage.name + "X"], y:this[currentPage.name + "Y"]});                TweenFilterLite.to(borde, 0.5, {alpha:0});            }            function removeFondo(currentPage) {                removeChild(fondo);                setChildIndex(currentPage,6);                removeChild(borde);                addEventListeners();            }        }    }} 

TypeError: Error #1034:
Hello everyone, I have a problem trying convert some timeline code into a class. I posted the whole class code but the problem I am having is at the beginning when I create the array photos.

This array consists in 6 movieclips placed on the stage. The error I am getting is the following: TypeError: Error #1034: Type Coercion failed: cannot convert one$ to flash.display.DisplayObject. at projects::ZoomViewer().

Any help would be greatly appreciated.


PHP Code:

package projects {
   
            import flash.display.MovieClip;
            import flash.events.MouseEvent;
            import gs.*;

    public class ZoomViewer extends MovieClip {
       
       
        public function ZoomViewer() {

           var photos:Array=new Array(one,two,three,four,five,six);

            var currentPage:MovieClip=null;
            removeChild(borde);
            removeChild(fondo);
           

            for (var i:int = 0; i<6; i++) {
                photos[i].alpha=1;
                photos[i].buttonMode=true;
                setChildIndex(photos[i], i+1);
                this[photos[i].name+"X"]=photos[i].x;
                this[photos[i].name+"Y"]=photos[i].y;
            }

            addEventListeners();

            function addEventListeners():void {
                for (var i:int = 0; i<6; i++) {

                    photos[i].addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
                    photos[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
                    photos[i].addEventListener(MouseEvent.CLICK, mouseClickHandler);
                }
            }

            function removeEventListeners():void {
                for (var i:int = 0; i<6; i++) {
                    photos[i].removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);
                    photos[i].removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
                    photos[i].removeEventListener(MouseEvent.CLICK, mouseClickHandler);
                }
            }

            function mouseOver(e:MouseEvent):void {
                var button:MovieClip=e.target as MovieClip;
                TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{colorize:0xff6600, amount:0.3, brightness:1.1}});
            }

            function mouseOut(e:MouseEvent):void {
                var button:MovieClip=e.target as MovieClip;
                TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{amount:0}});
            }

            function mouseClickHandler(e:MouseEvent):void {

                addChild(fondo);
                fondo.alpha=0;
                TweenLite.to(fondo, 1, {alpha:1});
                setChildIndex(fondo, 7);

                removeEventListeners();
                var button:MovieClip=e.target as MovieClip;
                currentPage=button;
                currentPage.alpha=1;
                setChildIndex(currentPage, 9);


                var stage_ratio=550/290;
                var page_ratio:int = new int();
                page_ratio=currentPage.width/currentPage.height;

                if (page_ratio>=stage_ratio) {
                    TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,
                    scaleY: (550/currentPage.width)* 0.9,
                    scaleX: (550/currentPage.width)* 0.9,
                    colorMatrixFilter:{ amount:0}});

                    borde.width=550*0.9+10;
                    borde.height = (currentPage.height * 550/currentPage.width)* 0.9 +10;

                } else if (page_ratio < stage_ratio) {
                    TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,
                    scaleY: (290/currentPage.height)* 0.9,
                    scaleX: (290/currentPage.height)* 0.9,
                    colorMatrixFilter:{amount:0}});

                    borde.width = (currentPage.width * 290/currentPage.height)* 0.9 +10;
                    borde.height=290*0.9+10;
                }

                currentPage.addEventListener(MouseEvent.CLICK, currentPageClicked);
                addChild(borde);
                borde.alpha=0;
                borde.x=550/2;
                borde.y=290/2;
                TweenFilterLite.to(borde, 1, {alpha:1});
                setChildIndex(borde, 8);
            }

            function currentPageClicked(e:MouseEvent):void {

                currentPage.removeEventListener(MouseEvent.CLICK, currentPageClicked);
                TweenLite.to(fondo, 1, {alpha:0, onComplete:removeFondo, onCompleteParams:[currentPage]});
                TweenLite.to(currentPage, 0.5, {scaleX:1, scaleY:1, x:this[currentPage.name + "X"], y:this[currentPage.name + "Y"]});
                TweenFilterLite.to(borde, 0.5, {alpha:0});
            }

            function removeFondo(currentPage) {
                removeChild(fondo);
                setChildIndex(currentPage,6);
                removeChild(borde);
                addEventListeners();
            }
        }
    }
}

TypeError: Error #1009:
Hi all, hope everything is well...

I'm currently working on a new project and using a loader container, however I seem to be getting this error message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mainClass/initStage()
at mainClass()

when the main.swf is ran it works fine, the problem seems to come when i try to load in the main.swf through the loader container.

This probably makes no sense, i'll be here all night and tomorrow if anyone can help and i can explain more.

I have a loader container that loads in the main.swf, within this is have the code:

Code:

import com.loading.LoadSWF;

var loader:LoadSWF = new LoadSWF("main.swf", true);
loader.addEventListener("displayObjectLoaded", onComplete, false, 0, true);
addChild(loader);

function onComplete(evt:Event):void
{
   trace("loaded complete received");
}

then within my main.fla i have a document class which is:

Code:

package
{
   // Import the following flash Classes
   import flash.display.Sprite;
   import flash.display.MovieClip;
   import flash.display.Stage;
   import flash.display.StageAlign;
   import flash.display.StageScaleMode;
   
   import flash.events.*;
   
   import flash.ui.ContextMenu;
   import flash.ui.ContextMenuItem;
   
   // Import the following External Classes
   import caurina.transitions.*;
   
   // Import the following self created Classes
   import com.xml.LoadXML;
   import com.loading.LoadSWF;
   
   public class mainClass extends Sprite
   {

      // Declare the following public variables


      // Declare the following private variables
      private var bg:MovieClip = new Background()
      private var myContextMenu:ContextMenu;
      private var _appData:LoadXML;
      private var _appContent:LoadSWF;
      private var i:int;
      
      public function mainClass():void
      {
         // Trace to check if the Document Class is working correctly
         trace ("Document Class Working Correctly");

         // Run the following functions on initialisation
         initStage();
         initXML();
         loadSWF();
         
      }
      
      private function initStage():void
      {
         // Set the stage attributes
         stage.frameRate = 30;
         stage.align = StageAlign.TOP_LEFT;
         stage.scaleMode = StageScaleMode.NO_SCALE;
         
         // Declare new context menu
         myContextMenu = new ContextMenu();
         this.contextMenu = myContextMenu;
         
         // Add the Event Listeners
         stage.addEventListener (Event.RESIZE, alignStage, false, 0, true);
         
         // Run following functions
         hideDefaultItems();
         addCustomItems()
         addBackground ();
         
      }
      
      private function initXML():void
      {
         _appData = new LoadXML("data/xml/index.xml");
         _appData.addEventListener("xmlLoaded", onLoadXML, false, 0, true);
      }
      
      public function onLoadXML(event:Event):void
      {
         trace("XML Loaded");
         
            for each (var item in _appData.xmlData.discipline[i].discipline_item.text)
            {
                trace(item);
               i++;
            }
      }
      
      private function loadSWF():void
      {
         _appContent = new LoadSWF ("fla/home.swf", true);
         _appContent.addEventListener("displayObjectLoaded", onComplete, false, 0, true);
         addChild(_appContent)
      }
      
      function onComplete(evt:Event):void
      {
         trace("loaded complete received");
      }
      
      private function hideDefaultItems():void
      {
         myContextMenu.hideBuiltInItems();
      }
      
      private function addCustomItems():void
      {
         var _tomWolfe:ContextMenuItem = new ContextMenuItem("Tom Wolfe 2008", false, true)
         myContextMenu.customItems.push(_tomWolfe);
         
         var _home:ContextMenuItem = new ContextMenuItem("_HOME", true, true)
         myContextMenu.customItems.push(_home);
         
         var _mens:ContextMenuItem = new ContextMenuItem("_MENS COLLECTION", false, true)
         myContextMenu.customItems.push(_mens);
         
         var _womens:ContextMenuItem = new ContextMenuItem("_WOMENS", false, true)
         myContextMenu.customItems.push(_womens);
         
         var _wolfePack:ContextMenuItem = new ContextMenuItem("_THE WOLFE PACK", false, true)
         myContextMenu.customItems.push(_wolfePack);
         
         var _stockist:ContextMenuItem = new ContextMenuItem("_STOCKIST", false, true)
         myContextMenu.customItems.push(_stockist);
         
         var _featuredCollection:ContextMenuItem = new ContextMenuItem("_FEATURED COLLECTION", false, true)
         myContextMenu.customItems.push(_featuredCollection);
      }
      
      private function addBackground ():void
      {
         // Add the public variables to the stage to create the background
         addChild (bg);
         bg.gotoAndPlay(2);
         
         // Set the attrbutes for the background
         bg.x = stage.stageWidth /2
         bg.y = stage.stageHeight / 2;
         
         // Use the tweener function to create the effect on enterframe
         //Tweener.addTween (bg,  {x:stage.stageWidth / 2, y:stage.stageHeight / 2, time:2.5, alpha:1, transition:"easeInOut"} );
      }
      
      private function alignStage (event:Event):void
      {
         // Organise the display objects when the stage is resized
         bg.x = stage.stageWidth / 2;
         bg.y = stage.stageHeight /2;
      }
   }
}

I'm guessing it's something that im not declaring on the stage...

Thanks for any help

Garfty!!

TypeError: Error #1009
hi i keep geting this erorr and i cant find out how to fix. can someone help?


Code:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at loadbar_fla::MainTimeline/loading()



Code:

stop();

addEventListener(Event.ENTER_FRAME,loading);

function loading(event:Event) {
   var bytestotal = stage.loaderInfo.bytesTotal;
   var bytesloaded = stage.loaderInfo.bytesLoaded;
   
   
   var percentVar = Math.round(bytesloaded * 100 /bytestotal );
   anyMessages.text =   percentVar + "% Loaded";
   customBar.gotoAndStop ( percentVar );
   
   if ( bytesloaded >= bytestotal) {
      removeEventListener(Event.ENTER_FRAME, loading );
      
      gotoAndStop(2);
      anyMessages.text = ""; //  << not really necessary, since we remove the text box in the next line anyway
      removeChild( anyMessages );
      removeChild( customBar );
   }
   
}

TypeError: Error #1006: Value Is Not A Function
Hi,

Im getting a weird error when I try to return an array in a function.
TypeError: Error #1006: value is not a function
The code calling the function is


[as] EQOutput=EQ.processSamples(44100,localPCMArray,num Samples,2);[as]

EQOutput as already been defined as an array.

The function that im calliing that should return an array value is

[as]package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;

public class E_Q {
public var filterType:int=4;// filterType should be passed as 4 this sets up a peaking filter. Const for now
public var numberInFrames:int;// numberOfFrames is the length in samples of one channels worth of aduio
public var frequency:Number;// frequency, bandwidth, and gain range between 0 and 255
public var bandwidth:Number;
public var gain:Number;
public var sampleRate:int;
public var channels:int;
public var inputData:Array=new Array();// inputData is a buffer numberInFrames*channels long of floats
public var outputData:Array=new Array();// outputData is a buffer numberInFrames*channels long of floats
public var lastInput:Array=new Array();
public var secondlastInput:Array=new Array();
public var lastOutput:Array=new Array();
public var secondlastOutput:Array=new Array();
public var eqResult:Array=new Array();

var b0:Number=0;
var b1:Number=0;
var a0:Number=0;
var a1:Number=0;
var a2:Number=0;

var b2:Number;


public function E_Q():void {

}
/*public function EQ_Samples(sRate:int,input:Array,numSamples:int,nu mChannels:int):Array {
this.inputData=input;//outPutFrom DSP Volume
this.sampleRate=sRate;
this.channels=numChannels;
this.numberInFrames=numSamples;
eqResult=processSample();
return eqResult;
}*/
public function processSamples(sRate:int,input:Array,numSamples:in t,numChannels:int):Array {


this.inputData=input;//outPutFrom DSP Volume
this.sampleRate=sRate;
this.channels=numChannels;
this.numberInFrames=numSamples;
this.gain=0;
this.frequency=128;
this.bandwidth=128;
//gain = 12.0 * (gain - 128.0)/127.0;
//frequency = 50.0*Math.exp((10.0,Math.LN10(11025.0/50.0)*(frequency-1)/254.0));
//bandwidth = 0.333*Math.exp((10.0,Math.LN10(3.0/0.333)*(bandWidth-1)/254));

var w0:Number=(2.0*Math.PI*frequency/sampleRate);
var A:Number=Math.exp(10.0(gain/40.0));
bandwidth=Math.exp(((2.0,bandwidth)*frequency - frequency)*2.0);
var Q:Number=(frequency/bandwidth);
var alpha:Number=(Math.sin(w0)/2.0*Q);




switch (filterType) {
case 0 :
b0 = (1 - Math.cos(w0)/2);
b1 = (1 - Math.cos(w0));
b2 = (1 - Math.cos(w0)/2);
a0 = (1 + alpha);
a1 = (-2*Math.cos(w0));
a2 = (1 - alpha);
break;

case 1 :
b0 = ((1 + Math.cos(w0))/2);
b1 = (-(1 + Math.cos(w0)));
b2 = ((1 + Math.cos(w0))/2);
a0 = (1 + alpha);
a1 = (-2* Math.cos(w0));
a2 = (1 - alpha);
break;

case 2 :

b0 = (Q*alpha);
b1 = (0.0);
b2 = (-Q*alpha);
a0 = (1 + alpha);
a1 = (-2*Math.cos(w0));
a2 = (1 - alpha);
break;

case 3 :

b0 = (1.0);
b1 = (-2.0*Math.cos(w0));
b2 = (1.0);
a0 = (1.0 + alpha);
a1 = (-2.0*Math.cos(w0));
a2 = (1.0 - alpha);
break;

case 4 :

b0 = (1.0 - alpha*A);
b1 = (-2.0*Math.cos(w0));//was cos f not cos??
b2 = (1.0 + alpha*A);
a0 = (1.0 + alpha/A);
a1 = (-2.0*Math.cos(w0));//was cos f not cos??
a2 = (1.0 - alpha/A);
break;

case 5 :

b0 = (A*( (A+1) - (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha));
b1 = (2*A*( (A-1) - (A+1)*Math.cos(w0)));
b2 = (A*( (A+1) - (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha));
a0 = ((A+1) + (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha);
a1 = (-2*( (A-1) + (A+1)*Math.cos(w0)));
a2 = ((A+1) + (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha);
break;

case 6 :

b0 = (A*( (A+1) + (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha));
b1 = (-2*A*( (A-1) + (A+1)*Math.cos(w0)));
b2 = ((A*( (A+1) + (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha)));
a0 = ((A+1) - (A-1)*Math.cos(w0) + 2*Math.sqrt((A)*alpha));
a1 = (2*( (A-1) - (A+1)*Math.cos(w0)));
a2 = ((A+1) - (A-1)*Math.cos(w0) - 2*Math.sqrt((A)*alpha));
break;
}
for (var x:int=0; x < channels; x++) {
for (var i:int=0; i < numberInFrames; i++) {
this.outputData[i*channels + x] = ((b0/a0)*inputData[i*channels + x] + (b1/a0)*lastInput[x] + (b2/a0)*secondlastInput[x] - (a1/a0)*lastOutput[x] - (a2/a0)*secondlastOutput[x]);

secondlastOutput[x] = lastOutput[x];
lastOutput[x] = outputData[i*channels + x];
secondlastInput[x] = lastInput[x];
lastInput[x] = inputData[i*channels + x];
}
}
return this.outputData;
}
}
}[as]


As far as I understand I have an array that I want to fill with the results of a function. Why on earth am I getting this error?

Thanks,
dub

TypeError: Error #1006: Value Is Not A Function.
I have been getting this eror and i cant seem to fix it
can you guys help?


Here is my code

package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import bb;
import ab;
public class FrameAnimation extends MovieClip {
protected var myShapeisplayObject;
public var a:ab;
public var b:bb;
protected var xs:Number = 3;
protected var ys:Number = 2;
protected var fpx:Number;
protected var fpy:Number;
protected var xl:Number;
protected var yl:Number;
protected var ax:Number;
protected var ay:Number;
protected var bv:Number = 0;
public function FrameAnimation() {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
a = new ab;
b = new bb;
myShape = getChildAt(0);
addChild(a);
a.x=400;
a.y=300;
}
private function onEnterFrame(event:Event):void {
fpx= myShape.x + (90(myShape.x-yl));
fpy= myShape.y + (90(myShape.y-xl));
if (bv==0) {
addChild(b);
b.x=a.x;
b.y=a.y;
ax= (fpx-a.x)/90 ;
ay= (fpy-a.y)/90;
bv=1;
}
b.x+=ax;
b.y+=ay;
myShape.x += xs;
myShape.y += ys;
if (b.x>800) {
removeChild(b);
bv=0;
}
if (b.x<0) {
removeChild(b);
bv=0;
}
if (b.y>600) {
removeChild(b);
bv=0;
}
if (b.y<0) {
removeChild(b);
bv=0;
}
if (myShape.x>790) {
myShape.x = 790;
xs *= -1;
}
if (myShape.x<10) {
myShape.x = 10;
xs *= -1;
}
if (myShape.y>590) {
myShape.y = 590;
ys *= -1;
}
if (myShape.y<10) {
myShape.y = 10;
ys *= -1;
}
xl = myShape.x;
yl = myShape.y;
}
}
}

Thanks for any help you can give

TypeError: Error #1006: Value Is Not A Function.
I am getting output like
TypeError: Error # 1006: value is not a function.
at actionscript_fla::MainTimeline/actionscript_fla::frame1();


ActionScript Code:
var headlineXML:XML = new XML();

headlineXML.load("D:/flash projects/flash1proj/headlines.xml");
headlineXML.onLoad = myLoad;
function myLoad(ok) {
    if (ok == true) {
        trace("headlines file loaded");
        Publish(this.firstChild);
    }}
headlineXML.onLoad = function(ok) {
    if (ok == true) {
        trace("headlines file loaded");
        Publish(this.firstChild);
    }}
function Publish(HeadlineXMLNode) {
    if (HeadlineXMLNode.nodeName == "broadcast") {
        var contentss = "Hi hello";
        var story = HeadlineXMLNode.firstChild;
        while (story != null) {
            if (story.nodeName.toUpperCase() == "STORY") {
                var lead = "";
                var body = "";
                var URLs = "";
                var element = story.firstChild;
                while (element != null) {
            if (element.nodeName.toUpperCase() == "LEAD") {
                        lead = element.firstChild.nodeValue;
                    }
            if (element.nodeName.toUpperCase() == "BODY") {
                        body = element.firstChild.nodeValue;
                    }
            if (element.nodeName.toUpperCase() == "URLs") {
                        URLs = element.firstChild.nodeValue;
                    }
                    element = element.nextSibling;
                }
                contentss="hello flahs";
                //contentss += "<font size='+2' color='#3366cc'><a href='"+URLs+"'>"+lead+"</a></font><br>"+body+"<br><br>";
                txt.htmlText = contentss;
            }
            story = story.nextSibling;
        }
    }
   
}

EDIT
please put code in
[ as ] [ /as ] tags (without spaces)

Help With Condition - TypeError: Error #1009:
Hi, I would like to request help coming up with the correct condition to check to see if myloader is loaded. If it is loaded then unload it and proceed to news.. If its not then simply continue to news.

Thought I had it, but it causes the error below during navagation, and now my news button is not working? Thanks in advance for your valued time~

################################################## #

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at testSite_fla::MainTimeline/gotoNews()

################################################## #

news_btn.addEventListener(MouseEvent.CLICK, gotoNews);

function gotoNews(event:MouseEvent):void {

if (myloader.content!=null) {
stage.removeChild(myloader);
myloader.unload();
trace("unloaded");
gotoAndStop("news");
} else {
gotoAndStop("news");
}
}

TypeError When Migrating Code To A Class
Hi,
I'm trying to modify some particle generating code from Seb Lee-Delisle by moving it off the timeline and into a class. On the timeline, the code runs great. I want to control when the particle fires, so I moved it into a document class which calls Seb's class. No prob so far.

But when the code in the document class runs as a constructor function I get the following error when it begins to build the particles: TypeError: Error #1034: Type Coercion failed: cannot convert global@3385101 to flash.display.DisplayObjectContainer.
What am I referencing wrong?
notes:
The error happens at var particle:Particle = new Particle(Spark, this, 60, 400);
Spark is an embedded asset with class "Spark" in the .fla library

document class GreenParticles.as

ActionScript Code:
package com.thomasakirk{
    import flash.events.*;
    import flash.display.*;
    import com.sebleedelisle.Particle;

    public class GreenParticles extends Sprite {
        function GreenParticles() {
            trace("init!");
            //count particles
            var count:Number = 0;
            //create particles array
            var particles:Array = new Array();
            //listen for new frame
            addEventListener(Event.ENTER_FRAME, enterFrame);
            //what to do on each frame
            function enterFrame(e:Event) {
                //max particles is 85
                if (count < 85) {
                    // make a new particle
                    var particle:Particle = new Particle(Spark, this, 60, 400);
                    //set random particle rotation
                    var thisRot:Number = Math.floor(randRange(0,360));
                    particle.clip.rotation = thisRot;
                    // give it a random velocity
                    particle.setVel(randRange(0,30), randRange(-10,5));
                    // add drag;
                    particle.drag = 0.96;
                    // fade out
                    particle.fade = 0;
                    // change size
                    particle.shrink = 1.05;
                    //gravity
                    particle.gravity = -.1;
                    // and add it to the particle array...
                    particles.push(particle);
                } else {
                    //trim array by 1 and get particle trimmed off
                    particle = Particle(particles.shift());
                    //remove that particle
                    particle.destroy();
                    //when you reach 0 particles, stop enter frame event
                    if (particles.length==0) {
                        removeEventListener(Event.ENTER_FRAME, enterFrame);
                    }
                }
                // go through the array of particles ...
                for (var i:Number = 0; i < particles.length; i++) {
                    // and update each one
                    particles[i].update();
                }
                //increment particle count
                count++;
            }
            //random number function
            function randRange(min:Number, max:Number) {
                var randomNum:Number = (Math.random() * (max - min )) + min;
                return randomNum;
            }
        }
    }
}

Seb's Class Particle.as

ActionScript Code:
package com.sebleedelisle
{

import flash.display.*; 
   
public class Particle
{
    public var xVel     :    Number;         // the x and y velocity of the particle
    public var yVel     :    Number;
   
    public var drag     :    Number = 1;     // the drag factor between 0 and 1, where 1 is no drag, and 0 is max drag.
   
    public var fade     :    Number = 0;  // the fade factor, works as a multiplier.
   
    public var shrink            :  Number = 1;      // another multiplier that changes the size.
                                                        // If < 1 then the particle graphic shrinks, >1 and the particle grows.
   
    public var gravity        : Number = 0;    // the amount of gravity to add to the yVelocity every frame. If < 0
                                                        // then gravity goes upwards.
   
    public var clip:DisplayObject;              // display object for the particle
   
   
    public function Particle ( spriteclass : Class, targetclip : DisplayObjectContainer, xpos : Number, ypos : Number)
    {
       
       
        // instantiate a new particle graphic
        clip = new spriteclass();
       
        // and add it to the stage
        targetclip.addChild(clip);
       
        // and set its position
        clip.x = xpos;
        clip.y = ypos;

    }
   
    public function setVel(xvel:Number, yvel:Number)
    {
        xVel = xvel;
        yVel = yvel;
    }
   
    public function setScale(newscale:Number)
    {
        clip.scaleX = clip.scaleY = newscale;
    }
   
    public function update()
    {
       
        // add the velocity to the particle's position...
        clip.x += xVel;
        clip.y += yVel;
       
        // apply drag
        xVel*=drag;
        yVel*=drag;
       
        // fade out
        clip.alpha -=fade;
       
        // scale
        clip.scaleX = clip.scaleY *=shrink;
       
        // gravity
        yVel+=gravity;
       
    }
   
    public function destroy():void
    {
        clip.parent.removeChild(clip);
       
    }
}
}

TypeError: Error #1006: Value Is Not A Function.
Hi there. I'm trying to do a very simple urlRequest ...

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,onLoadCSS);
loader.load(new URLRequest("htmlStyles.css"));

But I'm getting this error message ...

TypeError: Error #1006: value is not a function.
at url_loader/::onLoadCSS()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

I've checked and double-checked the code and it is fine. The error suggests problems with the EventDispatcher class itself. Anyone have any ideas at all?

TypeError: Error #1009 (loaded SWF)
I'm pulling out my hair on this one!

I'm just starting a site (full-Flash site) using CS3 and AS3. I'm pretty much accustom to the new AS3 changes. I built a rough structure to make sure the way I wanted to set the site up would work (loading in external SWFs, etc.). The tests worked.

Now, I'm going in to make some things real, and I'm getting this error as soon as an external SWF loads in:

-----------------------------------------------------------------------------------------------------------------------------------
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at test_fla::MainTimeline/test_fla::frame2()
-----------------------------------------------------------------------------------------------------------------------------------

I've tried narrowing it down, couldn't find the exact culprit (had to remove every ounce of ActionScript before it started to function again). So I started to rebuild that movie entirely -- cleared out the Library and deleted every layer. Didn't work. Couldn't even add a stop(); action in Frame 1.

Then I started completely fresh File > New, rebuilt again. I tested after every single change. I finally built it up to the point where I first tested the original, and it worked. So, then I added a couple more things tested again, and got the error again. Ahh, so I removed EXACTLY what I had just added. Tested again. SAME ERROR -- now it won't go away no matter what I remove!

Crazier yet is that I can still load in my other test SWF files and they have actions in them, and they're set up the exact same way -- but they work...

The whole site is new, so every SWF is CS3/AS3. I'm not even doing anything crazy, so I'm getting pretty frustrated trying to build an all AS3 site and I can't even do basic stuff....

I can upload/email the FLA files in question if anyone has time to look...

Thanks,
Brandon

TypeError: Error #1009: Cannot Access
For some GD reason I keep getting this error and I dont know why.


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at components.alpharaven::Frame/SetSize()
at framework/::StartAnimation()
I am attaching the files for reference. CAN SOMEONE PLEASE HELP!!!!. I cant seem to figure out the reason why its happening. Everything seems fine to me.

TypeError Issue And Timer Question
Hey all new to the forumns and learning AS3 which has been fun, and challenging at the same time. I have a slideshow with images and text driven by xml. I recently added a Timer variable to make the slides rotate automatic but it's given me this error in the output window.

TypeError: Error #1010: A term is undefined and has no properties.
at cycler_timer_fla::MainTimeline/slideIt()
at cycler_timer_fla::MainTimeline/onTimer()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()

Here is the code that I am using. Also I need to have the timer variable set to 0 when the user clicks either the next or previous button, so that when the user choses a slide they have the 7 seconds to read it. (make sense?) How would I do that in this code.

Thanks, look forward to adding the site to my list of daily reading.


cstudio

CODE // ------------------------------------------------------------------------

ActionScript Code:
<font color="Blue"><font color="Black">//Image Cycler using XML

import gs.TweenLite;
import gs.TweenFilterLite;
import fl.motion.easing.*;
import fl.transitions.*;
import fl.transitions.easing.*;


//************* Variables *************//

var slidesNum:Number = 0;
var slidesCur:Number = 0;
var nameArr:Array = new Array();
var descArr:Array = new Array();
var linksArr:Array = new Array();


//masks
cnt.mask = cntMsk;

//show hand cursor on the photo
cnt.buttonMode = true

//*************** XML ***************//

function onContentXMLLoad(event:Event):void {//content.xml loaded
var contentXML:XML = new XML(event.target.data);
contentXML.ignoreWhitespace = true;

slidesNum = contentXML.slides.item.length();

for (var i:int = 0; i<slidesNum; i++) {
//Set the title, description and url
nameArr.push(contentXML.slides.item[i].@name);
descArr.push(contentXML.slides.item[i].@caption);
linksArr.push(contentXML.slides.item[i].@url);

//load image
var slideLoader = new Loader();
slideLoader.load(new URLRequest(contentXML.slides.item[i].@img));
slideLoader.x = 400*i;

cnt.addChild(slideLoader);
}
}

var contentXMLLoader:URLLoader = new URLLoader();
contentXMLLoader.addEventListener(Event.COMPLETE, onContentXMLLoad, false, 0, true);
contentXMLLoader.load(new URLRequest("content.xml"));//load content.xml


//************* Functions *************//
function slideIt():void {
TweenLite.to(cnt, .3, {x:slidesCur*-400, ease:Regular.easeOut});
ui.nameTxt.text = nameArr[slidesCur];
ui.descTxt.text = descArr[slidesCur];
}



var timer:Timer = new Timer(7000);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();

function onTimer(evt:TimerEvent):void {
TweenLite.to(cnt, .3, {x:slidesCur*-400, ease:Regular.easeOut});
ui.nameTxt.text = nameArr[slidesCur];
ui.descTxt.text = descArr[slidesCur];

if (slidesCur<slidesNum-1) {
slidesCur++;
} else {
slidesCur = 0;
}
slideIt();

trace("hey man");
}


//slide to the next/prev photo

//on ">" click
function onNextClick(event:MouseEvent):void {
if (slidesCur<slidesNum-1) {
slidesCur++;
} else {
slidesCur = 0;
}
slideIt();

}


//on "<" click
function onPrevClick(event:MouseEvent):void {
if (slidesCur>0) {
slidesCur--;
} else {
slidesCur = slidesNum-1;
}
slideIt();
}

//on photo click
function onSlideClick(event:MouseEvent):void {
navigateToURL(new URLRequest(linksArr[slidesCur]));
}


//************** Events **************//

ui.nextBtn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true);
ui.prevBtn.addEventListener(MouseEvent.CLICK, onPrevClick, false, 0, true);
cnt.addEventListener(MouseEvent.CLICK, onSlideClick, false, 0, true);
</font></font>

Copyright © 2005-08 www.BigResource.com, All rights reserved