0

I think there may be a problem when I call the treeGroup symbol. As3 isnt adding it to the display list? I got the code to load the external swf file from adobe. They did have more than one method so Im probably using the wrong one. The external file thats loading throws the error that you can see in the screen shot. The code is there too. This file runs fine with no errors and when I load the swf in the other file it has the error listed. I can also see and change the X and Y locations on the loaded movie but its not running. So its loaded but looks to me that there could be a problem with adding to the display list or maybe cause im using MovieClip(root) cause line 12 is where I first use this. I have to do it this way cause I need to use setChildIndex. If there is a different way then I could not call the symbol in from the libary and should be fine.

The main movie is the main menu for the game. The other file I want to load in is the first hole for this golf game I am making.

Here is the link to adobe and I used the first method they listed. https://helpx.adobe.com/flash/kb/load-external-swf-swf.html

I can provide all code for both swf files if you need more info.

error code is ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData. at flash.display::BitmapData/hitTest() at Hole1_fla::Symbol2_1/treeDetect()[Hole1_fla.Symbol2_1::frame1:12]

this is how I am loading the swf.

var myLoader:Loader = new Loader();                     // create a new instance of the Loader class
var url:URLRequest = new URLRequest("Hole1.swf"); // in this case both SWFs are in the same folder 
myLoader.load(url);  

And I think the code in the symbol is the issue.

    var tree1:treeGroup = new treeGroup();
addChild(tree1);
setChildIndex(tree1,15);
var tree1Rect:Rectangle = tree1.getBounds(this);
var tree1ClipBmpData = new BitmapData(tree1Rect.width, tree1Rect.height, true, 0);
tree1ClipBmpData.draw(tree1);

addEventListener(Event.ENTER_FRAME,treeDetect);

function treeDetect(event:Event) {
    // code for trees to detect if we hit some trees
    if (tree1ClipBmpData.hitTest(new Point(tree1.x, tree1.y),255,MovieClip(root).ballClipBmpData,new Point(MovieClip(root).backhole1.golfball.x, MovieClip(root).backhole1.golfball.y),255)) { // this is line 12 poping the error in the symbol that is in the swf im loading in.
        if (MovieClip(root).backhole1.golfball.scaleX == .1 && MovieClip(root).backhole1.golfball.scaleY == .1) {
            setChildIndex(tree1,17);
            if (MovieClip(root).backhole1.golfball.scaleX >= .3 && MovieClip(root).backhole1.golfball.scaleY >= .3) {
                MovieClip(root).friction = .05;
            }
        }
        if (MovieClip(root).backhole1.golfball.scaleX <= .3 && MovieClip(root).backhole1.golfball.scaleY <= .3) {
            if (MovieClip(root).goingDown == 1) {
                MovieClip(root).friction = .08;
                setChildIndex(tree1,17);
                MovieClip(root).backhole1.golfball.scaleX = .1;
                MovieClip(root).backhole1.golfball.scaleY = .1;
                MovieClip(root).goingDown = 0;
            }
        }
    } else {
        setChildIndex(tree1,15);

    }
}

Where the first MovieClip(root) is in the hitTest is line 12 that pops the error message and is happening every frame.

jasonl
  • 23
  • 4
  • I didnt notice it before but there is a second error at the program start. TypeError: Error #1009: Cannot access a property or method of a null object reference. at Hole1_fla::MainTimeline/frame1()[Hole1_fla.MainTimeline::frame1:61] and I know for a fact this is because I am using keyboard functions in both fla files and attaching them both to the stage. Looks like I have to program the second file to be loaded so there is no conflicts. I will just give up on this for this program and make it one file and use the timeline to have the menu and gotoAndStop() to go to the hole 1 or options etc. – jasonl Mar 10 '19 at 13:36
  • I just thought of this. What if I put the symbol with the code for treeDetect() in the file where I load the swf and setup my stage for the keyboard listeners. Should correct the errors? – jasonl Mar 10 '19 at 14:07
  • Trace if **root** is defined at the moment **treeDetect** handler is called. If the **root** is undefined, that means the object with that code haven't been added to the display list. – Organis Mar 10 '19 at 22:34
  • I never thought of that. I did just give up and I used the timeline and will just build it with separate frames. Ill have to research loading files more. – jasonl Mar 12 '19 at 02:14

0 Answers0