[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Actionscript 3  Class Architecture

Posted on 2008-11-13
3
Medium Priority
?
243 Views
Last Modified: 2013-11-11
Hi,

I am writing an as3 program where i have a class called Main, which is the document class. Within this class i have created an Object of another class 'XYZ' .


What method should i adopt to access the movieclips etc on stage (which are children of Main class, since it is document class) from inside of XYZ class?

Also when i want to add something to the stage using addChild in XYZ class, how do i do it ?

0
Comment
Question by:young_buddha
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22957611
1)
You can access the movieClips on stage by simply using its instance name
"this" keyword in document class refers to the stage.

example:
// both will refer to the instnace of a movieClip on stage which has the instance name "myMovie"
this.myMovie;  
or  
myMovie;  

another approach is by using "getChildByName()" method

example:
this.getChildByName("myMovie");  // this will also return the reference to the movieclip with instance name "myMovie"

2)
you can simply add movieClip using :

this.addChild("<MovieClipInstance>");
or
addChild("<MovieClipInstance>");
0
 

Author Comment

by:young_buddha
ID: 22957755
Actually what i was asking is, that how do i do the same from an OBJECT OF CLASS 'XYZ', which i have created inside the Document class?

0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 22957769
from object of class "XYZ" you can access document class  using 'parent' properly,
just make sure XYZ class should expend "Sprite'' or "MovieClip"

sample code :

trace(MovieClip(this.parent));  //  this will return the reference of document class
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question