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

.onRelease button not playing video

Community Beginner ,
Jul 02, 2014 Jul 02, 2014

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.

TOPICS
ActionScript
721
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

Community Expert , Jul 02, 2014 Jul 02, 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();

...
Translate
Community Expert ,
Jul 02, 2014 Jul 02, 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();

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 ,
Jul 02, 2014 Jul 02, 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.

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 Expert ,
Jul 02, 2014 Jul 02, 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.

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 ,
Jul 07, 2014 Jul 07, 2014

Thanks on the _visible property tip.

It seems I spoke to soon on the video playing correctly. Apparently it's playing because I'm getting audio - but it's no where to be seen on the ad.

I don't know if one of the functions is missing or something else.

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 Expert ,
Jul 07, 2014 Jul 07, 2014

there is no video constructor in as2.  use the code i showed less the new Video line.

add a video symbol to your library, drag it to the stage and assign an instance name of myVideo.

test.

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 ,
Jul 07, 2014 Jul 07, 2014

Ahhh... guess I should find a reference as to what works in as2 vs as3. I had the video symbol on the stage but it was named my_Video from the previous code.

So much to learn - and yet I'll probably only use this once or twice a year.

Is there any reason you know of why someone would prefer as2 flash over as3?

Seems as3 is far more flexible.

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 Expert ,
Jul 07, 2014 Jul 07, 2014

none. skip as2.

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 ,
Jul 07, 2014 Jul 07, 2014

Grrr... that was my plan but the publisher said they had to have it in AS2 otherwise pop-up blockers would block the ad.

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 Expert ,
Jul 07, 2014 Jul 07, 2014
LATEST

i use flashblock with ff and it blocks all flash as2 or as3.  it's hard to believe any flash blocker would allow as2 and catch as3.

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