How would you use a MovieClip that's in the library in a document class?
Thanks
How would this be done in AS3?
Page 1 of 12 Replies - 520 Views - Last Post: 20 June 2009 - 09:32 AM
Replies To: How would this be done in AS3?
#2
Re: How would this be done in AS3?
Posted 14 June 2009 - 10:02 AM
Ryan1, on 14 Jun, 2009 - 08:35 AM, said:
How would you use a MovieClip that's in the library in a document class?
Thanks
Thanks
Right click the MC in the library and click linkage. You can then give it a class name. If that class exists (has to extend the MovieClip class) already (i.e defined in an AS file) then that class will take on the image of the MC, if not then a new class will be created. You can then refer to it as you would any other class:
var myMC:libraryMC = new libraryMC();
#3
Re: How would this be done in AS3?
Posted 20 June 2009 - 09:32 AM
UnknownFury, on 14 Jun, 2009 - 09:02 AM, said:
Right click the MC in the library and click linkage. You can then give it a class name. If that class exists (has to extend the MovieClip class) already (i.e defined in an AS file) then that class will take on the image of the MC, if not then a new class will be created. You can then refer to it as you would any other class:
var myMC:libraryMC = new libraryMC();
I guess I sort of understand this, but it's still not quite working right. I just let it make a new class, named Ball, and referred to it in the code. It adds the MC to the stage at the point 100, 100, but it doesn't allow the x-value to change. Here's the code I'm trying to use;
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Movement extends MovieClip {
private var ball:MovieClip;
public function Movement() {
init();
}
private function init():void {
var ball:Ball = new Ball;
addChild(ball);
ball.x = 100;
ball.y = 100;
addEventListener(Event.ENTER_FRAME,EnterFrame);
}
private function EnterFrame(event:Event):void {
ball.x += 5;
}
}
}
I end up getting this; TypeError: Error #1009: Cannot access a property or method of a null object reference. at Movement/EnterFrame()
Sorry to be a burden, but learning AS3 isn't working out too good for me.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|