Skip to main content
Inspiring
November 25, 2008
Answered

Need an opinion please

  • November 25, 2008
  • 16 replies
  • 2423 views
I am learning asc3 and loving it. I just ran into a problem as i tried to do a tutorial recently of where cards flip over and load random card design on them.

i constantly get this error. if someone can please verify my work and opinion and tell me where i made the mistake. I dont believe its in the code but the placement of the graphics but i need confirmation on it and also on where the error is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Card/settype()
at Memory/CardLoader()
at Memory()

PLEASE GO HERE TO GET ATTACHMENT OF MY FILES THAT I DID: http://www.actionscript.org/forums/showthread.php3?t=190078

Thank you
This topic has been closed for replies.
Correct answer Ned Murphy
I believe it had no issue compiling. The error you show is a run time error. I am assuming your fla file kicks off the show as soon as it's done compiling, and that's where it hit the snag... trying to act on an object that wasn't in scope. To talk to the object, it has to be present, but it was 5 frames down the road.

If you wanted to act on it when it finally got there, you would need to have assigned something up front in frame 1 (some variable(s)), and have some code in the frame down the line where Load_mc is that uses the variable(s).

What you could do as an alternative is have the Card or Load_mc invisible at frame 1, and then make it visible when you get to the frame you want it to show in.

16 replies

elyelyelyAuthor
Inspiring
November 26, 2008
Thanks Ned a lot again.... I will use your design method more i am sure....

But as i am learning actionscript 3 i think i would like to know what would of been the code for it to load at the 5th instead... I guess i have lots to learn but i think solving this thanks to you two allowed me to learn something new today.

Seems with all the var mentioning i think it will require another function and a whole hoopla to make that load from frame 5..

so from what i basicaly understood correct me if i am wrong...

//my code was good, BUT due to where the placement of my graphic of load_mc it didnt work as the program loaded much quicker then my graphics did so was too slow to get to the 5th frame for it to work properly... RIGHT???

thanks ned
elyelyelyAuthor
Inspiring
November 26, 2008
thanks again you two.
elyelyelyAuthor
Inspiring
November 26, 2008
Hello Ned,

Much appreciated and i did thank you two always..expert or no expert doesnt matter as any help is always appreciated. I know Kglad is always here to help and i am greatfull but its hard to describe it to someone who did not see your work so it cant always be explained well enough unless you see it. You saw it so was easier to understand and see my flaw.

Eitherway you both gave me much wisdom and help which i admire and i will remember that error; lol(trust me on it).

Thanks again Ned and Kglad!!!!
elyelyelyAuthor
Inspiring
November 26, 2008
thank you kglad. Load_mc does exist in the one i made but it existed in frame 8 instead of 1.... so it never loaded i guess...

in your scenario what would i done diff to make it load from the 5th frame .. as now the code works if load_mc graphic is placed as of the first frame and not 5th...

thanks again
kglad
Community Expert
Community Expert
November 26, 2008
Load_mc needs to exist when settype() is applied to a Card instance. if it existed, you wouldn't get that error.

and if Load_mc doesn't exist until the 5 or 8th frame of your card instance, you can apply settype() until that frame 5 or 8 renders.
elyelyelyAuthor
Inspiring
November 26, 2008
BINGO!!!! it works my friend and thank you so much Ned for patience and also Kglad for trying.

But a question why did i need to place it in first frame..is it a must for it to compile...

Also what would i need if i asked you that i wanted it to load the image as of frame 10 instead of lets say 1...is that possible or in this scenario its not


THANK YOU AGAIN!!!!!

**please let me know on my other questions
Ned Murphy
Ned MurphyCorrect answer
Legend
November 26, 2008
I believe it had no issue compiling. The error you show is a run time error. I am assuming your fla file kicks off the show as soon as it's done compiling, and that's where it hit the snag... trying to act on an object that wasn't in scope. To talk to the object, it has to be present, but it was 5 frames down the road.

If you wanted to act on it when it finally got there, you would need to have assigned something up front in frame 1 (some variable(s)), and have some code in the frame down the line where Load_mc is that uses the variable(s).

What you could do as an alternative is have the Card or Load_mc invisible at frame 1, and then make it visible when you get to the frame you want it to show in.
elyelyelyAuthor
Inspiring
November 26, 2008
so you saying to place it within the first frame....will try it as you confirm on my understanding to place it on first frame...
Ned Murphy
Legend
November 26, 2008
Try moving it to the first frame and see if that error still comes up. Code is processed faster than the blink of an eye, so even if you don't have a stop at frame 1 of Card, it's not likely to reach frame 2 by the time the code is processed. The Load_mc needs to be in sight when it's talked to.
elyelyelyAuthor
Inspiring
November 26, 2008
Basicaly its essential for me to understand where to place the loader_mc if i make my version of it so i can study it well and understand the concept from this tutorial...

thank you

**this would explain why it wont work also in mine as my loader_mc is placed from the 5th or so frame....
Ned Murphy
Legend
November 26, 2008
I'm hesitant to ask, figuring one or the other is a typo, but is the instance name load_mc or Load_mc?
elyelyelyAuthor
Inspiring
November 26, 2008
its Load_mc ... i just saying it here as load_mc but even in code its properly mentioned as Load_mc
Ned Murphy
Legend
November 26, 2008
I am at a disadvantage to help out directly because I do not have CS4, which I you assume do. I cannot open the fla file. But I could open the 2 as files that were included in your zip file and try to devise something to get something working. And I was eventually able to get passed the Load_mc issue, but I can't recall what I changed when that made it happen. It may have involved changing a private to a public. I had to get rid of the Triad elements because I had nothing to go on for that class since it wasn't in the zipped file.

Anyways, can you point me to the URL for the tutorial that you used for this. There's a chance I can work with that if it wasn't specifically authored for CS4. If yours has been modified to a great degree from the tutorial, then I probably won't pursue it... plenty I can do otherwise.

Just one final wondering first though... is the Load_mc in the first frame of the Card?

PS - I'll be off to bed in a short while, so don't wait around for me to get back with anything soon.
kglad
Community Expert
Community Expert
November 26, 2008
because you didn't answer my question in the affirmative, load_mc is probably the problem. it needs to exist when settype is called.
elyelyelyAuthor
Inspiring
November 26, 2008
Hello Kglad,

It is set but i am sure its not set properly and thats what i am trying to figure out. When i look into my card design. I see it and it has the name instant on it...i did this all day ( (&^()&(&)) ...but i guess trying to learn from my mistakes.

I am sure its something to do within the way i applied the instant of the card where the load_mc is embedded. But to pinpoint the error exactly ...thats what i am trying to do.


thanks again.

**like i said the link above takes you to where the file is....yes i know you dont do that but what your question is i know but to answer it is hard because what you hear is only the coordinates without the map...( which means the code without the flash.fla)...and i have gut feeling tis the way i placed my things that maybe is causing this problem.


thank you again
kglad
Community Expert
Community Expert
November 25, 2008
is Load_mc a child of Card?
elyelyelyAuthor
Inspiring
November 26, 2008
load_mc is an instance within the card. so that when the card flips then the other movieclip instance( in this case load_mc) will appear and load the image from the library which in this example is -Traid- upon itself.