Skip to main content
Participating Frequently
July 2, 2014
Answered

.onRelease button not playing video

  • July 2, 2014
  • 1 reply
  • 870 views

I created an video Flash ad with ActionScript 3.0 and was then told by the publisher I could only use ActionScript 2.0. #smh

I've gone back and tried to figure out the ActionScript 2.0 alternatives and syntax and the ad appears now without any errors but I seem to be missing something as the play_btn will not start the video.

Here's my script:

var myVideo:Video = new Video(300, 170); // note size for video

  addChild(myVideo);

// Play button

play_btn.onRelease = function() {

  var nc:NetConnection = new NetConnection();

  nc.connect(null);

  var ns:NetStream = new NetStream(nc);

  ns.client = new Object();

  myVideo.attachVideo(ns);

  ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

  addChild(play_btn);

  addChild(stop_btn);

};

// Stop button

stop_btn.onRelease = function() {

  ns.pause();

};

// Lean More button

learn_btn.onRelease = function() {

  getURL(_root.clickTAG, "_blank");

};

// stop();

I'm not sure if I need the stop command or not as right now it's not making a difference one way or the other. Any help on what I'm missing would be greatly appreciated.

This topic has been closed for replies.
Correct answer kglad

try:

var myVideo:Video = new Video(300, 170); // note size for video

  var nc:NetConnection = new NetConnection();

  nc.connect(null);

  var ns:NetStream = new NetStream(nc);

  myVideo.attachVideo(ns);

// Play button

play_btn.onRelease = function() {

  ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

};

// Stop button

stop_btn.onRelease = function() {

  ns.pause();

};

// Lean More button

learn_btn.onRelease = function() {

  getURL(_root.clickTAG, "_blank");

};

// stop();

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 2, 2014

try:

var myVideo:Video = new Video(300, 170); // note size for video

  var nc:NetConnection = new NetConnection();

  nc.connect(null);

  var ns:NetStream = new NetStream(nc);

  myVideo.attachVideo(ns);

// Play button

play_btn.onRelease = function() {

  ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

};

// Stop button

stop_btn.onRelease = function() {

  ns.pause();

};

// Lean More button

learn_btn.onRelease = function() {

  getURL(_root.clickTAG, "_blank");

};

// stop();

Participating Frequently
July 2, 2014

That seems to have gotten the video playing again not sure why the order made a difference.

The downside is it's playing in the background apparently so the still graphic isn't being hidden while the video is playing.

I tried re-adding the add_child lines back in but that didn't seem to fix it.

kglad
Community Expert
Community Expert
July 2, 2014

your main problem was making netstream and netconnection local to that onrelease function.  also, there is no addchild in as2.

to solve your latest problem, convert your bg graphic to a movieclip and assign an instance name.  in the onrelease, assign that movieclip's _visible property to false.

p.s. please mark correct and helpful responses.