I'm attempting to add a skip intro button within the intro. I've tried using methods that have worked with regular animations but they aren't working.

I tried this code with no luck so I'm hoping someone else has something that will work.

monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.domain.com/"));
}

Dani AI

Generated

Short primer: an .flv is just media — it cannot contain ActionScript. Any interactivity (buttons, event listeners, navigation or seeking) has to live in the SWF “wrapper” or player that loads the FLV. The compile errors about missing MouseEvent / URLRequest usually mean the FLA is set to the wrong ActionScript version (or the code is being placed where the player/compiler can’t see those classes). ran into that; was right to push for placing the control in the FLA, but the reason your original code failed is almost always a publish/type mismatch or the button being behind the video layer.

Quick checklist and examples (AS3):

  • Make sure the FLA’s document/publish script is ActionScript 3.0.
  • Put the skip button on a layer above the FLVPlayback/Video instance and give it an instance name (for example skipBtn). Give the FLV player an instance name (for example flvPlayer).
  • Import the classes before using them.
import fl.video.FLVPlayback;
import flash.events.MouseEvent;
import flash.net.URLRequest;

skipBtn.addEventListener(MouseEvent.CLICK, onSkip);

function onSkip(e:MouseEvent):void {
    // jump to 60 seconds in the video:
    if (flvPlayer is FLVPlayback) flvPlayer.seek(60);
    // or navigate away:
    // navigateToURL(new URLRequest("http://example.com"), "_self");
}

If your FLA must stay AS2, use AS2-style navigation (skip_btn.onRelease = function(){ getURL("http://example.com","_self"); };). Other gotchas: FLVPlayback skins or components can intercept mouse events (ensure your button sits above them or set the player’s mouse flags appropriately), and hardware-accelerated StageVideo can render above normal display objects — in that case use the player API or disable StageVideo. In short: don’t expect to inject code into the .flv; put the UI in the wrapper SWF (as suggested) and verify ActionScript version and instance names.

Recommended Answers

All 5 Replies

Member Avatar for Member #334542

Your code is working, are you expecting to open in the same window
Sample:

hit_btn.addEventListener(MouseEvent.CLICK,TestURL);
function TestURL(e:MouseEvent):void
{
var serverpath:String="http://localhost/Raja/AS3.0 PHP/TestPHP.php";
var urlrequest:URLRequest=new URLRequest(serverpath);
navigateToURL(urlrequest,"_self");
}

Hope this helps!

The class or interface 'MouseEvent' could not be loaded.
The class or interface 'URLRequest' could not be loaded.

I was told by someone that since the intro is just an embedded flv that a normal button code for an animation wouldn't work.

Can you look at the intro and maybe it will give you an idea?
joshsonunionsquare dot com

Member Avatar for Member #334542

The given embedded flv is your intro right! then its working fine with your skip intro button right!. I want more explanation!!!!

The given embedded flv is your intro right! then its working fine with your skip intro button right!. I want more explanation!!!!

At the moment I have a separate skip intro button outside of the intro due to that code not working with an embedded flv as an intro.

I suppose I'll just leave a separate button to skip the intro since the person I'm building this for said that is just as fine.

Member Avatar for Member #334542

If you want to use the button within flv, that is not possible! but this is the embeded flv, so you can place the button on the flv while designing, thats enough!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.