-
-
myLoader.load(myURL);
addChild(myLoader);
Try switching these two lines. I can explain further if you want
-
I tried switching them , but i still get the same Error message!
-
Senior Member
Can you be more specific what you load into what and in which context the scripts are.
- The right of the People to create Flash movies shall not be infringed. -
-
It's like this :
the main fla is "extrame car trace.fla" and there are 4 external AS files in the same folder : AIcar.as, playerCar.as, Timer.as, roadLane.as
so far, the they work fine, then i created a fla fiel called "Loader.fla" to load "extrame car trace.swf"
////////
code inside Loader.fla //first frame on main timeline//)
var myURL:URLRequest= new URLRequest("extrame car trace.swf");
var myLoader:Loader= new Loader();
myLoader.load(myURL);
addChild(myLoader);
////////////////////////////////
here is the code inside AIcar.as:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class AIcar extends MovieClip {
private var parent1:Object;
public var _status:Boolean;
public function AIcar() {
init();
}
private function init():void {
_status=true;
parent1= this.parent;
this.addEventListener(Event.ENTER_FRAME , enterFrameAction);
}
public function enterFrameAction(event:Event):void {
if (_status==true) {
if (parent1._hitAction==false) {
this.y+=parent1._speed*2/3;
} else {
}
if (this.hitTestObject(parent1.playerCar)) {
parent1.playerCar.play();
parent1._hitAction=true;
}
if (parent1._hitAction==true) {
parent1._speed=0;
}
if (this.y>460) {
parent1._score++;
//trace(parent1._score)
this.y=-60;
switch (Math.round(Math.random()*10)) {
case 0 :
this.x=184.6;
break;
case 1 :
this.x=364.6;
break;
case 2 :
this.x=244.6;
break;
case 3 :
this.x=304.6;
break;
case 4 :
this.x=184.6;
break;
case 5 :
this.x=364.6;
break;
case 6 :
this.x=244.6;
break;
case 7 :
this.x=304.6;
break;
case 8 :
this.x=184.6;
break;
case 9 :
this.x=364.6;
break;
}
//184.6 244.6 304.6 364.6
}
}
}
}
}
/////////////////////////////////
Error received :
[
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at extramecartrace_fla::MainTimeline/eventStage()
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display:isplayObject/flash.displayisplayObject::_hitTest()
at flash.display:isplayObject/hitTestObject()
at AIcar/enterFrameAction()
]
-
Senior Member
Try replacing this.hitTestObject with event.target. I assume that hitTestObject is on the timeline of the movie extrame car trace.
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|