PDA

View Full Version : AS2 game to AS3 Help?


theste123
09-06-2009, 09:18 PM
Hi all

I have made a escape the room game in flash using tutorials what was in as2 but now I have a hang of as2 so I wanted to do the same game in as3 but i am struggling to convert it to as3 so can anybody give me any hints or help to convert it to as3 thank you

this is the as2 game
32221

theste123
09-06-2009, 10:35 PM
hi all

sorry wrong file this is the right file
32222
sorry:p

tango88
09-07-2009, 07:23 AM
1 The onEnterFrame loop works differently. You'll need to use a listener for this. (Google it for lots of tutorials, or you could check mine out at www.flashbynight.com/tutes/gameloop/)

2 Try to put all the code on the timeline instead of the clips. Or use an external .as file.

3 myMc._visible is now myMC.visible

That should get you started, anyway.

theste123
09-07-2009, 10:55 AM
hi thanks for the hints and can i ask how to do this in as3
var squarelocated:String;
squarelocated = "Not located";
_root.inv_mc.square2_mc._visible = false;

thank you for all the hints :)

attunedesigns
09-07-2009, 06:23 PM
The String declaration is right, but _visible is now just visible. All underscored properties look normal in AS3. _root is probably stage, but could depend on how you are scoped.

theste123
09-09-2009, 10:29 PM
thank you for help I am still converting the game but having the error 1009 repeating to i close the game

this is the code
stop();

go1.addEventListener(MouseEvent.CLICK,toroom1);
go1.buttonMode = true;

box1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
box1.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
box1.buttonMode = true;
box2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
box2.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
box2.buttonMode = true;
box3.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
box3.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
box3.buttonMode = true;
key.addEventListener(MouseEvent.CLICK,keygot);
key.buttonMode = true;
key1.addEventListener(MouseEvent.MOUSE_DOWN,keygot 1);
key1.addEventListener(MouseEvent.MOUSE_UP,keygot2) ;
key1.addEventListener(Event.ENTER_FRAME,drag);
key1.buttonMode = true;
key1.visible=false;

function drag(event:Event):void {
if (key1.hitTestObject(go3)) {
gotoAndStop("room3");
}
}

function keygot1(event:MouseEvent):void {
text2.text = "You got the key.";
key1.startDrag();
}
function keygot2(event:MouseEvent):void {
key1.stopDrag();
}

function keygot(event:MouseEvent) {
key.visible=false;
key1.visible=true;
}

function mouseDownHandler(evt:MouseEvent):void {
var obj = evt.target;
obj.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
obj.stopDrag();
}

function toroom1(event:MouseEvent) {
gotoAndStop("room1");
}

please help

attunedesigns
09-10-2009, 02:37 AM
Where is the error occuring?

theste123
09-10-2009, 04:52 PM
This is what it is saying

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at pointandclick_fla::MainTimeline/drag()

attunedesigns
09-10-2009, 05:21 PM
Is 'go3' undefined?

theste123
09-10-2009, 05:51 PM
(go3) is a instance name sorry for not explaining very well

attunedesigns
09-10-2009, 05:55 PM
Check 'go3' and 'key1', make sure they are properly defined by the time drag() is called.

theste123
09-10-2009, 07:37 PM
I have check the go3 and key1 and it is still doing it :(
thank you the help

theste123
09-11-2009, 06:10 PM
hi all
i have add the file so you can have a look i am stuck and i can not figure it out plz help

32259

i will be happy with any help thank you

attunedesigns
09-11-2009, 06:26 PM
Ah. Since drag is executing on an ENTER_FRAME, and 'go3' only exists on frame 2... it throws an error when it changes to frame 3.

Easy fix:

function drag(event:Event):void {
if (key1.hitTestObject(go3)) {
key1.removeEventListener(Event.ENTER_FRAME,drag);
gotoAndStop("room3");
}
}

Shouldn't drag() be on MOUSE_DOWN?

theste123
09-11-2009, 06:39 PM
thank you for figureing it out and thankz again

theste123
09-17-2009, 06:02 PM
hi all i am have a little problem with the inventory i have all set up so if u click the box it disappears and reappears in the inventory but if i go to room 2 (frame2) and back to room 1(frame1) return to the stage hot do i make it stay in my inventory

plz help thank you

theste123
09-23-2009, 07:36 PM
hi all can anyone help me make a inventory i am having little problem with having 4 rooms the iterms are not staying in the inventory when i move rooms any ideas will help thank you