Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Remove Frame Script

Community Beginner ,
Jan 09, 2013 Jan 09, 2013

I have this function that is called by a frame. When I leave the frame it is still trying to run the createWater function.  How do I prevent it from doint that?

FRAME SCRIPT

createWater();

stop()l

FUNCTION

//Water Shimmmer;

function createWater()

{

          var bm:BitmapData = new BitmapData(water_MC.width,water_MC.height);

          var disp:DisplacementMapFilter = new DisplacementMapFilter(bm,new Point(0,0),1,2,10,60)

          var pt1:Point = new Point(0,0);

          var pt2:Point = new Point(0,0);

          var perlinOffset:Array = [pt1,pt2];

          stage.addEventListener(Event.ENTER_FRAME, onFrame);

          function onFrame(evt:Event):void

          {

                    perlinOffset[0].x +=  1;

                    perlinOffset[1].y +=  0.1;

                    bm.perlinNoise(45,9,2,50,true,false, 7,true,perlinOffset);

                    water_MC.filters = [disp];

          }

}

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 09, 2013 Jan 09, 2013

You shouldn't be nesting the onFrame function like you do.  Pull it out on its own.  Aside from that, if you want to stop that function you need to remove the ENTER_FRAME listener at whatever point in the code where you make the move to another frame.

      stage.removeEventListener(Event.ENTER_FRAME, onFrame);

That might be all you need to do since that appears to be the only things that would keep working after you leave the frame.

Translate
LEGEND ,
Jan 09, 2013 Jan 09, 2013
LATEST

You shouldn't be nesting the onFrame function like you do.  Pull it out on its own.  Aside from that, if you want to stop that function you need to remove the ENTER_FRAME listener at whatever point in the code where you make the move to another frame.

      stage.removeEventListener(Event.ENTER_FRAME, onFrame);

That might be all you need to do since that appears to be the only things that would keep working after you leave the frame.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines