Forum ‹ General ‹ Maybe one of you flash experts could help me understand it
9 posts
• Page 1 of 1
Maybe one of you flash experts could help me understand it
Hi everyone,
my co-worker on this project is currently away, and i'm trying to continue something he started.
now i'm getting this weird exception being thrown and i'm having some troubles debugging it.
my problem is this.
we have a component named map_mc (i'm guessing its a MovieClip component because of its name).
this component is throwing an exception of error 1009 (null value).
i've debugged the movie clip and found out this map_mc is set to null.
now, for some reason, I can't find its declaration anywhere! not in any of the .as files and not in the .fla
what i don't understand, is how come I don't get a compilation error if I can't find this component being declared in the first place, and all I get is a runtime error.
do you guys have any idea> maybe i'm not searching for it in the right places.
my co-worker on this project is currently away, and i'm trying to continue something he started.
now i'm getting this weird exception being thrown and i'm having some troubles debugging it.
my problem is this.
we have a component named map_mc (i'm guessing its a MovieClip component because of its name).
this component is throwing an exception of error 1009 (null value).
i've debugged the movie clip and found out this map_mc is set to null.
now, for some reason, I can't find its declaration anywhere! not in any of the .as files and not in the .fla
what i don't understand, is how come I don't get a compilation error if I can't find this component being declared in the first place, and all I get is a runtime error.
do you guys have any idea> maybe i'm not searching for it in the right places.
QiX
- QiX
- Posts: 34
- Joined: July 22nd, 2010, 4:41 pm
Re: Maybe one of you flash experts could help me understand it
There is a few ways an element could be auto defined. Can you paste the code where it errors?
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 749
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Maybe one of you flash experts could help me understand it
This are the 2 functions:
the first function is the handleJoing function thats being called when a user joins the room:
this function dynamically builds a map of tiles according to the information she already got from the server on the MapHandler message.
the only other usage i could find of this map_mc component, is at one of the .fla frames actions
Sorry if the code is a bit messy, we'll have to clean and re-organize it once the game's structure is complete
the first function is the handleJoing function thats being called when a user joins the room:
- Code: Select all
private function handleJoin(connection:Connection):void{
trace("Sucessfully connected to the multiplayer server");
addChild(infoBox);
infoBox.Show("waiting");
this.m_Connection = connection;
//Add chat to game
var chat:Chat = new Chat(chat_mc, m_Connection);
m_Connection.send("Map", "MapCenter");
m_Connection.addMessageHandler("Map", function(m:Message) {
str = m.getString(0);
traceString();
drawFromServer();
infoBox.Hide();
})
m_Connection.addMessageHandler("AttackAllowed", function(m:Message) {
gotoAndStop("error");
})
m_Connection.addMessageHandler("AttackFaild", function(m:Message, name:String){
trace("AttackFaild:" + name)
})
}
this function dynamically builds a map of tiles according to the information she already got from the server on the MapHandler message.
- Code: Select all
private function drawFromServer():void {
var newTile:Tile_Nu_gfx;
for (var i = 0; i < mapHight; ++i) {
for (var j = 0; j < mapWidth; ++j) {
newTile = new Tile_Nu_gfx("tile" + j + "x" + i, uint(j), uint(i), str.charAt(i * mapWidth + j).toString().charCodeAt(0) - 48);
newTile.x = (j*tileWidth);
newTile.y = (i*tileHight);
newTile.addEventListener(MouseEvent.MOUSE_OVER, OverTile);
newTile.addEventListener(MouseEvent.MOUSE_OUT, OutOfTile);
newTile.addEventListener(MouseEvent.CLICK, handleClick);
if (mapArr[i * j + j] != 3)//for debug
map_mc.addChild(newTile); // this is the problematic line!
}
}
}
the only other usage i could find of this map_mc component, is at one of the .fla frames actions
- Code: Select all
trace("Frame: " + currentLabel.toString());
import flash.display.Loader;
var imageLoader:Loader = new Loader();
var imageRequest = new URLRequest("E:/My Dropbox/Holyland.Project/GFX/MapCenter.png");
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadHandler);
imageLoader.load(imageRequest);
function imageLoadHandler(evt:Event) {
map_mc.addChild(imageLoader.content);
map_mc.setChildIndex(imageLoader.content,0);
}
Sorry if the code is a bit messy, we'll have to clean and re-organize it once the game's structure is complete
QiX
- QiX
- Posts: 34
- Joined: July 22nd, 2010, 4:41 pm
Re: Maybe one of you flash experts could help me understand it
Sounds to me like map_mc is a timeline object. The reason that its null can be that the mc it's in is not done initializing.
I assume that the timeline code does not error? If not try wrapping your code in a Event.ADDED_TO_STAGE event callback.
I assume that the timeline code does not error? If not try wrapping your code in a Event.ADDED_TO_STAGE event callback.
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 749
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Maybe one of you flash experts could help me understand it
what about if we already use this event?
- Code: Select all
function HolyLand() {
if (stage)
start();
else
addEventListener(Event.ADDED_TO_STAGE, start);
QiX
- QiX
- Posts: 34
- Joined: July 22nd, 2010, 4:41 pm
Re: Maybe one of you flash experts could help me understand it
Yep that looks about right. The only other thing I can think off is that the map_mc only exist in some of the frames of your container MC
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 749
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Maybe one of you flash experts could help me understand it
Do You have any idea how to solve it?
I've checked, and the method using this component (map_mc) is being called during the frames where the component is placed.
Thanks again.
I've checked, and the method using this component (map_mc) is being called during the frames where the component is placed.
Thanks again.
QiX
- QiX
- Posts: 34
- Joined: July 22nd, 2010, 4:41 pm
Re: Maybe one of you flash experts could help me understand it
Not unless you want to share the code files.
If so you can send them to me at chris at player.io
/Chris
If so you can send them to me at chris at player.io
/Chris
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 749
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Maybe one of you flash experts could help me understand it
Until my Buddy who designed it will had a chance checking it out, I was able to do a workaround by deleting the component from the frame and declaring it in the constructor.
this way I could add it to the stage at the time I choose.
it seems to be working ok now
thanks again for your help!
this way I could add it to the stage at the time I choose.
it seems to be working ok now
thanks again for your help!
QiX
- QiX
- Posts: 34
- Joined: July 22nd, 2010, 4:41 pm
9 posts
• Page 1 of 1