Quantcast
Channel: Adobe Community : Discussion List - Using Flash Builder
Viewing all articles
Browse latest Browse all 1802

How to call an internal function from an external function.

$
0
0

I am working on a page turning program and have bookmark option that would change the display to the current frame in a displayed swf file , but I get an error 1609, and have tried to research how to do it but I haven't been able to find out anything attached is the code for the section.

package screens

{

import flash.display.Loader;

import flash.display.MovieClip;

import flash.display.Shape;

import flash.display.Sprite;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import events.NavigationEvent;

import support.NxtPrvButton;

import support.RoundRectButton;

 

public class SwfLsnScrn extends Sprite

{

 

  private var _scrnid:Object;

  private var _bgClr:uint;

  private var _swfToLoad:String;

 

  private var _page:int = 1;

 

  public function get pagenum(): Number{

   return _page;

  }

  public function set pagenum(pg:Number):void{

   _page = pg;

  }

 

  public function SwfLsnScrn(scrnid:Object, bgClr:uint, swfToLoad:String)

  {

   super();

   _scrnid=scrnid;   // id used in dispatch event to let main know who is calling

   _bgClr = bgClr;         //color of background

   _swfToLoad=swfToLoad; //what swf to load and directory

     

   this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);

  }

 

 

  public function disposeTemporarily():void

  {

   this.visible = false;

  }

 

  public function initialize():void

  {

   this.visible = true;

  }

 

  public function bookmark(page:Number):void

  {

   pagenum = page;

   this.visible = true;

   trace("bkmark call done going to setpage", pagenum);

   setpage(pagenum);

  }

 

  

  private function onAddedToStage(e:Event):void

  {

   this.removeEventListener(Event.ADDED_TO_STAGE,onAddedToStage);

   var background:Shape = new Shape();

   background.graphics.beginFill(_bgClr,1);

   background.graphics.drawRect(0,0,640,1136);

   background.x=0;

   background.y=0;

   addChild(background);

  

   /////////////////swf loader section

   //var i:int = 1;

   var _bkScrn:MovieClip = new MovieClip;

   var ldr:Loader = new Loader();

   var appDomain:ApplicationDomain = ApplicationDomain.currentDomain;

   var lc:LoaderContext = new LoaderContext(false,appDomain, null);

   ldr.load(new URLRequest(_swfToLoad),lc);

   ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);

  

  

   function onComplete(e:Event):void{

    _bkScrn = e.target.content;

    addChild(_bkScrn);

    setpage(pagenum);

   

       function setpage(i:Number):void{

    _bkScrn.gotoAndStop(i); //_bkScrn.gotoAndStop(i);

    }

   

    var exitbtn:RoundRectButton = new RoundRectButton(60, 40, 20, 2, 0xF6EED7 ,"TofC", 0x000000,"Georgia",24,false)

    exitbtn.x= 0;

    exitbtn.y=920;

    addChild(exitbtn);

    exitbtn.addEventListener(MouseEvent.CLICK, closeScrnSwf);

   

    var nextbtn:NxtPrvButton = new NxtPrvButton(160, 40, 20, 2, 0xF6EED7, true)

    nextbtn.x=380;

    nextbtn.y=920;

    addChild(nextbtn);

    nextbtn.addEventListener(MouseEvent.CLICK, nextClk);

   

    var prevbtn:NxtPrvButton = new NxtPrvButton(160, 40, 20, 2, 0xF6EED7, false)

    prevbtn.x=110;

    prevbtn.y=920;

    addChild(prevbtn);

    prevbtn.addEventListener(MouseEvent.CLICK, prevClk);

   

   

    function nextClk(e:MouseEvent):void

    {

     /*if(i<_bkScrn.totalFrames){

      i++;

      _bkScrn.gotoAndStop(i);

      }*/

     if(pagenum<_bkScrn.totalFrames){

      pagenum++;

      setpage(pagenum); //_bkScrn.gotoAndStop(pagenum);

     }

    }

    function prevClk(e:MouseEvent):void

    {

     /*if(i>1){

      i--;

      _bkScrn.gotoAndStop(i);

     }*/

     if(pagenum>1){

      pagenum--;

      setpage(pagenum); //_bkScrn.gotoAndStop(pagenum);

     }

    }

     

   }

  

  }

 

  public function closeScrnSwf(e:MouseEvent):void

  {

    this.dispatchEvent(new NavigationEvent(NavigationEvent.CHANGE_SCREEN, {id: _scrnid}, true));

  

  }

 

}

}

 

The problem as I said is the bookmark function when it tries to call the setpage function.  Any help would be appreciated.


Viewing all articles
Browse latest Browse all 1802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>