How come I can't convert the root variable to a MovieClip?

In one of my custom classes for my program I am trying to access the main timeline from within it. The following is code which I have used before, but for some reason does not seem to be working now. The full error I get (During runtime, not during compiling) is
[code]
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@28132041 to flash.display.MovieClip.
    at ButtonGame/onAddedToStage()
    at flash.display::DisplayObjectContainer/addChild()
    at flash.display::Stage/addChild()
    at RECOVER_CoinGame_fla::MainTimeline/frame2()
[/code]
And my code is:
[code]
package  {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.events.MouseEvent;
    public class ButtonGame extends MovieClip
    {        private var _root:Object;
        private var buttonSound1:Sound;       
        public function ButtonGame(btnX:int, btnY:int, btnWidth:int, btnHeight:int, btnString:String)
            addEventListener(MouseEvent.CLICK, clickHandler);
            addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        function onAddedToStage(e:Event):void
            _root = MovieClip(root); //Code the error is referencing to.
            buttonSound1 = _root._resource.CoinSound;
            removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        private function clickHandler(e:MouseEvent):void
            buttonSound1.play();
[/code]
And this same exact code worked in a different class, but for some reason it doesn't seem to work for this.
Please help i've been stuck on this for about an hour, trying many different things and searching the internet.
-Thanks

as long as you're using the added_to_stage event, that's not the problem.
do you see any trace output when using:
package  {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.events.MouseEvent;
    public class ButtonGame extends MovieClip
    {        private var _root:Object;
        private var buttonSound1:Sound;       
        public function ButtonGame(btnX:int, btnY:int, btnWidth:int, btnHeight:int, btnString:String)
            addEventListener(MouseEvent.CLICK, clickHandler);
            addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        function onAddedToStage(e:Event):void
trace(this);
trace(root);
            _root = MovieClip(root); //Code the error is referencing to.
            buttonSound1 = _root._resource.CoinSound;
            removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        private function clickHandler(e:MouseEvent):void
            buttonSound1.play();

Similar Messages

  • How come I can't use the back gesture in certain apps with my magic mouse on certain applications in Lion OS?

    How come I can't use the back gesture with my magic mouse on certain applications in Lion? I figured out that in Safari i have to use a 1 finger swipe to go back a page instead of 2 fingers like i used to do in Snow Leopard. But apps like iTunes and iPhoto and i can't do that. Any ideas? is there a setting im missing to make this work? It works in Safari but not any other applications, so im assuming theres no setting for this. Just want to know if this is just a bug that will be fixed in the next update or if its something I can fix now. Any help would be appreciated because its kind of annoying. Other than this minor issue I love Lion. Full screen apps are unbelievable.

    Hi.
    I managed to compile open-vm-tools and the kernel module against 3.14.5 kernel.  Here is the tarball with the all the files.
    I still have an issue : With vmware-player 6.0.2, I can't acces my shared folder :
    root@P146S011b ~ # lsmod | grep hgfs
    vmhgfs 41622 0
    vmw_vmci 47960 2 vmw_vsock_vmci_transport,vmhgfs
    root@P146S011b ~ # vmware-hgfsclient
    R
    D
    C
    root@P146S011b ~ # mount -t vmhgfs .host:/R /mnt
    Could not add entry to mtab, continuing
    root@P146S011b ~ # tail -1 /etc/mtab
    .host:/R /mnt vmhgfs rw,relatime 0 0
    root@P146S011b ~ # cd /mnt
    cd:cd:6: not a directory: /mnt
    1 root@P146S011b ~ #
    Forgot to add an install file with a depmod -a inside. You will have to run it by yourself

  • HT2404 I just clicked on Software Updates; BUT nothing shows what's happening? How come I can't see the updates & time it will take?

    Help!  I just got this Lion, and SO many changes & not necessarily for the better !
    I went to the Apple icon, but  "Software Updates" did not show ... though I had deferred installing some updates ...
    Finally it showed up, I clicked on it, saw the updates to do - BUT when I clicked on install - the "box" that usually shows the updates & how long to install - just disappeared! I can't get to it to see what's next. (I have to leave soon & will turn off the mac)
    What's happening? How come I can't see the updates as they are installed, & how much time it will take?
    How do I know IF they have been installed?  Is this the "new Normal" for Lion? Or is there a glitch in my mac somewhere?
    How about updates you download from Apple (not bought) - they go to Downloads on the Sideboard, but are they installed automatically, & put where they belong too? Is there no more restart, etc.?
    - I just went to Systems Preference, to see the "Installed Software" - shows they were ... but don't I have to restart anymore? Are all updates now automatically placed where they belong?
    Thanks to any who can help
    PS One other question - just checked my "profile" & it has my email addy that's 4 years old... how do I change That?

    software update not working
    https://discussions.apple.com/thread/3967755?start=0&tstart=0

  • How come i can't open the sim tray even if i use the small pin?

    how come i can't open the sim tray even if i use the small pin?

    Press firmly and push either the sim eject tool or a small paperclip straight in until the tray pops out.
    If that doesn't work make an appointment at an Apple store.

  • How come I can print off the Apple support page but not of my note book i n documents.

    How come I can print off the Apple support page but not off of note pad in my documents.

    No. It is not free unless the phone was originally purchased less than 90 days ago or you have an active AppleCare agreement.
    Where did you get the phone? This is almost always a symptom of a phone that was hacked or jailbroken to unlock it.

  • HT2534 How come I can't avail the "none" option after following instructions in review payment info?

    How come I can't avail the "none" option after following instructions in review payment info?

    If you are doing this on the iPad, try accessing your account in the app store. Tap the featured tab and you can access your ID in the lower left corner.
    If that doesn't work, perhaps you can be a bit more specific in what you have tried already.

  • How come I can not see the volume bar on my music

    I do not always see the volume bar on my iPhone music, how can I get the volume bar to display on the bottom of the music screen?

    tap on the screen?

  • How come I can't see the CNN's comment box? Now I can't comment! It works on others MacBook Pro's Safari, but not on mine.

    The Comment box vanished!. There is usually a box where you can type your comment right under where it says "Add New Comment".  I have Mac OS X Lion 10.7.4, Safari 6.0. I have a CNN account and can also log into it through Facebook and it still does not work. However, Whenever I log into my sister's laptop which is the same as mine, it works over there. So the issue is definitely on my Safari or somewhere else in my computer.
    I will show you two pictures giving an example on how the comment section on CNN is supposed to be working.
    PIC #1 - On this first picture, in the part where it says "Add New Comment", right under it theres supposed to be a box where i type inside my comment. But as you will see there will not be a box
    There is supposed to be a comment box between "Add New Comment" and those tabs where it says CNN DISQUS FacebookCONNECT TWITTER
    PIC # 2 - On this second picture, I will print screen the same page and try to reply to that first top comment on PIC #1. And doing it that way there is also no comment box. Again I should say that yes I do have an account on CNN and I am logged in. On CNN.com, if you are not logged in either through Facebook or CNN itself, the reply button would not even appear.
    As you can see, Right under where it says "Replying to geoplato"(whoever that is) there should be a box as well. And I know its my computer or my browser because my sister that lives with me, she has a MacbookPro which is what I use, and it works fine on hers. So I know its not CNN, Its my computer or browser.
    I hope with these new pictures, someone will be able to help me.
    Thank you all again who spends your time going through this. I really appreciate it.
    Francisco Neto.

    software update not working
    https://discussions.apple.com/thread/3967755?start=0&tstart=0

  • How come I can not change the initialization parameter

    show parameters audit_trail
    NAME TYPE VALUE
    audit_trail string NONE
    alter system set audit_trail = true
    ERROR at line 1:
    ORA-02095: specified initialization parameter cannot be modified
    I am using windows XP professional, Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    sqlplus sheet
    How to change the parameter like this?
    Edited by: user8117130 on May 4, 2009 9:23 AM

    user8117130 wrote:
    show parameters audit_trail
    NAME TYPE VALUE
    audit_trail string NONE
    alter system set audit_trail = true
    ERROR at line 1:
    ORA-02095: specified initialization parameter cannot be modified
    I am using windows XP professional, Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    sqlplus sheet
    How to change the parameter like this?
    Edited by: user8117130 on May 4, 2009 9:23 AMHi,
    This is a static parameter which means you can't change it when the db is running. If you are using an spfile, you need to change the query as ,
    alter system set audit_trail=true scope=spfileAnd then give a bounce to your db. If you are usnig a parameter file, than change in that and restart.
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch112.htm#REFRN10006
    HTH
    Aman....

  • How come I can't view the shared files on my PC anymore?

    I used to be able to view and drag all the shared items on my PC, but suddenly I cant do it anymore? What's wrong
    Can someone help?
    PS. also the NETWORK button disappeared from the upper left hand side of Finder window( that's my bad, I accidently deleted it) How can I get it back??
    Thanks in advance

    PS. also the NETWORK button disappeared from the
    upper left hand side of Finder window( that's my bad,
    I accidently deleted it) How can I get it back??
    Choose Finder > Preferences > Sidebar and click the checkbox for Network.

  • How come I can't access the app store on my iPod touch? There is no icon and I can't get to it through the iTunes icon. My iPod does have the latest software.

    See question above.

    On my iPod touch I don't have a spotlight search icon or option available. Also under my settings and general there is no "restriction" options or settings. I reset the iPod several times and that doesn't work.
    The thing is the music that is on my iPod is not all in my iTunes library so I can never sync automatically. Also if i restore to factory settings then it will erase what i have on my iPod and not in my library. I always manually add songs. When I plug in my iPod and i go under Summary...the only other tabs are music, tv shows, photos and info. There is no Apps tab. When i plug in my iPhone i do get the apps tab.
    I got my iTouch awhile ago....is it possible that this is why i can't get apps?? I got the iTouch back in 2008.
    Ughhh this is so frustrating. I just want to get this one app on my iPod Touch. Please help!!

  • How come I can't see the sound wave in the tracks?

    I just got an iMac, and am brand new to this, but I'm stuck here. The tracks are rectangular blocks of sound and I can't get them so they will be sound waves. I feel like I've clicked on every possible option. Any help?

    remy trahant wrote:
    The tracks
    regions (tracks contain regions)
    are rectangular blocks of sound
    MIDI loops (green) are not sounds, so there is no waveform, they are merely instructions for a synth. audio loops (blue) will show the waveform.
    and I can't get them so they will be sound waves.
    if you option drag a MIDI loop from the browser into the timeline, it's pre-rendered audio sample will be used instead and you will see a sound wave.

  • How come I can't lengthen the duration of PDF's in my storyline?

    I need to show a PDF at the bottom of my storline for approximately 1 minute. Final Cut X does not seem to allow me to change the duration of the PDF when imported as a connected clip or in it's own storyline. It only allows me to show for approximately 2 seconds. I have tried changing the duration of the clip in every way that I know how (dragging the edges, changing the settings of still images in preferences, etc.). Even when I apply the "change duration" shortcut (D ^) nothing happens. Any help is much appreciated!

    I tried and got the same results you report.
    The only way I was able to extend a pdf past 1 second was the following (admittedly rather awkward) workaround: control-click the pdf in the browser, open in Timeline, Retime. By "slowing down" to 10% I was able to then add it to a project and extend its duration.
    An easier way is probably to open the pdf in Preview, save as PNG and use that.

  • How come i can't hear the voice i add to pictures of my movie?

    I hear the firsts i made, i hear the movie parts, but the last i add only appears(the little purple screen). I hear them if i separate it from the pictures. Sorry for my english!

    I tried and got the same results you report.
    The only way I was able to extend a pdf past 1 second was the following (admittedly rather awkward) workaround: control-click the pdf in the browser, open in Timeline, Retime. By "slowing down" to 10% I was able to then add it to a project and extend its duration.
    An easier way is probably to open the pdf in Preview, save as PNG and use that.

  • How come I can't add a song to my playlists in itunes match? Is it me or itunes match? It keeps on coming up with a message " iCloud playlists can only contain songs from your iCloud music library. If you continue, the playlist will be removed from iCloud

    How come I can't add a song to my playlists in itunes match? Is it me or itunes match? It keeps on coming up with a message " iCloud playlists can only contain songs from your iCloud music library. If you continue, the playlist will be removed from iCloud and will only be available on this computer"?
    You must surely be able to add and subtract songs on specific playlist?

    I fixed this issue (with help from tech support) and it involved several things.
    After adding a song to iTunes, right-click on the song in iTunes and select "Update iTunes Match."
    OR go to the iTunes menu-->Store-->Update iTunes Match.
    Maybe that's the reason, it just hadn't updated to the cloud.
    OR maybe it's not a high-enough bitrate file.   This happens to me because most of my tunes are home-recorded.
    Sometimes converting to .mp3 or Create AAC version might work. (You do this with a right-click in iTunes, and then you will want to remove the original file from iTunes.)
    There is an iTunes Preferences setting, under General Preferences called Import Settings.  Try setting it to AAC Encoder and iTunes Plus.   That (I think) causes imports to be slightly better quality.
    Good luck!  The tech support person at Apple is requesting that a knowlege-base article be written about this.

Maybe you are looking for

  • How to use airplay with wifi dongle?

    My mac's wifi adapter was broken, so I bought a wifi dongle - ASUS USB-N10. It wasn't work until I installed the driver: http://www.wireless-driver.com/realtek-rtl8192su-adapter-macos-drivers-ver1082/ And however it seems to be a wifi assistant to he

  • Windows 8 and extensions

    I just purchased a new computer with windows 8 and am trying to install Russel Browns watermark extension in CS5 Extended. The extension manager wont let me install it even as administrator nor does the manual instalation work. Any suggestions?

  • Script:  When insert USB, run App.

    Here's the deal: When I plug in a USB drive, and it pops up on the desktop, I want it to automatically run a little application thats in it. This application would be some text document or something that would open up like a notice. I can do that par

  • ITunes Radio on Windows 8

    I tried to play iTunes Radio on my Windows 8 PC, and it keeps telling me there are no apps compatible to play it on my computer. How do I fix this, if it's even possible?

  • Can't open PDF on iPhone - blank grey screen appears

    Hi. I have downloaded the latest reader on my new iPhone 6. I cannot view PDF douments. If I try to open a file, Safari opens to a blank grey screen. I can see the "open in" prompt but cannot click on it. Any suggestions? Thanks.