-
using keypress to play video
Hi All
I'm making changes to a very old project that was made using AS2.
I'm trying to give the user some hotkeys to trigger videos playing on a scoreboard.
I'm using this code on a movie clip:-
Code:
onClipEvent (keyDown) {
//showing overlay on with control + e
if (Key.isDown(17) and Key.isDown(49))
{
var my_video:Video;// my_video is a Video object on the Stage
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play(_root.vid);
_root.my_video._alpha = 100;
}
but its not doing much.
I know that the same code on a button does the trick, but not it seems on a listener. I've also put something different within the it statement to check that the keypress trigger works and it does.
Can anyone help me figure out why its not working?
-
.
Hi,
You missed the _root for the video player,
PHP Code:
[onClipEvent (keyDown) {
//showing overlay on with control + e
//1 = 49
// e = 69
// 17 = control
if (Key.isDown(17) && Key.isDown(49))
{
trace("1 & control are both pressed");
var my_video:Video;
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
_root.my_video.attachVideo(my_ns);
my_ns.play("video.flv");// I used my video for testing
//_root.my_video._alpha = 100;
}
}
-
Perfect, that fixed it!
Many thanks
Originally Posted by fruitbeard
Hi,
You missed the _root for the video player,
PHP Code:
[onClipEvent (keyDown) {
//showing overlay on with control + e
//1 = 49
// e = 69
// 17 = control
if (Key.isDown(17) && Key.isDown(49))
{
trace("1 & control are both pressed");
var my_video:Video;
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
_root.my_video.attachVideo(my_ns);
my_ns.play("video.flv");// I used my video for testing
//_root.my_video._alpha = 100;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|