How do you run loop functions on specific frames of nested Movieclips?

I'm still pretty new to AS3 and I've run into a problem that I never had with AS2.  I have a project where the 1st frame of the main timeline is the loading screen and the second frame has buttons and a title bar that I want to be on every "page" of my project.  There are 7 buttons that take the user between 7 different "pages", which consist of 7 frames of a movieclip I have filling the content area on frame 2 of my main timeline.  I'll call this movieclip "pages_mc".
The problem is that frame 6 of the pages_mc movieclip has the following code:
var moving = 0;
var xmoved;
var xbegin = pano_cont.pano_image.x;
parts_mc.addEventListener(Event.ENTER_FRAME, moveImage); // constantly moves the image 1 pixel left or right depending on the button pressed
btn_left.addEventListener(MouseEvent.MOUSE_DOWN, moveLeft); //changes the variable "moving" to 2 on mouse down
btn_right.addEventListener(MouseEvent.MOUSE_DOWN, moveRight); //changes the variable "moving" to 1 on mouse down
btn_left.addEventListener(MouseEvent.MOUSE_UP, stopMoveLeft); //changes the variable "moving" to 0 on mouse up
btn_right.addEventListener(MouseEvent.MOUSE_UP, stopMoveRight); //changes the variable "moving" to 0 on mouse up
function moveImage(e.Event):void{
xmoved = xbegin - pano_cont.pano_image.x;
    if(moving == 1)
        pano_cont.pano_image.x -= 1;
    if(moving == 2)
        pano_cont.pano_image.x += 1;
    if(xmoved < -(pano_cont.pano_image.width/2)+180)
        pano_cont.pano_image.x = -2538;
    if(xmoved > (pano_cont.pano_image.width/2)- 180)
        pano_cont.pano_image.x = -2178;
function moveRight (e:MouseEvent):void
    btn_right.gotoAndStop("down");
    moving = 1;
function moveLeft (e:MouseEvent):void
    btn_left.gotoAndStop("down");
    moving = 2;
function stopMoveLeft (e:MouseEvent):void
    moving = 0;
    btn_left.gotoAndStop("active");
function stopMoveRight (e:MouseEvent):void
    moving = 0;
    btn_right.gotoAndStop("active");
This is all just some code to allow users to move a panaromic image around on the screen.  But when I navigate to a different page from of my pages_mc movieclip I get the following output message:
TypeError: Error #1099: Cannot access a property or method of a null object reference.
     at SampleProject_fla::Content_MC_1/moveImage()
I'm thinking this is happening because the "parts_mc" movieclip I referenced for the ENTER_FRAME event listener no longer exists (unless you go back to frame 6 of pages_mc).  I'm not sure how to remove this event listener when the user moves to another frame of pages_mc.
Any help would be greatly appreciated.

kglad wrote:
what's parts_mc.parts_mc???
Not sure where you see that.  I see pages_mc.parts_mc which is just because the parts_mc movieclip is nested on the 6th frame of the pages_mc movieclip.
At any rate, I was able to get it working by moving all the code onto frame 2 of the main timline and declaring all of my vairables on frame 1 of the main timeline.  I then added an ENTER_FRAME event listener onto one of my movieclip buttons (main_btn) on the main timeline and had it check what frame the pages_mc movieclip was on.  If it was frame 6, I then executed the moveImage function and had it remove the event listener from the main_btn movieclip if the frame changed away from frame 6.
Seems to be working so far.
Here's the code:
Frame 1
/* Declaring variables. */
var pagenumber:Number;
var moving:Number = 0;
var firstTime:Number = 0;
var xmoved:Number;
var xbegin:Number;
Frame 2
pages_mc.addEventListener(Event.ENTER_FRAME, pageNum);
pages_mc.addEventListener(Event.ENTER_FRAME, BtnSelParts);
/* Keeps track of current page. */
function pageNum(e:Event):void
    pagenumber = pages_mc.currentFrame;
    title_bar.gotoAndStop(pages_mc.currentFrame);
function BtnSelParts(e:Event):void
    if(pagenumber == 6)
        btn_parts.gotoAndStop("current");
        if(firstTime == 0)
            btn_main.addEventListener(Event.ENTER_FRAME, moveImage); //moves the panorama image left or right
    else
        if(btn_parts.currentFrame == 32)
            btn_parts.gotoAndStop(1);
function moveImage(e:Event):void
    if(pagenumber==6)
        if(firstTime == 0)
            pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_OVER, overLeft); //animates left arrow button on rollover
            pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_OVER, overRight); //animates right arrow button on rollover
            pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_DOWN, moveLeft); //changes the variable "moving" to 2 on mouse down
            pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_DOWN, moveRight); //changes the variable "moving" to 1 on mouse down
            pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_UP, stopMoveLeft); //changes the variable "moving" to 0 on mouse up
            pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_UP, stopMoveRight); //changes the variable "moving" to 0 on mouse up
            pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_OUT, rollOutLeft); //animates left arrow button on rollout
            pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_OUT, rollOutRight); //animates right arrow button on rollout
            xbegin = pages_mc.parts_mc.pano_image.x;
            firstTime = 1;
        xmoved = xbegin - pages_mc.parts_mc.pano_image.x;
        if(moving == 1)
            pages_mc.parts_mc.pano_image.x -= 1;
        if(moving == 2)
            pages_mc.parts_mc.pano_image.x += 1;
        if(xmoved < -(pages_mc.parts_mc.pano_image.width/2)+180)
            pages_mc.parts_mc.pano_image.x = -2538;
        if(xmoved > (pages_mc.parts_mc.pano_image.width/2)- 180)
            pages_mc.parts_mc.pano_image.x = -2178;
        if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 1)
            pages_mc.btn_sel.gotoAndStop(1);
        if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 2)
            pages_mc.btn_sel.gotoAndStop(2);
        if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 3)
            pages_mc.btn_sel.gotoAndStop(3);
    else
        btn_main.removeEventListener(Event.ENTER_FRAME, moveImage);
        firstTime = 0;
} // controlls the panaromas
Let me know if you see any problems with this.
Thanks again.

Similar Messages

  • How would you describe the function of 'Camera roll'?

    How would you describe the function of 'Camera roll'?

    ITs the folder that stores pictures taken with the camera or downloaded from the web.   Or stored from Apps running on the iPad.
    Basically any picture or image created on the iPad will reside in there.

  • Is it possible to run host command from SAP environment? How do you run?

    Hi
    Is it possible to run host command from SAP environment? How do you run?
    Thank You

    Hello Subhash
    You will more details in the following thread:
    Re: How to define command for SXPG_COMMAND_EXECUTE
    Regards
      Uwe

  • When curser is on hyper link the url will diplay on the bottom of the screen in the background.(where done is located when site is loaded) How do you control this function?

    When curser is on hyper link the URL will display on the bottom of the screen in the background.(where done is located when site is loaded) How do you control this function?

    Do you want to control that via code on a web page to prevent visitors from seeing the link or do you ask as a Firefox user?<br />
    Tools > Options > Content : JavaScript > Advanced > Allow Scripts to:
    [ ] "Hide the status bar"
    [ ] "Change the status bar text"
    The Status Bar will be gone in Firefox 4.0 and is replaced by the (View > Toolbars) Add-on bar that extensions can use.

  • How do you run apps on creative cloud? I can't seem to run them or see them on my desktop

    How do you run apps on creative cloud? I can't seem to run them or see them on my desktop

    Hi JasonLuong,
    You will have to go to www.creative.adobe.com and login with your Adobe Id on which you have purchased the subscription.
    You can go to the download center and then start downloading all the cc apps available. It will first download and install the Creative cloud desktop tool in your computer. This creative cloud desktop will show you the option to download all the CC programs, the updates, etc.
    Thanks
    Kapil Rupani

  • How do you run Adobe Reader with New Lions

    How do you run Adobe Reader with New Lions?

    Lion has Preview, you may not need Adobe Reader.
    Preview Help
    View your images and PDF documents, touch them up, annotate them, and share your comments.
    Regards,
    Colin R.

  • How do you run a Wagetype G/L report in SAP

    Hi SAP experts
    In SAP system,How do you run a Wagetype G/L report?
    regards
    Krishna

    Aarti
    Thanks for your answers,this was the report I was  looking for .
    Full points awarded to you .we can also use this transaction code directly
    PC00_M99_DKON
    regards
    krishna

  • How do you run a full virus scan

    How do you run a full virus scan on the Imac

    Take a look at this article:
    http://en.wikipedia.org/wiki/Phishing
    Running a virus scan would not help at all - someone got your email address and is now hoping you're dumb enough to use the links they provided and give them information so they can use your credit card or checking acount number, password, etc.
    I would change my user name and password immediately (if not sooner!!) - make it difficult to guess. Do it at least with the bank involved; however, to be safe, it wouldn't hurt doing it with others as well.

  • HT5246 How do you run the Flashback malware removal tool?

    How do you run the Flashback malware removal tool?
    Thanks

    I am away from my computer and it is somewhat awkward to reply on an iPad.
    > I had already done what softwater instructed. I've read that it deletes itself on other threads, but it's still in my Finder as a Device. That's what confused me, because it doesn't appear to have deleted itself.
    Sorry, I wasn't clear. That is not the tool. It is the .dmg image mounted to your desktop. Next to the name you will see a small eject icon. Click on it or highlight it and choose "Eject" from the appropriate Finder menu. Once that happens you can drag the .dmg file to the trash as it will not delete itself.
    > I only recently upgraded to Snow Leopard and then Lion, in quick succession. My understanding is that there were (are) variants that would have infected my computer prior to my upgrading my OS to Lion. Before the upgrade, they were Adobe, but afterward they were Java. Could it be that be that the pop-ups were/are some other variant?
    Difficult to say for certain. Apple says it deletes all the common variants but does not specify which and I haven't seen the results of any testing done to verify that it finds and deletes those. The only dialogs that appeared with the initial variants were for FlashPlayer. They are depicted in the descriptions for Flashback-A on F-Secures site if you want to take a look. There have been none that I am aware of for Java, so that is probably either a web page or application that needs Java to run giving you that alert.
    > If the Flashback malware removal tool didn't find anything and my Software Update is current, does that mean the vulnerability has been fixed? At least for now? I understand that I Software Update will prompt downloads in the future if and when it needs to be patched again.
    The vulnerability is in Java, nowhere else, so if you don't have it installed there was nothing to fix.
    If you download Java in the future it will be the latest version Apple has available at the time, which hopefully will not be subject to exploitation, yet...

  • How do you start music on the 8th frame in iMovie on iPad

    how do you start music on the 8th frame on a ipad with imovie

    Add a song to the start, trim it to 10 frames or what you want,
    THen turn the volume to zero.
    THen next track then starts where the silent track ended.
    Terrible workaround, but it works.

  • How do you run Windows on a Mac?

    I have had a Dual Core MacBook Pro since last July, but I have never run Windows on it. Could someone here please explain to me how I can run Windows on my Mac, how to switch between Windows and Mac OSX, and if Windows Vista is able to be run on a Mac. Or, at least point me in an article already posted on this subject. Thank you!
    MacBook Pro   Mac OS X (10.4.8)   17" Screen, 2.16 GHz Processor, 1 GB RAM, 120 GB Hard Drive

    Please search the discussions before posting. You'll find hundreds of threads detailing how to run Windows on a Mac and could have answered your own question. Or better yet, just search Google.
    http://www.apple.com/macosx/bootcamp/

  • How do you run the optimizer with fixed orders?

    Hi experts,
    If the planner wishes to prioritize orders based on the customer demand, orders should be set as fixed.
    How do I run the optimizer when using fixed orders??
    Regards,
    Analía Nahmías

    Hi Analia,
    Will you please elaborate more ?
    It looks you are running SNP optimizer and want to use also make use of order prioirty functionlity.
    You may be knowing already the contents below :
    We know that Demand Prioritization functionlity is handled differently in SNP CTM and in SNP Optimizer.
    In SNP CTM, Demand can be sorted by different sort criteria.
    Whereas in SNP-Optimizer, Demand can be aggregated for three demand classes or by customer locations.
    We set prioirties on the SNP Optimizer profile Maintenance for demand classes ,
    1. Sales orders
    2. The Corrected demand forecast
    3.The demand forecast
    Apart from this, we can set flag for priority of location products
    The optimizer considers the priority of location products in combination with the priority of priority classes of the demand. To simplify this combination, we  must group the priorities of the location products into three classes.
    Within every priority class as above, the APO system uses all available cost information to determine the final solution
    With the above way, planner does not have to fix an order.
    regards
    Datta

  • How do you run another Java file from a master Java file?

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!One doesn't "run a Java file", and there's no conventional definition of "master Java file". If you want to call the main() method of another class, just make sure the class is in your classpath and call the method. If you want to start up a separate JVM with that class as a process, use Runtime.exec() or similar method.
    ~

  • How do you run a .sh file without errors?

    Hi. For any of you who are familiar with the game Minecraft, I'm trying to start making my own mods using Minecraft Forge Source. However, in the installation instructions, it says I have to run the install.sh file. But whenever I run it in Terminal, here's all that comes out in the Terminal window:
    *******-MacBook-Pro:~ *******$ /Users/*******/Downloads/forge/install.sh ; exit;python: can't open file 'install.py': [Errno 2] No such file or directory
    logout
    [Process completed]
    Could somebody tell me how to properly run the .sh file without errors? Any help that anyone gives will be appreciated. Thanks.

    You can try Crossover.
    It isn't free, but it lets you run most common windows apps without having to buy windows. (it only works on intel macs).
    Good luck!

  • How do you run a Windows PC based program on a MacPro

    Can someone advise on how I can run a program designed for a windows PC on my Apple Macbook Pro.

    Use Boot Camp Assistant, the PDF Guide and FAQ and there is a Boot Camp forum.
    Along with that, you might just use a virtual OS of Windows like VirtualBox from Oracle or buy VMware Fusion. But you need Windows usually (Crossover Mac covers a few programs).
    http://www.codeweavers.com/products/cxmac/
    Boot Camp:
    http://discussions.apple.com/category.jspa?categoryID=237
    http://www.apple.com/support/bootcamp/
    http://www.virtualbox.org/
    http://communities.vmware.com/community/vmtn/desktop/fusion

Maybe you are looking for