|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Mar 2003
Location: Belgium
Posts: 17
|
No more ROOT in Actionscript 3? Then how to do thie following???
Hi,
I can't find how to do the following. On my main timeline I have 2 movieclips. mc1 and mc2 Now in mc1 there is nothing (empty at the moment) and in mc2 there is a button with a click event defined. The clickevent should just do a mc1.graphics.lineTo(100,100); But that seems to be a problem, since mc2 and mc1 are both added to the main stage, but they seem not to know anything about eachother. I thought that it would be enough just to call root.mc1.graphics.lineTo(100,100) from the button in mc2, but that seems not to work. Anyone know a good solution to be able to control movieclip1 from a button in movieclip2 if they are both movieclips on the main timeline? Regards, Bart |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jan 2008
Posts: 150
|
Lot's of things you can do. You can set up event listeners, you can put functions in the parent to deal with mc2's requests, or you can pass mc1 into mc2 as a variable.
And I think I'm forgetting one or more other ways you could do it... |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2008
Posts: 24
|
What about "parent.mc1"?
Be happy that root is gone, now you can start to write proper code
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Mar 2003
Location: Belgium
Posts: 17
|
I'm absolutely not SAD. In fact I'm very happy with AS3 since its very powerfull and finally looks like a OOP language.
I discovered that you can still access the root by doing MovieClip(root).movieclip1 I do wonder however if this would also work for a externally loaded .swf by the way. If I want to load a movie from an external .swf , then in most docs which I find they create a new movieclip, load the sxf content in it and add it as a child where it needs to be added. Isn't there a way to load an external .swf into an allready existing movieclip on the stage ? |
|
|
|
|
|
#5 |
|
trace("AKA: Biro Barna");
Join Date: Oct 2007
Location: RO.Timişoara
Posts: 1,403
|
^ of course there is a way:
PHP Code:
__________________
![]() | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro | WebLog: http://blog.wisebisoft.com/ | | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge | | Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/ | By perseverance the snail reached the ark. | |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Mar 2003
Location: Belgium
Posts: 17
|
Tnx,
1) Can I then replace the "this" keyword with the name of my allready existing movieclip ? 2) And does this remove the contents of that movieclip and replace it with the just loaded .swf content ? Or does it just ADD content to that movieclip but keep the content that was allready in the movieclip ? 3) If I don't need a dynamically created movieclip anymore, then how should I nicely clear it ? Just remove it as a child of its parent, or is it also better to destroy the object to free all its memory ? How to destroy it then ? Kind regards, Bart |
|
|
|
|
|
#7 | |
|
Mod
Join Date: Mar 2002
Location: press the picture...
Posts: 12,748
|
Quote:
If you are dealing with a movie extending Sprite or with both you will run into problems if you use either of them. If you know it is a Sprite or MovieClip only then use Sprite(root) or MovieClip(root). You can load and external into MovieClip you want.
__________________
![]() - The right of the People to create Flash movies shall not be infringed. - | www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti | Last edited by cancerinform; 02-28-2008 at 10:19 AM. |
|
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jun 2009
Posts: 2
|
I have had the same problem, but with a bit of a twist.
I'm using MovieClip(root) in a private function of a class file bit even though I can trace that MovieClip(root) is the main time line it gives me an error about referencing a null object. the class file is directly attached to the movie clip on the stage, I have 3 frame an intro with a button to send the user to the second frame where the movie clip is and all the game elements are dynamically added to the MC then in the class file the private function among other things checks if teh game has ended and if so sends the user to the third frame which has the game over text and a button that they can click to play another game (get sent back to the second frame) but as soon as the variable that checks for the end of the game reaches zero the if condition is meet in there it just has a line MovieClip(root),gotoAndStop("gameover"); which is the third frame, if I comment out this line there is no error message but of cause no functionality either to go to the third frame. Does any one know what may be happening here as this should work by all accounts. Big mystery for me and I would like to understand what I have done wrong here. |
|
|
|
|
|
#9 |
|
Mod
Join Date: Mar 2002
Location: press the picture...
Posts: 12,748
|
__________________
![]() - The right of the People to create Flash movies shall not be infringed. - | www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti | |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jun 2009
Posts: 2
|
Cheers for that, i found that the problem is being caused by my button, I'm still working on the button to see if I can find the problem.
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|