Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-29-2012, 01:00 PM   #1
flamer09
Registered User
 
Join Date: Feb 2009
Posts: 17
Default calling instances from class

stage(a instance called player)
|
|
v
inside another movieclip named mc i have a movieclip named enemy
|
|
v
i placed a class in enemy and want to call the instance "player".

i've tried MovieClip(parent).player but it give me an error "A term is undefined and has no properties."

is there anyways that i can call the instance "player" from movieclip enemy?

sorry for the poor english
flamer09 is offline   Reply With Quote
Old 05-29-2012, 03:05 PM   #2
arkitx
Senior Member
 
Join Date: Jan 2011
Posts: 703
Default

post a sample or your project.

__________________
Regards

arkitx
arkitx is offline   Reply With Quote
Old 05-29-2012, 03:35 PM   #3
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

Your description of the display hierarchy is quite confusing. Your stage is an instance called player? You put the enemy inside the player? Give the full display paths of the objects in question, such as:

main timeline -> player
main timeline -> mc -> enemy

Without a clear understanding of the hierarchy it's impossible to use the parent property effectively.

Also note that stage and root are different. The root is inside the stage. The main timeline in Flash is compiled as the root, so refer to your main timeline as root, not stage.

You can use this method to determine the exact display object path of any display object:

ActionScript Code:
function getDisplayPath(object:DisplayObject):String {     var a:Array = [];     while(object){         a.unshift(object.name || object.toString());         object = object.parent;     }     return a.join("."); }
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 06-01-2012, 08:20 AM   #4
flamer09
Registered User
 
Join Date: Feb 2009
Posts: 17
Default

sorry for the late reply. my hierarchy is as follows

main timeline -> player -> playerLevel -> playerLibrary -> me

i wanted to call player from me. is there anyway i can call?
flamer09 is offline   Reply With Quote
Old 06-01-2012, 09:01 AM   #5
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default

Calling parent from me will refer to the container holding me. so to access player you either have to step out 3 times . like parent.parent.parent .
or use it from root.
MovieClip(root).playerinstance
Sonny is offline   Reply With Quote
Old 06-01-2012, 02:04 PM   #6
flamer09
Registered User
 
Join Date: Feb 2009
Posts: 17
Default

ahh.it works!! thx!!
flamer09 is offline   Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:00 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.