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

Hide dynamic flash video from stage when leaving frame?

Community Beginner ,
Nov 22, 2014 Nov 22, 2014

Hello all,

I am still working on this flash presentation and I have coded a dynamic video player that calls on a url to play an mp4 file.

The problem is that when I leave the frame which I have designated for video, the video still remains on the stage over the content on the other frames.

Now, I have experimented with things such as removeChild but with no luck.

If anyone has suggestions about how to make the video visible on one frame, or to make it stop playing on other frames, I would appreciate the input.

Thanks!

Here is my code if it helps.

var alreadyExecuted:Boolean;

if (! alreadyExecuted)

{

  alreadyExecuted = true;

  stop();

  //begin button animation

  home_button.addEventListener(MouseEvent.ROLL_OVER, overBtn);

  home_button.addEventListener(MouseEvent.ROLL_OUT, outBtn);

  home_button.addEventListener(MouseEvent.CLICK, clickBtn);

  video_button.addEventListener(MouseEvent.ROLL_OVER, overBtn);

  video_button.addEventListener(MouseEvent.ROLL_OUT, outBtn);

  video_button.addEventListener(MouseEvent.CLICK, clickBtn);

  animation_button.addEventListener(MouseEvent.ROLL_OVER, overBtn);

  animation_button.addEventListener(MouseEvent.ROLL_OUT, outBtn);

  animation_button.addEventListener(MouseEvent.CLICK, clickBtn);

  faq_button.addEventListener(MouseEvent.ROLL_OVER, overBtn);

  faq_button.addEventListener(MouseEvent.ROLL_OUT, outBtn);

  faq_button.addEventListener(MouseEvent.CLICK, clickBtn);

  quiz_button.addEventListener(MouseEvent.ROLL_OVER, overBtn);

  quiz_button.addEventListener(MouseEvent.ROLL_OUT, outBtn);

  quiz_button.addEventListener(MouseEvent.CLICK, clickBtn);

  function overBtn(evt:MouseEvent):void

  {

  evt.currentTarget.gotoAndPlay(10);

  }

  function outBtn(evt:MouseEvent):void

  {

  evt.currentTarget.gotoAndPlay(1);

  }

  function clickBtn(evt:MouseEvent):void

  {

  evt.currentTarget.gotoAndPlay(20);

  }

  //end button animation - begin navigation ;

  video_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_13);

  function fl_ClickToGoToAndStopAtFrame_13(event:MouseEvent):void

  {

  gotoAndStop(15);

  }

  animation_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

  function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

  {

  gotoAndStop(30);

  }

  faq_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_15);

  function fl_ClickToGoToAndStopAtFrame_15(event:MouseEvent):void

  {

  gotoAndStop(45);

  }

  quiz_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_16);

  function fl_ClickToGoToAndStopAtFrame_16(event:MouseEvent):void

  {

  gotoAndStop(60);

  }

  home_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_17);

  function fl_ClickToGoToAndStopAtFrame_17(event:MouseEvent):void

  {

  gotoAndStop(1);

  }

  //end navigation -Begin mp3 player code

  var mySound:Sound;

  var myChannel:SoundChannel;

  var soundIsPlaying:Boolean = false;//prevent play btn overlap

  var p:uint = 0;

  mySound = new Sound  ;

  mySound.load(new URLRequest("assets/track1.mp3"));

  btn_play.addEventListener(MouseEvent.CLICK, playSound);

  btn_stop.addEventListener(MouseEvent.CLICK, stopSound);

  btn_pause.addEventListener(MouseEvent.CLICK, pauseSound);

  function stopSound(myEvent:MouseEvent):void

  {

  myChannel.stop();

  p = 0;

  soundIsPlaying = false;

  }

  function playSound(myEvent:MouseEvent):void

  {

  if (! soundIsPlaying)

  {

  myChannel = mySound.play(p);//play song location (p)

  soundIsPlaying = true;

  }

  }

  function pauseSound(myEvent:MouseEvent):void

  {

  if (soundIsPlaying)

  {

  p = Math.floor(myChannel.position);

  myChannel.stop();

  soundIsPlaying = false;

  }

  }

  //video code

  var video:Video = new Video(480,204);

  video.y = stage.stageHeight / 2 - 278 / 2;

  video.x = stage.stageWidth / 2 - 290 / 2;

  var nc:NetConnection = new NetConnection();

  nc.connect(null);

  var ns:NetStream = new NetStream(nc);

  ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

  function onStatusEvent(stat:Object):void

  {

  trace(stat.info.code);

  }

  var meta:Object = new Object();

  meta.onMetaData = function(meta:Object){

  trace(meta.duration);

  };

  ns.client = meta;

  video.attachNetStream(ns);

  btn_playvid.addEventListener(MouseEvent.CLICK, playFunction);

  function playFunction(evt:MouseEvent):void

  {

  ns.play("assets/movie.mp4");

  }

  btn_stopvid.addEventListener(MouseEvent.CLICK, stopFunction);

  function stopFunction(evt:MouseEvent):void

  {

  ns.pause();

  }

}

//hide video playback buttons on first frame

btn_playvid.visible = false;

btn_stopvid.visible = false;

TOPICS
ActionScript
203
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 , Nov 22, 2014 Nov 22, 2014

Change the .y location of the video object to something off the visible area of the stage, say -1000.

Translate
LEGEND ,
Nov 22, 2014 Nov 22, 2014

Change the .y location of the video object to something off the visible area of the stage, say -1000.

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
Community Beginner ,
Nov 22, 2014 Nov 22, 2014
LATEST

thank you so much for the quick reply! It worked !

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