Objects aparently turning null

A place for tutorials on how to get the most out of Flash

Objects aparently turning null

Postby Toyloli » Mon Dec 24, 2012 6:40 am

Okay, so I've been trying to create a system for my flashy flash project where a player should be able to select a body type, then select a skin colour (and later a hair colour and hair style).

To do this I created objects for each body part (I have yet to bone them together) and in each body part is a different shape per frame (not much variance right now but I intend to be able to expand)
Then under the parts in each frame I was trying to apply a mask to a 'skintone' layer that I wanted to be able to change the frame or colour of to make the skin the right colour.

Unfortunately when I run it in practice, as soon as I change the body part to anything other than frame one, it loses the skincolour object somehow. I don't know why.

Can anyone please take a look at this, explain to me why it's doing what it is or if there is an easier way to change the skincolour without creating acres of duplicate objects within my project?
(Project is in CS5)
Attachments
ToyChipsChallenge.rar
(959.85 KiB) Downloaded 36 times
User avatar
Toyloli
 
Joined: Fri Oct 19, 2012 10:53 am
Location: Six feet down, three feet to the left and 12 feet up.

Re: Objects aparently turning null

Postby OwnerOfSuccuby » Mon Dec 24, 2012 1:24 pm

When you make objects if you do not like them play put stop(); in it.

One mistake was that you make object like graphick not movie clip so you can not ask it to play by its name (becouse it have not got name).
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Objects aparently turning null

Postby Toyloli » Mon Dec 24, 2012 2:09 pm

um, that isn't solving the problem.

The script that runs at Frame1 'stage level is supposed to load and lock all the component parts of Actionset to their first frame, with the sub object Skintone inside each object being set to the first frame. The Skintone objects are meant to be used to set the colour of the skin while the parent objects for each body part set the part shape.

The problem is getting the script to handle both the part shape assignment and the skin colour assignment.
Even in the 'modified and output' you just provided you have not got it doing that. The 'changer' is changing just the skintone (in the case of the main body) or just the face (in the case of the face)

The code does not throw a compile exception but you will notice when running from within flash that it is outputting "Cannot modify property of a null object" when it tries to change the skintone after changing the display frame of the individual body part.

Basically, I can get it to change the body part or the skin tone but I cannot (with my current design) achieve both.

And I know about the difference between graphic and movieclip. Any objects that were not 'Movieclip' in their instancing should have been that way - although I can check over them again. There are a lot of parts.

Basically your answer didn't help and was completely unrelated to the problem. But thank you for your reply anyhow, hope to work with you in future.
User avatar
Toyloli
 
Joined: Fri Oct 19, 2012 10:53 am
Location: Six feet down, three feet to the left and 12 feet up.

Re: Objects aparently turning null

Postby OwnerOfSuccuby » Mon Dec 24, 2012 5:03 pm

Oh i understand now.

But it is really hard to understand some thing in your code sorry :roll:

Try make it simpler.

First make function that change all components to what you want. Then ckeck them and change color by another function. You can check what characters component is select in frame by using for example MyArm.currentFrame

Put that function on may be the main layer or in player how you like more.

Now when part of code is in comonents and part in layers it is really hard to understand how do it work.

I always make it that way - just as example. download/file.php?id=6185

Then if you will need to change a color or any thing else you know what number have color or what do not so you can wright like:

if ((MyArmor==1) || (MyArmor>4)){SetColor=3} or some thing like that. Or some thing like that. You will not need so much code like now and it will be easier to understand what part of it do not work.

And for me is a little strange that male and female characters are in one charecter set - i mean they have a little different moves when they are naked :roll: - why to put them in ine component - or they will not have different moves in future ?
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Objects aparently turning null

Postby KaTsuO_O » Mon Dec 24, 2012 9:07 pm

It just seems like you're making it way too complicated. Though I only know how Actionscript 2.0 works.

I would write something like this to change the two:

For bodypart shape:
character.torso.nextFrame();
and then the other body parts.

For skintone:
character.torso.skin.nextFrame();
and then the the skin for the other body parts.

That's all you would need.
Don't create a porn game if you're only interested in porn.
Wise words regarding criticism http://www.youtube.com/watch?v=-98ZFl1sKt4
User avatar
KaTsuO_O
 
Joined: Tue Nov 02, 2010 6:03 pm

Re: Objects aparently turning null

Postby Toyloli » Tue Dec 25, 2012 4:27 am

And I thought I was doing it the simple say using gotoandstop... I can try that thanks, not sure if it will solve the problem I'm having though.
What I didn't understand why after I've say, set Torso to frame 2, It won't let me set a frame on Torso.Skintone.... Fiddling with it if the body part (torso) is on frame 1 then addressing torso.gotoAndStop(any number) will work.
But if Torso is not on frame 1 then it throws that "Cannot change the property or method of a null object" when it goes to change Torso.Skintone.

[shrugs] I'll try your suggestion, if it still has problems then I'll have to rip the skintone out from the subobject and just accept that there will be object duplication for each skintone....
[sigh]

What would be good is if I could just tell it to change the colour of the object using code. But oh well.
User avatar
Toyloli
 
Joined: Fri Oct 19, 2012 10:53 am
Location: Six feet down, three feet to the left and 12 feet up.

Re: Objects aparently turning null

Postby OwnerOfSuccuby » Tue Dec 25, 2012 11:22 am

Some times flash have this situation. Id doesnot load from memory or some where else part of anination or it is playing and have not got some object on it.

After you say it go some frame it is loaded and you can ask her do make some thing like part.goto or etc.

In AS 3 some times you do not remove some listeners and it say that some Nule is in your program. For example you go to the next frame where it is not such element. But the same time listener that catch some listener catch some thing and try to execute. He can not find the object and say null too.

Just ignore it - it means that some code is not optimezed but if it is working all is fine :mrgreen:
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Objects aparently turning null

Postby OwnerOfSuccuby » Tue Dec 25, 2012 11:40 am

Try to make it logicaly for example:

Make a player object that have legs and etc. All functions that will need to change it have to be or example on this layer. Or may be even upper than that on root.

Then you wright function for cosumization:

Not real code - i do not remember its syntacsis i always copy it :roll: :mrgreen:

function ArmorChange(ArmorNumber) BlaBlaBla

Player.LeftArm.gotoAndStop(ArmorNumber);
Player.RightArm.gotoAndStop(ArmorNumber);
Player.LeftLeg.gotoAndStop(ArmorNumber);
Player.Rightleg.gotoAndStop(ArmorNumber);
Player.Head.gotoAndStop(ArmorNumber);
Player.Torso.gotoAndStop(ArmorNumber);


function BodyColorChange(ArmorNumber) BlaBlaBla

if (ArmorNumber==1) {
if (Some condition or restrictions on armors) {
Player.Head.gotoAndStop(ArmorNumber or any other const);
Player.Torso.gotoAndStop(ArmorNumber or any other const);
}
}

if (ArmorNumber==2) {
if (Some condition or restrictions on armors) {
Player.Head.gotoAndStop(ArmorNumber or any other const);
Player.Torso.gotoAndStop(ArmorNumber or any other const);
}
}

And step by step you will get all the costumizations of your charecter. It is a little long to wright - but it is easy to be fixed. You see what armor sets you have you can easely add new and fix old. You will not change all components but if you will need to add any new components in it you will not need where to fix them to make it work.



Some times it is possible to make it in the components like it was in LegendOfKrystal game - there was solution like this: It check every frame where to go and if variable changes - it change the costumization. But for example it is possible to make it like making first frame in component that will direct where to go on itself. Then if you will need to change frame you only will need to make it go to the 1st frame. No functions no such big codes you will not need - and it works not bad too. And you will not need to make loops like in LoK game - it means less lags of code.


By the way Look how Corta make his components (Corta Charecter Template) - he is very very very good animator and painter i think, and hes components works, he even try to make the game with samus with it. It have some levels and is not bad but unfortunatly he dissapered some time ago and i do not know how progress goes with it :? :roll:
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Objects aparently turning null

Postby GoRepeat » Fri Dec 28, 2012 9:45 pm

I can't see your file atm, but is your color object in frame 2 and beyond of "torso" its own keyframe and properly named, or does it only "exist" in frame one and then filled over the rest of the torso clip? If thats not the issue then you probably have a type declaration messed up somewhere.

My default advice is always just use AS2 since it is so much easier to manipulate embedded clips. You could just control every single body part and color with a couple of arrays and one for loop in a root function (like 6 lines of code).
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 2:26 am
Location: Behind the Looking Glass

Re: Objects aparently turning null

Postby OwnerOfSuccuby » Fri Dec 28, 2012 10:24 pm

It is possible to make the same in AS3 too ;) But you are right that you need to wright more code in AS3 it is a little not good as i think =(
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Objects aparently turning null

Postby Toyloli » Sat Dec 29, 2012 1:30 pm

:) Thanks for all your input and feedback, I have really apreciated it.
It would appear that the nature of the problem was in relation to 'Skintone' being inside a Masking layer.
This apparently makes the object un-findable once the parent object has started playing, meaning I'm needing to find a way around this other than using masks. I'm souring that Corta's Template like you suggested cause it does seam a well designed system.
I want to source a copy of this 'Corta's template maker' thingy and I scoured his thread but the only downloads I could find were for CS6 (apparently) and I only have CS5.

I think I know how this is gonna go down. I will have to have Every body part in Every variation listed as a separate symbol (no simply drawing stuff onto a layer). On the upside I did some research and I have figured out and working the colorTransform method and can use it - so I will only need to symbolize a few of each body type and then I can simply colour it and be done. (Somebody set me onto this a while ago).
Again, thanks for your help so far.
User avatar
Toyloli
 
Joined: Fri Oct 19, 2012 10:53 am
Location: Six feet down, three feet to the left and 12 feet up.

Re: Objects aparently turning null

Postby Toyloli » Mon Dec 31, 2012 4:58 pm

Okay, so. for anyone who has been following this thread, after sleeping on it, mucking about and wasting some time I finally figured out the cause and the solution.

Step1 - the changer was changing the 'display' frame correctly using gotoAndStop.
Step2 - Having changed the display frame of a sub-object I must now 'Play' the current object and exit the script.
Step3 - on the next frame (or wherever) I call a seperate script that changes the colour of the bodypart.skin object(s).

The problem was originating from the subcontent of the subcortanious object not being initialized properly when telling it to gotoAndWhatever unless all stops related to the subject were released. This has allowed me to solve the problem I was having with my project in terms of character selectionage.

A few people on this website have my 'work so far' and I look forward to hearing from them on this topic.
Meanwhile - I will keep working. With all these 'bugs' worked out of what I was trying to do the next stage is mostly fine-tuning some iffy artwork and creating a key press processor script.

I WILL post my project within the week and I hope people comment (keeping in mind I knew nothing of flash two months ago).

Again, thankyou for all your assistance.
User avatar
Toyloli
 
Joined: Fri Oct 19, 2012 10:53 am
Location: Six feet down, three feet to the left and 12 feet up.


Return to Tutorials



Who is online

Users browsing this forum: No registered users