2 Replies Latest reply on May 9, 2012 7:09 AM by spursfan2k12

    links not working when clicking (code included)

    spursfan2k12

      Ok im totally new to AS so i will do best to describe issue i am running into.....

       

      Have a cover photo created in PS,and on photo, there is text, which when click should open pdf file specified.....well when i hover over, and click....it doesnt go anywhere....(example below)  THX for any responses and assistance.

       

       

       

          EX:        this would be the cover photo

       

       

                        REPORT

      ------------------------------------------------------

       

        Analysis  (this should have a sub menu of PDF's which it does, but when click on the pdf's refrenced, it doesnt go anywhere)

        Link 2     (PDF)

        Link 3     (PDF)

        Link 4     (PDF)

        Link 5     (same as Analysis)

        Link 6     (PDF)

         ect ect...

      ------------------------------------------------------------------------------------------ -------------------------------------------

       

       

      CODE BELOW....

       

       

      import flash.net.URLRequest;

      import flash.events.MouseEvent;

      import flash.events.Event;

       

      //init menu links

      var link_1:Object = this.getChildByName( 'MenuLinkMC_1' );

      var link_2:Object = this.getChildByName( 'MenuLinkMC_2' );

      var link_3:Object = this.getChildByName( 'MenuLinkMC_3' );

      var link_4:Object = this.getChildByName( 'MenuLinkMC_4' );

      var link_5:Object = this.getChildByName( 'MenuLinkMC_5' );

      var link_6:Object = this.getChildByName( 'MenuLinkMC_6' );

      var link_7:Object = this.getChildByName( 'MenuLinkMC_7' );

      var link_8:Object = this.getChildByName( 'MenuLinkMC_8' );

      var link_9:Object = this.getChildByName( 'MenuLinkMC_9' );

       

      var _close:Object = this.getChildByName( 'closeMC' );

      this._close.addEventListener( MouseEvent.CLICK, quit );

       

      var sub_menu_notes_slide:Object = this.getChildByName( 'SubMenu_NotesSlideMC' );

      var sub_menu_discussion_slide:Object = this.getChildByName( 'SubMenu_DiscussionSlideMC' );

       

      //set url addresses

      var url_link_1:URLRequest = new URLRequest( 'PDF_FILES/1.  MD&A Introduction.pdf' );

      var url_link_2:URLRequest = new URLRequest( 'PDF_FILES/9.  Independent Auditors\' Report.pdf' );

      var url_link_3:URLRequest = new URLRequest( 'PDF_FILES/10.  Balance Sheets.pdf' );

      var url_link_4:URLRequest = new URLRequest( 'PDF_FILES/11.  Statements of Revenues, Expenses and Changes in Fund Net Assets.pdf' );

      var url_link_5:URLRequest = new URLRequest( 'PDF_FILES/12.  Statements of Cash Flows.pdf' );

      var url_link_6:URLRequest = new URLRequest( 'PDF_FILES/13.  Note 1 - Summary of Significant Accounting Policies.pdf' );

      var url_link_7:URLRequest = new URLRequest( 'PDF_FILES/31.  Glossary of Terms.pdf' );

      var url_link_8:URLRequest = new URLRequest( 'PDF_FILES/EOY Audited Financials - FY2011 with blue links.pdf' );

      var url_link_9:URLRequest = new URLRequest( 'http://www.cpsenergy.com' );

       

      //run subroutines

      noMenu();

       

      set_link( link_1, url_link_1, sub_menu_discussion_slide );

      set_link( link_2, url_link_2, null );

      set_link( link_3, url_link_3, null );

      set_link( link_4, url_link_4, null );

      set_link( link_5, url_link_5, null );

      set_link( link_6, url_link_6, sub_menu_notes_slide );

      set_link( link_7, url_link_7, null );

      set_link( link_8, url_link_8, null );

      set_link( link_9, url_link_9, null );

       

      //subroutines

      function set_link( linkObject:Object, linkURL:URLRequest, optMenu:Object ):void {

          linkObject.addEventListener( MouseEvent.CLICK, click_link );

          linkObject.addEventListener( MouseEvent.MOUSE_OVER, mouse_over_link );

         

          if ( optMenu != null ){

              this.setChildIndex( MovieClip( optMenu ), 9 );

              linkObject.addEventListener( Event.ENTER_FRAME, slide_sub_menu );

          }

         

          function click_link( evt:MouseEvent):void {

              navigateToURL( linkURL, 'File.browseForOpen()' );    <-----(note: should this be set to "_blank"  ?)

          }

         

          function mouse_over_link( evt:MouseEvent ):void {

              linkObject.mouseChildren = false;

              linkObject.buttonMode = true;

              linkObject.useHandCursor = true;

          }

         

          function slide_sub_menu( evt:Event ):void {

              if ( optMenu.hitTestPoint( mouseX, mouseY, true )) {

                  optMenu.nextFrame();

              } else {

                  optMenu.prevFrame();

              }

          }

      }

       

      function quit( evt:MouseEvent ):void {

          fscommand("quit", "");

      }

       

      function noMenu():void {

          var NoMenu:ContextMenu = new ContextMenu();

          NoMenu.hideBuiltInItems();

          this.contextMenu = NoMenu;

      }

      ------------------------------------------------------------------------------------------ -------------------------------AND

       

      import flash.events.MouseEvent;

       

      //init sublinks

      var sublink_1:Object = this.getChildByName( 'SublinkMC_1' );

      var sublink_2:Object = this.getChildByName( 'SublinkMC_2' );

      var sublink_3:Object = this.getChildByName( 'SublinkMC_3' );

      var sublink_4:Object = this.getChildByName( 'SublinkMC_4' );

      var sublink_5:Object = this.getChildByName( 'SublinkMC_5' );

      var sublink_6:Object = this.getChildByName( 'SublinkMC_6' );

      var sublink_7:Object = this.getChildByName( 'SublinkMC_7' );

      var sublink_8:Object = this.getChildByName( 'SublinkMC_8' );

      var sublink_9:Object = this.getChildByName( 'SublinkMC_9' );

      var sublink_10:Object = this.getChildByName( 'SublinkMC_10' );

      var sublink_11:Object = this.getChildByName( 'SublinkMC_11' );

      var sublink_12:Object = this.getChildByName( 'SublinkMC_12' );

      var sublink_13:Object = this.getChildByName( 'SublinkMC_13' );

      var sublink_14:Object = this.getChildByName( 'SublinkMC_14' );

      var sublink_15:Object = this.getChildByName( 'SublinkMC_15' );

      var sublink_16:Object = this.getChildByName( 'SublinkMC_16' );

      var sublink_17:Object = this.getChildByName( 'SublinkMC_17' );

      var sublink_18:Object = this.getChildByName( 'SublinkMC_18' );

       

      //set link names dynamic text

      sublink_1.SublinkNameDT.text = 'Note 1 - Summary of Significant Accounting Policies';

      sublink_2.SublinkNameDT.text = 'Note 2 - Cash, Cash Equivalents and Investments';

      sublink_3.SublinkNameDT.text = 'Note 3 - Disaggregation of Current Receivables and Payables';

      sublink_4.SublinkNameDT.text = 'Note 4 - Capital Assets';

      sublink_5.SublinkNameDT.text = 'Note 5 - Revenue Bond and Commercial Paper Ordinances Requirements';

      sublink_6.SublinkNameDT.text = 'Note 6 - Revenue Bonds';

      sublink_7.SublinkNameDT.text = 'Note 7 - Commercial Paper and Related Revolving Credit Agreement';

      sublink_8.SublinkNameDT.text = 'Note 8 - Flexible Rate Revolving Note';

      sublink_9.SublinkNameDT.text = 'Note 9 - Employee Pension Plan';

      sublink_10.SublinkNameDT.text = 'Note 10 - Other Postemployment Benefits';

      sublink_11.SublinkNameDT.text = 'Note 11 - Other Obligations and Risk Management';

      sublink_12.SublinkNameDT.text = 'Note 12 - Other Financial Instruments';

      sublink_13.SublinkNameDT.text = 'Note 13 - Lease-Leaseback';

      sublink_14.SublinkNameDT.text = 'Note 14 - South Texas Project';

      sublink_15.SublinkNameDT.text = 'Note 15 - Commitments and Contingencies';

      sublink_16.SublinkNameDT.text = 'Note 16 - Leases';

      sublink_17.SublinkNameDT.text = 'Note 17 - Pollution Remediation Obligation';

      sublink_18.SublinkNameDT.text = 'Note 18 - Subsequent Events';

       

      //set url addresses

      var url_sublink_1:URLRequest = new URLRequest( 'PDF_FILES/13.  Note 1 - Summary of Significant Accounting Policies.pdf' );

      var url_sublink_2:URLRequest = new URLRequest( 'PDF_FILES/14.  Note 2 - Cash, Cash Equivalents and Investments.pdf' );

      var url_sublink_3:URLRequest = new URLRequest( 'PDF_FILES/15.  Note 3 - Disaggregation of Current Receivables and Payables.pdf' );

      var url_sublink_4:URLRequest = new URLRequest( 'PDF_FILES/16.  Note 4 - Capital Assets.pdf' );

      var url_sublink_5:URLRequest = new URLRequest( 'PDF_FILES/17.  Note 5 - Revenue Bond and Commercial Paper Ordinances Requirements.pdf' );

      var url_sublink_6:URLRequest = new URLRequest( 'PDF_FILES/18.  Note 6 - Revenue Bonds.pdf' );

      var url_sublink_7:URLRequest = new URLRequest( 'PDF_FILES/19.  Note 7 - Commercial Paper.pdf' );

      var url_sublink_8:URLRequest = new URLRequest( 'PDF_FILES/20.  Note 8 - Flexible Rate Revolving Note.pdf' );

      var url_sublink_9:URLRequest = new URLRequest( 'PDF_FILES/21.  Note 9 - Employee Pension Plan.pdf' );

      var url_sublink_10:URLRequest = new URLRequest( 'PDF_FILES/22.  Note 10 - Other Postemployment Benefits.pdf' );

      var url_sublink_11:URLRequest = new URLRequest( 'PDF_FILES/23.  Note 11 - Other Obligations and Risk Management.pdf' );

      var url_sublink_12:URLRequest = new URLRequest( 'PDF_FILES/24.  Note 12 - Other Financial Instruments.pdf' );

      var url_sublink_13:URLRequest = new URLRequest( 'PDF_FILES/25.  Note 13 - Lease-Leaseback.pdf' );

      var url_sublink_14:URLRequest = new URLRequest( 'PDF_FILES/26.  Note 14 - South Texas Project.pdf' );

      var url_sublink_15:URLRequest = new URLRequest( 'PDF_FILES/27.  Note 15 - Commitments and Contingencies.pdf' );

      var url_sublink_16:URLRequest = new URLRequest( 'PDF_FILES/28.  Note 16 - Leases.pdf' );

      var url_sublink_17:URLRequest = new URLRequest( 'PDF_FILES/29.  Note 17 - Pollution Remediation Obligation.pdf' );

      var url_sublink_18:URLRequest = new URLRequest( 'PDF_FILES/30.  Note 18 - Subsequent Events.pdf' );

       

       

      //run subroutines

      set_sublink( sublink_1, url_sublink_1 );

      set_sublink( sublink_2, url_sublink_2 );

      set_sublink( sublink_3, url_sublink_3 );

      set_sublink( sublink_4, url_sublink_4 );

      set_sublink( sublink_5, url_sublink_5 );

      set_sublink( sublink_6, url_sublink_6 );

      set_sublink( sublink_7, url_sublink_7 );

      set_sublink( sublink_8, url_sublink_8 );

      set_sublink( sublink_9, url_sublink_9 );

      set_sublink( sublink_10, url_sublink_10 );

      set_sublink( sublink_11, url_sublink_11 );

      set_sublink( sublink_12, url_sublink_12 );

      set_sublink( sublink_13, url_sublink_13 );

      set_sublink( sublink_14, url_sublink_14 );

      set_sublink( sublink_15, url_sublink_15 );

      set_sublink( sublink_16, url_sublink_16 );

      set_sublink( sublink_17, url_sublink_17 );

      set_sublink( sublink_18, url_sublink_18 );

       

      //subroutines

      function set_sublink( sublinkObject:Object, sublinkURL ):void {

          sublinkObject.addEventListener( MouseEvent.CLICK, click_sublink );

          sublinkObject.addEventListener( MouseEvent.MOUSE_OVER, mouse_over_sublink );

          sublinkObject.addEventListener( MouseEvent.MOUSE_OUT, mouse_out_sublink );

         

          function click_sublink( evt:MouseEvent):void {

              navigateToURL( sublinkURL, '_blank' );

          }

         

          function mouse_over_sublink( evt:MouseEvent ):void {

              sublinkObject.mouseChildren = false;

              sublinkObject.buttonMode = true;

              sublinkObject.useHandCursor = true;

             

              sublinkObject.gotoAndStop( 'On' );

          }

         

          function mouse_out_sublink( evt:MouseEvent ):void {

              sublinkObject.gotoAndStop( 'Off' );

          }

      }