PDA

View Full Version : addChild not working?



Xannax
October 2nd, 2007, 06:59 AM
I don't know what I am doing wrong;
I have created a class, named "Item.as" that is a holder for
1) some info: item name, item description, etc
2) image container: a container for the image
3) image container: a container for the thumbnail

the images containers are defined in a class named "Container.as"
Now, the container works by creating a "Loader", that loads the image
Once the image is loaded, the container dispatches an event event.complete

When the Item has received "complete" from both the image container, the thumbnail container and the variables loader, it displays both the image and the thumbnail by calling a function call displayImage(); this function actually calls a function in the "Container" class, also called displayImage(), which basically is:

addChild(currLoader)currLoader being of course the Loader object which loads the image.
I also do an addChild(image) (image being the Container object)
and an addChild(currItem) on the stage.

Aaannnnnnd....
Nothing happens.
If I place trace() events here and there, everything works; the events and functions are called in the right order, I get no error, but...Nothing appears on my screen!
I've been stuck on this since yesterday morning. I am going crazy. A little help would be warmly welcomed.
Thanks.

P.S: I have attached the classes in the crazy hope that someone will have enough free time to actually check them out. The code on my stage is:


import orient.*
var currItem:Item = new Item()
Item.url = "http://localhost/orient499/input.php";
currItem.load(4);
addChild(currItem);
stop();
Orient499 being the name of the website.

Xannax
October 2nd, 2007, 09:15 AM
Ok, I resolved my issue, only thing, I have no idea how. I simply erased everything and re-wrote everything from scratch, and it works. I compared the two set of files and I can see no difference, so I have no idea what solved it...Anyway I intend to post the full source once I'm over.

hakukaji
October 2nd, 2007, 09:19 AM
yeah im curious now. :look:

-Z-
October 2nd, 2007, 09:54 AM
Sometimes when I program I accidently hit a 1 or a l and it looks like an I or something like that, maybe that's what happend. And by re writting it you wrote over the wrong letter and replaced it with the right one, that's why I personally only use small letters for everything and _ to seperate words. instead of capitalizing first letters.

nikefido
October 2nd, 2007, 10:13 AM
Sometimes when I program I accidently hit a 1 or a l and it looks like an I or something like that, maybe that's what happend. And by re writting it you wrote over the wrong letter and replaced it with the right one, that's why I personally only use small letters for everything and _ to seperate words. instead of capitalizing first letters.

While I don't use "_", I definitely have used the "Find" feature and replace words with the right capitalization and what not. (command + F on Macintosh)

Xannax
October 2nd, 2007, 01:01 PM
Maybe, but I doubt it; it should have thrown an error if something was wrong with the syntax, no?
Anyway I'm having another issue here (I post in the same thread because if I open a new thread for every problem I have, i'll turn the boards into a mess)
I have this neat class that creates a tooltip, and I want the tooltip to follow the mouse;
problem:
if I addEventListen a mouseEvent.Mouse_MOVE to the tooltip, it is taken into account only when the mouse is over the tooltip;
I don't want to add a listener to the stage in the fla, because I want my class to be reusable by people that now nothing about coding;
And, if I add a stage.addEventListener in the class, I get a Error #1009: Cannot access a property or method of a null object reference., even though I have imported flash.display.Stage;
Anyone knows how to do that?

BradLee
October 2nd, 2007, 01:40 PM
You can only use the stage pointer when your object is in the display list. So if it's just been instantiated, but not added to the display list yet (using addChild) then stage will be null.

You can add an event listener to listen for the ADDED_TO_STAGE event, that'll let you know when it's safe to use the stage reference to add your mouse listener.

christiang
October 2nd, 2007, 02:07 PM
I have the same problem, also in Firefox 2.0.0.7. I've tested 2.0.0.4 and 2.0.0.6 and they work great as does IE7 and 6. But in 2.0.0.7 the thumbnails don't show.

This (http://www.bjarholm-olsson.se/synk/main.html) is the page.

See this (http://www.kirupa.com/forum/showthread.php?t=276193) thread for details. I'd love to see your work to compare it with mine. I'm completely stumped by this problem.

Xannax
October 2nd, 2007, 03:58 PM
Your problem is different from mine (my thumbs weren't showing, regardless of which browser I used), but still of premium importance. I think anyone who knows about this should help you because your issue concerns everyone who works in flash. From now on I'm gonna try my websites with every version of every browser!

Xannax
October 2nd, 2007, 04:09 PM
BradLee: thanks, it works! I would have - N - E - V - E - R - thought about it. Thanks again.