Highlighted

TypeError: Error #1006: value is not a function.

Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

I'm getting this error:

TypeError: Error #1006: value is not a function.
    at project_fla::MainTimeline/createMap()
    at project_fla::MainTimeline/frame1()

heres the actionscript:

function createMap(target:Object, map:Array, tilesize:Number):void {
    for (var ix:Number=0; ix<map[0].length; ix++) {
        for (var iy:Number=0; iy<map.length; iy++) {
            this["t"+String(ix)+"x"+String(iy)] = new Object();
            this["t"+String(ix)+"x"+String(iy)] = new tile();
            this["t"+String(ix)+"x"+String(iy)].gotoAndStop(map[ix][iy]);
            this["t"+String(ix)+"x"+String(iy)].x = Flxy(new Point(ix,iy), tilesize).x;
            this["t"+String(ix)+"x"+String(iy)].y = Flxy(new Point(ix,iy), tilesize).y;
            target.addChild(this["t"+String(ix)+"x"+String(iy)]);
        }
    }
}

{/A]

What's wrong with the code?

There ya go. You have to give your clip on stage an instance name -when you select the clip - the instance name is the field above the instance behavior dropdown at the very top of the properties panel...

Topics

ActionScript

Views

12.3K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

TypeError: Error #1006: value is not a function.

Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

I'm getting this error:

TypeError: Error #1006: value is not a function.
    at project_fla::MainTimeline/createMap()
    at project_fla::MainTimeline/frame1()

heres the actionscript:

function createMap(target:Object, map:Array, tilesize:Number):void {
    for (var ix:Number=0; ix<map[0].length; ix++) {
        for (var iy:Number=0; iy<map.length; iy++) {
            this["t"+String(ix)+"x"+String(iy)] = new Object();
            this["t"+String(ix)+"x"+String(iy)] = new tile();
            this["t"+String(ix)+"x"+String(iy)].gotoAndStop(map[ix][iy]);
            this["t"+String(ix)+"x"+String(iy)].x = Flxy(new Point(ix,iy), tilesize).x;
            this["t"+String(ix)+"x"+String(iy)].y = Flxy(new Point(ix,iy), tilesize).y;
            target.addChild(this["t"+String(ix)+"x"+String(iy)]);
        }
    }
}

{/A]

What's wrong with the code?

There ya go. You have to give your clip on stage an instance name -when you select the clip - the instance name is the field above the instance behavior dropdown at the very top of the properties panel...

Topics

ActionScript

Views

12.3K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

oh, heres the other function being used in that function. its in frame1 aswell

function Flxy(p:Point, s:Number):Point {
    return new Point(s*(p.x-p.y)/2,s*(p.x+p.y)/4);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Jul 07, 2010

Copy link to clipboard

Copied

In Publish Settings > Flash Tab in the Advanced section check Permit Debugging - that will tell the line number of the error... I don't see anything at first glance. Although, I'm not sure why you have:

this["t"+String(ix)+"x"+String(iy)] = new Object();
this["t"+String(ix)+"x"+String(iy)] = new tile();

You can omit the new Object line...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

I forgot to emit that line.  It was a test of mine to try and get rid of the error but it didn't work .

It's gone now.

the line with the error is this:

line 88: target.addChild(this["t"+String(ix)+"x"+String(iy)]);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Jul 07, 2010

Copy link to clipboard

Copied

In a quick test that line seems to work OK for me... I think you can much simplify this though - something like so:

function createMap(target:Object, map:Array, tilesize:Number):void {
    var t:tile;
    for (var ix:Number=0; ix<map[0].length; ix++) {
        for (var iy:Number=0; iy<map.length; iy++) {           
            t = new tile();
            t.name = "t" + String(ix) + "x" + String(iy);
            t.gotoAndStop(map[ix][iy]);
            t.x = Flxy(new Point(ix,iy), tilesize).x;
            t.y = Flxy(new Point(ix,iy), tilesize).y;
            target.addChild(t);
        }
    }
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

I put in your code instead. Thanks for that .  Still getting the error tho.

target.addChild(t);

is giving me an error for some reason.  It's driving me crazy.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Jul 07, 2010

Copy link to clipboard

Copied

What is target?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

target is a movieclip on the stage called "g".

createMap(g, array, 40);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Jul 07, 2010

Copy link to clipboard

Copied

Outside of your function can you just do: g.addChild(new tile());  ?


Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

I just found out that it works when i use:

createMap(this, array, 40);

however,

i need to addChild into that g movieclip

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

when i try that outside the function it says

1061: Call to a possibly undefined method addChild through a reference with static type String.

does it think g is a string?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Jul 07, 2010

Copy link to clipboard

Copied

There ya go. You have to give your clip on stage an instance name -when you select the clip - the instance name is the field above the instance behavior dropdown at the very top of the properties panel...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Kyle517 LATEST
Explorer ,
Jul 07, 2010

Copy link to clipboard

Copied

hm.  it has an instance name g... in-fact all the other functions using that target work

i changed the instance name to "game" instead and used that same name in all the preceding functions and it works fine now.

i didn't define "g" anywhere else so it still confuses me. lol

but as long as it's working.  Thank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...