Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-06-2012, 05:55 PM   #1
Registered User
Join Date: Feb 2012
Posts: 3
Default calling a function from a loaded movie clip... with a wrinkle

This is my setup:

1) Main timeline (I will call "game.swf") loads another flash movie (I will call room.swf)

2) using a series of addChilds, a function in game.swf sets the draw order of all of the items in the scene. This includes the background room that was contained in room.swf, the main character, the custom mouse pointers and so on.

3) there is an array in room.swf that has a list (I will call "FGitemsArray") of all of the items that should be drawn in front of the main character - like for instance there is a plant in the room and when the main character walks across the room I want him to appear behind it, despite the fact that it was loaded in a separate movie - I was delighted to find out that I could call addChild on everything in FGitemsArray from game.swf and the draw order would just work.

4) I want some of the items in room.swf to be able to call functions on the main timeline when they are clicked on. If an items is not in FGitemsArray, it is added to the display list by virtue of the fact that it is contained in room.swf. So this line of code embedded in an object in room.swf that looks like this:
(root.loaderInfo.loader.root as Object).showArrayEnd();
works just fine.

5) however when I set an item to be a foreground item, adding it to the display list separate from the room it's in I get the classic:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
6) if the item is not set to be a foreground object then I can use the previously mentioned reference to root.loaderInfo.loader.root just fine. It took me a while to figure out that this was the problem.

7) I obviously can't remove (root.loaderInfo.loader.root as Object) from the foreground object in room.swf, as the movie won't compile cause it can't find showArrayEnd().

8) how do I fix this.
howdyzach is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 09:07 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.