How do I assign a mouseclick event Listener to a simplebutton already nested in a movie clip when it's dropped on stage?

I'm trying to assign a mouseclick event listener to a simplebutton nested within a movie clip's later frames, starting at frame 2 and up. This card, however, is not added to my game until later, and when the player clicks on it/turns it over.
There are four files involved in this program:
#1 The main actionscript file, which corresponds to
#2 my dreamQuester .fla file.
#3 my artifactCard file movieClip's corresponding .as file,
#4 my combo1.as file corresponding to a an instance of a simpleButton named combo1 that is already
nested --and this instance is already named-- inside/as a child of said artifactCard movieclip.
What I've done so far isn't working:
In my main dreamQuester.as file, when a player clicks on an artifactCard, its MOUSE_DOWN event
listener takes them to this function (clickArtCard), where the trouble is at:
// player clicked on the artC card--which is a child of posArt1 on stage--to turn card over:
        function clickArtCard(a_event:MouseEvent) {
            var thisArtCard:artifactCard = (a_event.target as artifactCard);
            thisArtCard.gotoAndStop(unclickedArt1);  // go to frame number of artifact
                                // card where combo1 button is.
            thisArtCard.removeEventListener(MouseEvent.CLICK,clickArtCard);
            thisArtCard.buttonMode = false;
            trace("combo1.combo is:" + combo1.combo);
            trace("posArt1.artC.combo1 is:" + posArt1.artC.combo1);
            posArt1.artC.combo1.addEventListener(MouseEvent.MOUSE_DOWN, comboClickedWHO);
when the artC card--the static public instance of artifactCard--is clicked, it only gets to the
trace("posArt1.artC.combo1 is:" + posArt1.artC.combo1); which returns this error message:  
TypeError: Error #1010: A term is undefined and has no properties.
    at MethodInfo-61()
So do how would I declare a static public variable of this simpleButton at the start of my main .as
file to make it defined to get a mouseDown actionListener into my pre-existing-and-named-instance
combo1 simpleButton?
perhaps there is a way, while the debug movie program is running, to click on the simpleButton and see exactly
what it's parent heirarchy is, to see the name of all parents above the simpleButton incase they are
different then what I think?
(just in case, I was hoping to squeeze a zip file containing these files to be less than 9MB incase someone was willing to look at my files to see what I've done so far, but 9 megs is just too big! even though all graphics I've imported where turned into vector graphics with trace bitmap. I wish there was a way to check the file size of each symbol in Flash CS4, here...)
Thank you so much for any help!
~Ethan

Just use a
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent):void {
     //trace(event.keyCode);
     if(event.keyCode == ???){
          // play the sound
Where I show the "???" you would replace with the keyCode for the key you want pressed for that sound.  To determine the keyCode you can use the trace line that I have commented out.
Note that when testing in Flash you often need to disable the keyboard shortcuts in the Flash Player in order to be able to use alot of the keys.  You will find this option in the Control menu options in the player.

Similar Messages

  • How to changed old apple ID in AppStore? I've already creat new one's but when I go to the AppStore the old apple ID always appear. Hope you can answer my question. Thanks godbless

    How to changed old apple ID in AppStore? I've already creat new one's but when I go to the AppStore the old apple ID always appear. Hope you can answer my question. Thanks godbless

    No, your accounts will remain separate, any content that you download via either account will be tied to that account - so each account will only be able to authorise its own downloads on your computer's iTunes, redownload them, download updates to its apps, and make in-app purchases in its apps.
    Is there are particular reason why you've created a new account ? If it's due to, for example, no longer having access to your old email account then you can update the email address on an account by tapping on the id in Settings > iTunes & App Store and selecting 'view apple id' on the popup and logging into it, via the Store > View Account menu option on a computer's iTunes (click the Edit button to the right of your id at the top of your account's screen), or via http://appleid.apple.com . If you want to re-use the email address on the account that you've just created then you will need to change that first

  • Please Help !!!How to pass variable defined in Event Listener Method outside it.

    Hi, everybody
    I have 3-4 swf those i want to load one after another like a slideshow.What i  want to do is get the total frames of loaded swf and want to pass that value to Timer object's delay parameter.  i have converted total frames to milliseconds so i can use it in timer constructor. But i am not getting the value of that variable outside of my Event.COMPLETE listener method. Here is my code what i have done, Please have a look and guide me what i am missing.
    var fr = stage.frameRate;
    var m:MovieClip = new MovieClip();
    var ms;
    var swf:XML =
                       <swfs>
                                 <swf filename="1.swf"/>
                            <swf filename="2.swf"/>
                            <swf filename="3.swf"/>
                    </swfs>;
    import flash.display.*;
    import flash.net.URLRequest;
    function loadSwf(num)
       var ldr:Loader = new Loader();
        var url:String = swf.swf[num].attribute("filename");
        var urlReq:URLRequest = new URLRequest(url);
        ldr.load(urlReq);
       ldr.loaderInfo.addEventListener(Event.COMPLETE, onC);
    function onC(e:Event):void
       var m:MovieClip = e.target.content as MovieClip;
       ms = m.totalFrames/fr;
       ms = ms * 1000;
    var timer:Timer = new Timer(ms);
    timer.addEventListener(TimerEvent.TIMER, onT);
    function onT(e:TimerEvent)

    Hi Ned,
    Thanks for your reply. i want to call loadSwf method in timerEvent. My aim is to load next swf movie after playhead play all frames of loaded swf. I hope you are getting my point. My aim is to play a slide show of swfs with not equal interval but after completion of each swf's animation, those total frames may differ. Am i going right or if you can suggest me a  better way then please tell me.

  • How do I get my playlist from my computer to my iPhone, it doesn't move over when I sync.

    How do I get my playlist from my computer to my IPhone? Syncing doesn't seem to do it?

    If you're manually managing your content, make you're you've checked playlists to sync.

  • Any idea how I can get FCPX to accurately show the scale of a clip when it is dropped into a project that has smaller dimensions?

    Hi all,
    This is a niche problem but one that I want to figure out.
    I shot at 1920 x 1080 and want to edit at 960 x 720.  This will give me a video that is plenty big for web playback, but will allow me to do some "camera moves" (pans, zooms, etc) by selectively reframing the large file inside the smaller project.
    The problem is, FCPX resizes the larger footage to fill the smaller project when I drop it in the timeline, then tells me that the footage is scaled to 100% in the info window.  I know the source footage isn't really scaled to 100% (should be more like 50% +/-) even though FCPX tells me it is.
    In FCP 7 there were options to keep the larger footage at a true 100% which I could then resize to fit the smaller project.  Is there such a thing in FCPX?
    I just want to make sure I never zoom in past the true 100% scale of the source footage or the image will soften.
    Thanks,
    Matt

    Hi There,
    1 - You want to spend a little time with the manual ;-)
    2 - Select ANY clip in either Timeline or Even Browser, go to inspector and in the "Spatial Conform" tab, choose 'none' from the type field
    Hope this helps !

  • In iCal can't assign .ICS calendar event to non-"on my mac" calendars

    In apple mail, I click on the the .ICS file [sent by windows outlook user] and can see that it is added into iCal. Great, as expected.
    However, if I right click on this event, under "calendars" I can only assign it to either "home" or "work" i.e. those same calendars that show up under the "on my mac" section, top left of iCal - no other calendars show up
    When I select different events already in the calendar (and not added using .ICS files), I can see more calendars, namely those added from gmail
    e.g. [email protected]
            = vacation
            = work
            = training
          [email protected]
           = bookings
           = vacation
    these are the same ones which appear under the 'on my mac' section
    How can I assign this .ICS event to one of my gmail calendars?
    anyone know how to fix this?

    Sounds like a failed HD. Get another HD, install it, reinstall the OS, upgrade to Lion, and then restore the TM backup.

  • Intercept a mouseclick event with a background running application

    Ciao to everyone.
    My name is Alessandro and "i have a problem"...
    I want to count every click of my mouse with an application running in background.
    How can i intercept any mouseclick event, also those occurring out of the application?
    I work with Windows XP.
    Thanks and excuse me for my bad english.

    As far as we know when a Java swing application loses focus you can not handle the click being generated by the user.
    Have a look at the following source:
    http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
    We have developed routines for that kind of handling in C+ and set up java JNI in order to retrieve them, but they are low level routines that need to handle interruptions from the main board (not recomended for average users).
    Answer provided by http://www.consultoriajava.com

  • JTextArea problem: mouseClicked event irregular

    My application allows user to add several CalcArea objects (a subclass of JPanel) in a big JPanel. Highlight of ClassArea class is given below.
    Strangely, I find that once in a while, mouseClicked event is not fired. It is very critical for my user to select a particular CalcArea and modify/update the currently selected CalcArea. It is very much annoying to find that the mouseClicked event occurs irregularly. Please advise me how I can make sure mouseClicked event occurs when user clicks on the desired CalcArea. Thanks.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.math.*;
    import javax.swing.border.*;
    import java.awt.print.*;
    public class CalcArea extends JPanel implements MouseListener, FocusListener
       JTextArea ta;
       DrawPanel dp; //subclass of JPanel
       static int iCount=0;
       static int selectedMemberID=-1;
       int memberID;     //unique ID (0-based)
       //constructor
       public CalcArea(String strID....)
       }  //constructor ends
       public void mousePressed(MouseEvent e)
       } //method mousePressed ends
       public void mouseClicked(MouseEvent e)  //***Problem here
         selectedMemberID= memberID;
         System.out.print("mseClicked***");
       public void mouseReleased(MouseEvent e) {}
       public void mouseEntered(MouseEvent e) {}
       public void mouseExited(MouseEvent e) {}

    Is there any way to solve it? I don't really understand what you are trying to accomplish, but maybe somthing like the following will help:
    e.getComponent().getGraphics();
    e.getComponent().getParent().getGraphics();

  • How to stop a slideshow and show another movie clip at the end?

    Currently my slideshow is in a loop. At the end of last slideshow, I want to show another movie clip (End_mv) that's on another layer. How do I do that? My current scripts are below:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    //change scale on an image
    var fadeTween:Tween;
    //To slide in on X axis
    var slideXTween:Tween;
    //To slide in on Y axis
    var slideYTween:Tween;
    //To fade IN
    var alphaTween:Tween;
    //To get bigger on its X axis
    var scaleXTween:Tween;
    //To get bigger on its Y axis
    var scaleYTween:Tween;
    //var fadeTween:Tween;
    //description place holder
    var strDescrp:String;
    //source place holder
    var strSource:String;
    //x poistion
    var posX:Number;
    //y position
    var posY:Number;
    //degree rotation
    var degreeRot:Number;
    // delay between slides
    //const TIMER_DELAY:int = 5000;
    var TIMER_DELAY:int = 5000;
    // fade time between slides
    const FADE_TIME:int = 3;
    // reference to the current slider container
    var currentContainer:Sprite;
    // index of the current slide
    var intCurrentSlide:int = -1;
    // total slides
    var intSlideCount:int;
    // timer for switching slides
    var slideTimer:Timer;
    // slides holder
    var sprContainer1:Sprite;
    var sprContainer2:Sprite;
    // slides loader
    var slideLoader:Loader;
    // url to slideshow xml
    var strXMLPath:String = "lstHouse.xml";
    // slideshow xml loader
    var xmlLoader:URLLoader;
    // slideshow xml
    var xmlSlideshow:XML;
    var txtField:TextField = new TextField();
    var formatText:TextFormat = new TextFormat();
    //start of sound section is for sound
    var soundReq:URLRequest = new URLRequest("PaukenBrumfiel_AngelsOnHigh.mp3");
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    //end of sound section
    function onComplete(event:Event):void
        sound.play();
    function init():void
        // create new urlloader for xml file
        xmlLoader = new URLLoader();
        // add listener for complete event
        xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
        // load xml file
        xmlLoader.load(new URLRequest(strXMLPath));
        // create new timer with delay from constant
        slideTimer = new Timer(TIMER_DELAY);
        // add event listener for timer event
        slideTimer.addEventListener(TimerEvent.TIMER, switchSlide);
        // create 2 container sprite which will hold the slides and
        // add them to the masked movieclip
        sprContainer1 = new Sprite();
        sprContainer2 = new Sprite();   
        mcSlideHolder.addChild(sprContainer1);
        mcSlideHolder.addChild(sprContainer2);
        // keep a reference of the container which is currently
        // in the front
        currentContainer = sprContainer2;
    function onXMLLoadComplete(event:Event):void
        // create new xml with the received data
        xmlSlideshow = new XML(event.target.data);
        // get total slide count
        intSlideCount = xmlSlideshow..image.length();
        // switch the first slide without a delay
        switchSlide(null);
    function fadeSlideIn(e:Event):void {
        // add loaded slide from slide loader to the
        // current container
        currentContainer.addChild(slideLoader.content);
        // clear preloader text
        //mcInfo.lbl_loading.text = "";
        // fade the current container in and start the slide timer
        // when the tween is finished
        //Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:function() { slideTimer.start(); }});       
        //strSource = xmlSlideshow.image[intCurrentSlide].@src;
        fadeTween = new Tween(currentContainer, "alpha", Regular.easeInOut, 0, 1, 2, true)
        //scale = new Tween(currentContainer, "alpha", Regular.easeInOut, 0, 1, 2, true)
        slideTimer.start()
        onComplete:function();
    function switchSlide(e:Event):void
        // check, if the timer is running (needed for the
        // very first switch of the slide)
        if(slideTimer.running)
            slideTimer.stop();
        // check if we have any slides left and increment
        // current slide index
        if(intCurrentSlide + 1 < intSlideCount)
            intCurrentSlide++;
        // if not, start slideshow from beginning
        else
            intCurrentSlide = 0;
        // check which container is currently in the front and
        // assign currentContainer to the one that's in the back with
        // the old slide
        if(currentContainer == sprContainer2)
            currentContainer = sprContainer1;
        else
            currentContainer = sprContainer2;
        // hide the old slide
        currentContainer.alpha = 0;
        // bring the old slide to the front
        mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
        strDescrp = xmlSlideshow.image[intCurrentSlide].@desc;
        //strSource = xmlSlideshow.image[intCurrentSlide].@src;
        //txtField.border = true;
        //txtField.x = 0;
        //txtField.y = 600;
        txtField.width = 855;
        txtField.height = 200;   
        //txtField.background = true;
        //txtField.backgroundColor = 0xEE9A00;
        txtField.alpha = 20;
        txtField.text = strDescrp;
        formatText.align = TextFormatAlign.CENTER;
        //txtField.autoSize = TextFieldAutoSize.LEFT;
        formatText.color = 0x000;
        formatText.size = 30;
        txtField.x = 0;
        txtField.y = 550;
        posX = 0;
        posY = 0;
        degreeRot = 0;
        // create a new loader for the slide
        slideLoader = new Loader();
        // add event listener when slide is loaded
        slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
        // load the next slide
        slideLoader.load(new URLRequest(xmlSlideshow.image[intCurrentSlide].@src));   
        addChild(txtField);
        txtField.setTextFormat(formatText)
    // init slideshow
    init();

    I got this error:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
        at flash.display::DisplayObjectContainer/swapChildren()
        at University_Advancement_Holiday_Greeting2012_fla::MainTimeline/switchSlide()
        at flash.utils::Timer/_timerDispatch()
        at flash.utils::Timer/tick()
    And here's the code:
    // import tweener
    //import caurina.transitions.Tweener;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import flash.display.MovieClip;
    //change scale on an image
    var fadeTween:Tween;
    //To slide in on X axis
    var slideXTween:Tween;
    //To slide in on Y axis
    var slideYTween:Tween;
    //To fade IN
    var alphaTween:Tween;
    //To get bigger on its X axis
    var scaleXTween:Tween;
    //To get bigger on its Y axis
    var scaleYTween:Tween;
    //var fadeTween:Tween;
    //description place holder
    var strDescrp:String;
    //source place holder
    var strSource:String;
    //x poistion
    var posX:Number;
    //y position
    var posY:Number;
    //degree rotation
    var degreeRot:Number;
    // delay between slides
    //const TIMER_DELAY:int = 5000;
    var TIMER_DELAY:int = 5000;
    // fade time between slides
    const FADE_TIME:int = 3;
    // reference to the current slider container
    var currentContainer:Sprite;
    // index of the current slide
    var intCurrentSlide:int = -1;
    // total slides
    var intSlideCount:int;
    // timer for switching slides
    var slideTimer:Timer;
    // slides holder
    var sprContainer1:Sprite;
    var sprContainer2:Sprite;
    // slides loader
    var slideLoader:Loader;
    // url to slideshow xml
    var strXMLPath:String = "lstHouse.xml";
    // slideshow xml loader
    var xmlLoader:URLLoader;
    // slideshow xml
    var xmlSlideshow:XML;
    var txtField:TextField = new TextField();
    var formatText:TextFormat = new TextFormat();
    //var myEnding:MovieClip = stage.getChildByName('End_mc') as MovieClip;
    //start of sound section is for sound
    var soundReq:URLRequest = new URLRequest("PaukenBrumfiel_AngelsOnHigh.mp3");
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    //end of sound section
    function onComplete(event:Event):void
        sound.play();
    function init():void
        //reference my movie clip "End_mc" oon the stage and turn its visibility off
        MovieClip(getChildByName('End_mc')).visible = false;
        // create new urlloader for xml file
        xmlLoader = new URLLoader();
        // add listener for complete event
        xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
        // load xml file
        xmlLoader.load(new URLRequest(strXMLPath));
        // create new timer with delay from constant
        slideTimer = new Timer(TIMER_DELAY);
        // add event listener for timer event
        slideTimer.addEventListener(TimerEvent.TIMER, switchSlide);
        // create 2 container sprite which will hold the slides and
        // add them to the masked movieclip
        sprContainer1 = new Sprite();
        sprContainer2 = new Sprite();   
        mcSlideHolder.addChild(sprContainer1);
        mcSlideHolder.addChild(sprContainer2);
        // keep a reference of the container which is currently
        // in the front
        currentContainer = sprContainer2;
    //function onXMLLoadComplete(e:Event):void
    function onXMLLoadComplete(event:Event):void
        // create new xml with the received data
        xmlSlideshow = new XML(event.target.data);
        // get total slide count
        intSlideCount = xmlSlideshow..image.length();
        // switch the first slide without a delay
        switchSlide(null);
    function fadeSlideIn(e:Event):void {
        // add loaded slide from slide loader to the
        // current container
        currentContainer.addChild(slideLoader.content);
        // clear preloader text
        //mcInfo.lbl_loading.text = "";
        // fade the current container in and start the slide timer
        // when the tween is finished
        //Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:function() { slideTimer.start(); }});       
        //strSource = xmlSlideshow.image[intCurrentSlide].@src;
        fadeTween = new Tween(currentContainer, "alpha", Regular.easeInOut, 0, 1, 2, true)
        //scale = new Tween(currentContainer, "alpha", Regular.easeInOut, 0, 1, 2, true)
        slideTimer.start()
        onComplete:function();
    function switchSlide(e:Event):void
        // check, if the timer is running (needed for the
        // very first switch of the slide)
        if(slideTimer.running)
            slideTimer.stop();
        // ADDED: Check if using sprContainer2 and at the last slide
        //if ((currentContainer == sprContainer2) && (intCurrentSlide == intSlideCount))
        trace("Current Slide: " + intCurrentSlide);
        trace("SlideCount: " + intSlideCount);
        if ((currentContainer == sprContainer2) && ((intCurrentSlide + 1) == intSlideCount))
            // hide the slideshow (and other related elements, or remove them if desired)
            //mcSlideHolder.visible = false;
            // remove any clips directly inside slideshow (any timers/etc need to be stopped too)
             while (mcSlideHolder.numChildren > 0)
                mcSlideHolder.removeChildAt(0);
            // I do see a var named 'sound' playing so you might want to:
             //sound.stop();
             //sound = null;
            // etc any other slideshow-only elements to hide/remove..
            // play your movie
            MovieClip(getChildByName('End_mc')).visible = true;
            MovieClip(getChildByName('End_mc')).play();       
        // check if we have any slides left and increment
        // current slide index
        if(intCurrentSlide + 1 < intSlideCount)
            intCurrentSlide++;
        // if not, start slideshow from beginning
        else
            intCurrentSlide = 0;
        // check which container is currently in the front and
        // assign currentContainer to the one that's in the back with
        // the old slide
        if(currentContainer == sprContainer2)
            currentContainer = sprContainer1;
        else
            currentContainer = sprContainer2;
        // hide the old slide
        currentContainer.alpha = 0;
        // bring the old slide to the front
        mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
        strDescrp = xmlSlideshow.image[intCurrentSlide].@desc;
        //strSource = xmlSlideshow.image[intCurrentSlide].@src;
        //txtField.border = true;
        //txtField.x = 0;
        //txtField.y = 600;
        txtField.width = 855;
        txtField.height = 200;   
        //txtField.background = true;
        //txtField.backgroundColor = 0xEE9A00;
        txtField.alpha = 20;
        txtField.text = strDescrp;
        formatText.align = TextFormatAlign.CENTER;
        //txtField.autoSize = TextFieldAutoSize.LEFT;
        formatText.color = 0x000;
        formatText.size = 30;
        txtField.x = 0;
        txtField.y = 550;
        posX = 0;
        posY = 0;
        degreeRot = 0;
        // create a new loader for the slide
        slideLoader = new Loader();
        // add event listener when slide is loaded
        slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
        // add event listener for the progress
        //slideLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
        // load the next slide
        slideLoader.load(new URLRequest(xmlSlideshow.image[intCurrentSlide].@src));   
        addChild(txtField);
        txtField.setTextFormat(formatText)   
    // init slideshow
    init();

  • Remove Child and Event.SOUND_COMPLETE not working inside movie clip. What's the problem?

    I have a movie clip that is called to the stage. The user then clicks a button and music plays. As the music starts, another movie clip is called, a simulation of  an equilizer. There are several things that should happen:
    1) When the user closes the movie clip the music is supposed to stop playing and the equilizer movie clip is removed. What actually happens is the music stops playing but  the equilzer movie clip is not removed.
    2) When the music is finished playing the equilzer is supposed to be removed from the stage and the play button is reactivated. But none of that happens. When I click on the movie clip a second time equilizer is still there and the play button is not reactivated.
    Here's the code that calls the movie clip to the stage.
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtons);
    function goButtons(event:MouseEvent):void
        if (event.target == Song_bnt)
            SoundMixer.stopAll();
            addChild(myPlaySong);
            myPlaySong.x = 304;
            myPlaySong.y = 105;
            //event.stopImmediatePropagation();
    Here's the code in the movie clip:
    import flash.media.Sound;
    import flash.events.Event;
    stop();
    var playRayJaySong:RJSong;
    var playRayJaySongChannel:SoundChannel;
    var equilizer:Equilizer;
    equilizer = new Equilizer();
    playRayJaySong = new RJSong();
    //Plays music, inactivates buttons, and adds the equilizer to the stage.
    PlaySongRJClip.addEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
    function songPageButton(event:Event):void
        playRayJaySongChannel = playRayJaySong.play();
        PlaySongRJClip.visible = false;
        ClicktoPlaySong.visible = false;
        addChild(equilizer);
        equilizer.x = 269;
        equilizer.y = 246;
    //Removes the equilizer from the stage when the music is complete.
    PlaySongRJClip.addEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
        function rjSoundComplete(e:Event):void
        PlaySongRJClip.visible = true;
        ClicktoPlaySong.visible = true;
        removeChild(equilizer);
    //Removes the equilizer and event listeners from stage and calls dispatch event to close the movie clip.
    closeSong_bnt.addEventListener(MouseEvent.MOUSE_DOWN, CloseSong);
    function CloseSong(event:MouseEvent):void
        removeChild(equilizer);
        dispatchEvent(new Event("RemoveMSong"));
        PlaySongRJClip.removeEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
        PlaySongRJClip.removeEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
    //Removes the MovieClip from the stage when the user clicks on the close button inside the MovieClip.
    myPlaySong.addEventListener("RemoveMSong", RemoveSongClip);
    function RemoveSongClip(e:Event):void
        SoundMixer.stopAll();
        removeChild(myPlaySong);
    Any thoughts?

    I figured out the problem. Here's how I reorganized the code (all in one frame).
    //Code for Ray Jay song.
    var playRayJaySong:RJSong;
    var playRayJaySongChannel:SoundChannel;
    playRayJaySong = new RJSong();
    myPlaySong.equilizer_inst.visible = false;
    //Plays the song.
    myPlaySong.PlaySongRJClip.addEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
    function songPageButton(event:Event):void
        playRayJaySongChannel = playRayJaySong.play();
        playRayJaySongChannel.addEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
        myPlaySong.equilizer_inst.visible = true;
        myPlaySong.PlaySongRJClip.visible = false;
        myPlaySong.ClicktoPlaySong.visible = false;
    //Removes the MovieClip from the stage when the user clicks on the close button inside the MovieClip.
    myPlaySong.closeSong_bnt.addEventListener(MouseEvent.CLICK,RemoveSongClip);
    function RemoveSongClip(e:Event):void
        SoundMixer.stopAll();
        removeChild(myPlaySong);
        myPlaySong.equilizer_inst.visible = false;
        myPlaySong.PlaySongRJClip.visible = true;
        myPlaySong.ClicktoPlaySong.visible = true;
        playRayJaySongChannel.removeEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
    //Resets all of the movieclips to their orginal state.
    function rjSoundComplete(e:Event):void
        myPlaySong.equilizer_inst.visible = false;
        myPlaySong.PlaySongRJClip.visible = true;
        myPlaySong.ClicktoPlaySong.visible = true;
    Thanks all for your suggests and input.

  • How to obtain instance name of Movie Clip?

    Hello!
    Is there a way to get the instance name of a move clip once it's on the stage?  In my dress up game, I need to know which items are on the doll in order to keep them visible.  My drag and drop feature uses an array and currentTarget:
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace("It's on the doll!");
    It can successfully run this code.  However, instead of tracing "It's on the doll!", I'd like to turn the currentTarget into it's instance name, which should be "Doll.Drawers.Dress1" etc... and then store that name in an array.
    How would I do this?
    I've looked into e.target.name, but I keep getting errors...

    use the name property of clip (if that's the movieclip whose name you want):
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace(clip.name);  // but that won't be Doll.Drawers.Dress1.  it might be Dress1.

  • Using Events To Play Another Movie Clip

    Dear Readers:
    I have a set of buttons in my flash movie that, when a mouse
    cursor passes over it, another movie clip on the stage causes a
    layer with text to gradually appear from below. It pops up, so to
    speak, and eventually stops, displaying the text related to the
    button in full view.
    Passing over a different button causes the text layer to move
    downward, slowly disappear off the stage, then reappear in the same
    manner with text associated with that latest button. Its fairly
    simple and works fine, as long as the user waits patiently for the
    text layer to scroll down and back up before passing over another
    button. See code below.
    However, if the user decides to quickly pass over multiple
    buttons (before the text layer reaches the top), the event handler
    is coded such that if the mouseover event occurs BEFORE the text
    layer reaches the top, the text layer starts over at the bottom, so
    the transition is not smooth. Imagine the text layer just about to
    reach the top, when the mouseover event occurs, now the text layer
    starts over from the bottom. Very choppy.
    I'd like to grab the current frame of the text layer movie
    clip when the mouseover event occurs, and have the layer move back
    down from there, reach the bottom, then come back up, rather than
    starting from the bottom. Any help in coming would be great. Thanks
    in advance.

    yourI = setInterval(f,t) starts a loop. it repeatedly calls
    the function f() every t milliseconds until a clearInterval(yourI)
    is executed.
    the most common problem that occurs with setInterval() is
    executing it twice (or more) with no intervening clearInterval().
    when that happens all hell breaks loose and the swf will call the
    function much more rapidly than intended and can not be (easily)
    stopped no matter how many clearInterval() statements you try and
    execute.
    the easiest way to prevent that problem is to execute a
    clearInterval() just BEFORE all setInterval() statements. it
    doesn't hurt anything to (try and) clear and interval that doesn't
    exist and occasionally it'll stop the seemingly bizarre problems
    that occur with out-of-control intervals:
    clearInterval(yourI);
    yourI=setInterval(f,t);

  • How can I display a Movie clip from library on stage in AS3?

    Hi,
    I have a movie clip in my library and I would like to display it on the stage using AS3.
    do I have to define it as a variable?Do  I need to use this code:  addchild(movieclip);
    can I use the 'x' and 'y' to position it?
    What would the code look like?
    Ben.

    Great! it works  well ! thanks
    But I have another question, if I wanted to used the same movie clip but postion it at different x and y positions when a different btn is selected how could I do that?
    Would I have to make a copy of the movie clip and give it a different name?
    or is there an better way around it?
    Ben.

  • How to email a Movie Clip in Flash

    Hi everyone.
    I am creating a painting / drawing application in flash.
    I want to add a functionality, which allows the user to send his/her painting to his/her email address.
    How can this be done?
    Please note that the painting / drawing would be a movie clip
    Help on an urgent basis would be greatly appreciated
    Thanks

    Hi,
    I did something similar for AS2:basically there was a "designer" swf where one could interact to create a design,
    and a "viewing" swf that contained all the bits and pieces used (e.g. a blank t-shirt).
    The designer swf would send data (placement of objects, coordinates of strokes) to the server, and the server would amend the blank viewer swf by compiling the data object and adding it as another code block. The code of the viewing swf would handle constructing the desired image, by placing objects, adding strokes, etc.
    With the simple structure of AS2 code, php could do that.
    I sort of believe that something similar could be done for AS3 if the server is able to run java (the flex sdk programs). Addition: PHP by itself should be able to replace an embedded text file ... such as an xml description of the artwork

  • As 2.0 class objects- how to swap depths of a movie clip

    How do you bring an object to the top? if it's just a movie
    clip, I could do a swapdepths, but if it's a movieclip that's part
    of an AS 2.0 object, how do you swap depths of the whole object?
    I create 2 objects (same class) which each have a movieclip
    within them. The movie clip is created on a unique level with
    getNextHighestDepth().
    I have a button which tries to swapDepths of the 2 objects,
    but I can't get it to work. Can anyone help?
    here's the detail:
    1. create a symbol in the library called "someShape_mc" and
    put some shape in it - a circle, a square, whatever - this symbol
    is exported for action script, and has an AS 2.0 Class of
    "ClassObject" ( I also put a dynamic text field in the shape to
    display the current depth - it's called "depth_txt")
    2. create a button called "swap_btn" on the stage.
    Frame 1 has the following actionscript:
    var BottomObject:ClassObject = new ClassObject(this,100,150);
    var topObject:ClassObject = new ClassObject(this,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    // try it with the full path:
    _root.BottomObject.__LocalMovieClip.swapDepths(_root.topObject.__LocalMovieClip);
    // try it with with just the objects:
    BottomObject.__LocalMovieClip.swapDepths(topObject.__LocalMovieClip);
    // try it with the object as a movieclip
    BottomObject.swapDepths(topObject);
    trace("Did it Swap?");
    // try it with a method in the class....
    BottomObject.swapIt(topObject.__LocalMovieClip);
    BottomObject.swapIt(topObject);
    trace("nope... no swapping going on...");
    ================================
    here's the AS file: "ClassObject.as"
    class ClassObject extends MovieClip{
    var __LocalMovieClip;
    var __Depth;
    function ClassObject(passedIn_mc:MovieClip,x:Number,y:Number)
    __Depth = passedIn_mc.getNextHighestDepth();
    __LocalMovieClip =
    passedIn_mc.attachMovie("someShape_mc","__LocalMovieClip",__Depth);
    trace("made a shape at " + __Depth);
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    __LocalMovieClip.depth_txt.text = __Depth;
    public function swapIt(targetMc) {
    __LocalMovieClip.swapDepths(targetMc);
    __LocalMovieClip.depth_txt.text =
    __LocalMovieClip.getDepth(); // no difference.
    trace("Tried to swap from within the class...");
    ========================
    so- the goal is to bring the "bottom" Class object on top of
    the "top" object. The button tries various methods of swapping the
    depths of the movie clips - but there is not one that works. What
    am I missing?
    tia
    ferd

    Thank you for your response - and here I have included the
    code I reworked to show how it works, and doesn't work. you're
    right about not needing the extra containers, but this example is
    part of a bigger thing...
    I'm confused - it works ONLY if I attach the movie outside
    the class, even though the "attachment" occurs, I'm thinking, at
    the same scope level, that is, _root.holder_mc, in both examples.
    it seems that the advantage of having a class is defeated
    since I have to do the extra coding for each object that will be
    created. It's like the class can only have a reference to the
    movieclip outside itself, and not have a clip INSIDE that is fully
    functioning. am I right about this? Is there someplace good I can
    learn more about class objects and movieclip usage?
    also, my class object IS a movieclip, but " this.getDepth() "
    is meaningless inside the class object. hmmm...
    This one works..... attaching the movies at the root level
    (to a holder_mc)
    // Frame 1
    tmp1 =
    holder_mc.attachMovie("someShape_mc","tmp1",holder_mc.getNextHighestDepth());
    var BottomObject:ClassObject3 = new
    ClassObject3(tmp1,100,150);
    tmp2 =
    holder_mc.attachMovie("someShape_mc","tmp2",holder_mc.getNextHighestDepth());
    var topObject:ClassObject3 = new ClassObject3(tmp2,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    BottomObject.swapIt(topObject);
    trace("clicked button");
    // ClassObject3.as
    class ClassObject3 extends MovieClip{
    var __LocalMovieClip:MovieClip;
    function
    ClassObject3(passedInMovieClip:MovieClip,x:Number,y:Number) {
    trace(" this class object is at ["+this.getDepth()+"]");
    __LocalMovieClip = passedInMovieClip;
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    public function swapIt(targetMc:MovieClip):Void {
    trace("do the swap in the class");
    trace("===========================");
    trace("target type :" + typeof(targetMc));
    trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
    __LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);
    This one does NOT work..... attaching the movies within the
    class object...
    // Frame 1
    var BottomObject:ClassObject2 = new
    ClassObject2(holder_mc,100,150);
    var topObject:ClassObject2 = new
    ClassObject2(holder_mc,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    BottomObject.swapIt(topObject);
    trace("clicked button");
    // ClassObject2.as
    class ClassObject2 extends MovieClip{
    var __LocalMovieClip:MovieClip;
    function
    ClassObject2(passedInMovieClip:MovieClip,x:Number,y:Number) {
    __LocalMovieClip =
    passedInMovieClip.attachMovie("someShape_mc","stuff1",passedInMovieClip.getNextHighestDep th());
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    public function swapIt(targetMc:MovieClip):Void {
    trace("do the swap in the class");
    trace("===========================");
    trace("target type :" + typeof(targetMc));
    trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
    __LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);

Maybe you are looking for

  • File Name after donwload from BLOB

    dear experts, i'm a newbie in programming, just started this month.. i got problem where after i download from blob (oracle) the file name will be the same as the java class that i use to download it. How can i make the file name as it real file name

  • Header file

    I need to create a header file with the following specifications FILLER IS CREATED BY SPACING THROUGH THE FIELD FOR THE APPROPRIATE SIZE OF THAT FIELD. A FILLER SIZE OF ONE WOULD REQUIRE THE CURSOR BE ADVANCED BY ONE SPACE USING THE SPACE BAR. FIELD

  • Rollovers Only Work Sometimes

    In iWeb 2.0.3, I'm creating text boxes in which the text (a word or two each) is a link with the rollover enabled--the text is in black normally, and in red when the mouse rolls over it. The rollovers work perfectly in iWeb itself, but when published

  • Canopus 110 and the dreaded "Cannot connect to device"  msg

    I am using Premiere Elements 2.0 with the Canopus 110 to make copies of my HI-8 and Beta tapes, and getting increasingly frustrated with the way PE 2 drops my temporary file and forces me to start the whole copy over again from the beginning every ti

  • Buy on AppleTV, Sync, Manage, Now Gone

    Hi folks, Hopefully this is an easy one for most of you. Here's what I did: 1) Bought Lost: Season 2 on AppleTV. Enjoyed a few episodes with the better half. 2) It synced to a near full MBP. All is good. 3) I went on business travel with my MBP. 4) L