Referencing joints by instance name

Post about the Flash World Construction Kit and the Alchemy port of Box2D.
celloe
Posts: 6
Joined: Sat Aug 03, 2013 8:49 am

Referencing joints by instance name

Postby celloe » Sat Aug 03, 2013 8:55 am

I've got a revolute joint set up between 2 bodies, and my goal is to make the joint break if too much force acts on it. It seems I could use GetReactionForce to do this, so I gave my joint an instance name, 'armjoint' - when I do this and then compile my project, it throws the error "\BlankProject\..\wck\World.as, Line 4 1000: Ambiguous reference to Joint".

When I give regular body movieclips instance names I can access their Box2D respective class properties such as 'active' etc, but I can't seem to do the same on joints. Does anybody have experience with this? Is it impossible to access certain joint properties that aren't directly on the WCK component properties without creating a class specific to the component?

IstvanOrosi
Posts: 172
Joined: Thu Mar 01, 2012 9:31 am

Re: Referencing joints by instance name

Postby IstvanOrosi » Wed Aug 07, 2013 5:13 pm

I have removed joints successfully with Util.remove(jointName). If you are adding the joint to another container than Util.remove(containerName.jointName).

Without seeing your project, my only guess at this point would be that you may not be referring properly to the joint.

Update:
I just remembered that "containerName" was actually a custom class in my project and I did create the "jointName" property in "containerName". So that may not be the issue.

So, how are you creating/adding the joint?

celloe
Posts: 6
Joined: Sat Aug 03, 2013 8:49 am

Re: Referencing joints by instance name

Postby celloe » Sun Aug 18, 2013 1:39 pm

Sorry for the late followup, I've been away! Removing objects with the Util class doesn't seem to be a problem, rather giving a joint on the stage an instance name at all appears to produce the error. Here's a basic example - http://www.filz.us/files/cb91ae43/928/tester.zip, where you should see if you remove the instance name from the joint in question, it'll begin to compile without that 'Ambiguous reference' error, seemingly with no issue. The only problem is, I kind of directly need the joints themselves to have instance name so I could recall Util.remove() on them in the first place! Is there anything simple I'm missing here? Or should I just start defining my joints in code?

IstvanOrosi
Posts: 172
Joined: Thu Mar 01, 2012 9:31 am

Re: Referencing joints by instance name

Postby IstvanOrosi » Sun Aug 18, 2013 6:01 pm

I can't seem to be able to open the .fla file. Probably my Flash is an earlier version.

I did create a test project as you described and was able to remove a joint with a specific instance name. Not sure what could be the issue.

Someone may have a suggestion but in the mean time try to create a joint with code and see if that works.

celloe
Posts: 6
Joined: Sat Aug 03, 2013 8:49 am

Re: Referencing joints by instance name

Postby celloe » Mon Aug 19, 2013 8:59 am

Converted it to a CS4 .fla - http://www.filz.us/files/199d873a/fa1/tester.zip

Would it be possible to see that test project? I really have no idea why it shouldn't work in my case, if it's going okay for you. Something I set up wrong perhaps.

Creating joints with code is working perfectly fine, however it's just a bit of a nuisance when the convenience of the wck components is there and I have a lot of joints to deal with.

IstvanOrosi
Posts: 172
Joined: Thu Mar 01, 2012 9:31 am

Re: Referencing joints by instance name

Postby IstvanOrosi » Mon Aug 19, 2013 3:58 pm

I seem to be getting some other errors that my be due to paths or maybe to CS4 conversion

I did notice a few things that may be related to the issue:
-Joints have to connect two objects. You only seem to have one circle
-I thought that the main class has to also extend WCK e.g. see Demo.as in the WCK demo
-Might not be an issue but instead of using World as the class name, it is better to use something unique e.g. myWorld.

celloe
Posts: 6
Joined: Sat Aug 03, 2013 8:49 am

Re: Referencing joints by instance name

Postby celloe » Sat Aug 24, 2013 8:42 am

Hm, joints must connect 2 objects? It seemed perfectly valid to have a joint between an object and the stage behind it, even the WCK demos make use of it - is there an alternate method I should be using? In any case, the final situation for where I'll use these joints is between 2 objects anyway, was just for the sake of example.
As far as I know about extending WCK, that's only for the use of the "b2Base.initialize(); Input.initialize(stage);" lines, which I have on the stage. So it's compiling and detecting that part fine, the only issue seems joint-specific. I think World.as is used internally by WCK anyway so I'm not sure if changing the filename of it would work.

Man! This is a weird issue. Would it be possible to see an example of a working joint that's removable through its instance name? Just so I can compare.

IstvanOrosi
Posts: 172
Joined: Thu Mar 01, 2012 9:31 am

Re: Referencing joints by instance name

Postby IstvanOrosi » Sun Aug 25, 2013 9:25 pm

Oh, you're right. Joints don't need 2 objects (though in the demo objects are placed in an object that extends wck.World and not the Flash stage). I started using joints with code and probably confused the issue with joint cannot be connected to another joint. It was strange that your sample seemed to work but I've seen things work somehow even though weren't intended/supposed to.

About World, I was thinking of: myWorld = new wck.World();

I basically used the steps in the sample tutorial:
https://github.com/jesses/wck/wiki/worl ... uction-kit

Try those steps. If that still doesn't work, I'll create an example and we can see what happens.

celloe
Posts: 6
Joined: Sat Aug 03, 2013 8:49 am

Re: Referencing joints by instance name

Postby celloe » Thu Aug 29, 2013 1:16 pm

It still doesn't seem to behave correctly. Here is what I modified from the demo files too, directly in "BlankProject" - http://www.filz.us/files/0b3f193a/1c9/wck-master.zip

I would love an example to see a version up and running!

IstvanOrosi
Posts: 172
Joined: Thu Mar 01, 2012 9:31 am

Re: Referencing joints by instance name

Postby IstvanOrosi » Thu Aug 29, 2013 6:17 pm

I couldn't open the .fla file again. Probably not CS4 version ;)

Clicking on the blue box will remove the joint. The code is on the frame(s) inside the .fla file.
http://www.filz.us/files/66e70afb/8da/Main.zip


Return to “WCK”



Who is online

Users browsing this forum: No registered users and 1 guest