• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Guest
Jul 07, 2010 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?

TOPICS
ActionScript

Views

14.2K

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
community guidelines

correct answers 1 Correct answer

Deleted User
Jul 07, 2010 Jul 07, 2010

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...

Votes

Translate

Translate
Guest
Jul 07, 2010 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);
}

Votes

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
community guidelines
Guest
Jul 07, 2010 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...

Votes

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
community guidelines
Guest
Jul 07, 2010 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)]);

Votes

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
community guidelines
Guest
Jul 07, 2010 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);
        }
    }
}

Votes

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
community guidelines
Guest
Jul 07, 2010 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.

Votes

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
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

What is target?

Votes

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
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

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

createMap(g, array, 40);

Votes

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
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

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


Votes

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
community guidelines
Guest
Jul 07, 2010 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

Votes

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
community guidelines
Guest
Jul 07, 2010 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?

Votes

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
community guidelines
Guest
Jul 07, 2010 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...

Votes

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
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines