Video Actor

niccosw

  • Posts: 91
Video Actor
version 1.0 - uploaded July 23rd 2011
Flash only

Video Actor is behavior that allows you to stream video directly into an actor's current sprite. This behavior only works with Flash games (not iStencyl or any other platform). What this means is that video files can behave as normal actors in a game. They can be placed on different layers and interact with other game objects.



Is it possible to change a video during runtime?
Yes. For example, 4-way movement can trigger different video streams. To do this, set 'newVideoURL' on this behavior and tell it to 'changeVideoURL'.


Does this work with Flixel Pause and Volume control?
Yes.

Can I use FLV files with transparency?
Yes, but they are a bit slower than regular video. Be sure to click the check box in the behavior or you will see a trippy ghosting effect.

Is it possible to have multiple video actors running at the same time?
Yes, but this can use up a lot of resources. Use the debug console to watch your FPS. The larger the videos and the higher the frame rate, the more taxing it is.

Can I use this with HD video?
I don't suggest it. A 640x480 game will run much smoother than a 1280x720 or a 1920x1080 game. Going into Full Screen mode will drastically slow the performance as well, even for small games. If you must use HD, then use Stage Video and try to use only one or two videos at a time.

What is Stage Video? Is this the same Stage Video as Flash 10.2+?
No, this is not the same as Flash 10.2+ Stage Video. I guess I should rename it, shouldn't I? Hmmm. Maybe Static Video.

This places the video in front of the game where the actor cannot move or interact with the game. It will also obscure the Flixel pause and volume screens, but they will still function. Using this method there is a significant performance increase. Use this for full screen cutscenes and other non-interactive parts of the game.

Is there a sample game?
You can play the sample game from StencylForge in the "Video Actor" behavior. I'll look into posting a sample on stencyl.com but to do that I need to be allowed to host video there as well.

Will this behavior work with portals, such as Kongragate or Newgrounds?
Probably not. The video needs to be local or on the same server, unless there is a crossdomain.xml file. Most portals do not allow extra files to be uploaded without special permission.

How do I test video locally?
If you want to test using a relative path, you should place the video files in "StencylWorks\plaf\flash". Then you would call them by name like "myVideo.flv". I often create a separate folder called "assets" in the "flash" folder. Then I call: "assets/myVideo.flv". If I placed the folder higher in the hierarchy, such as "StencylWorks\assets" then I would use "../../assets/myVideo.flv".


I hope you get some use out of this. There is talk about making it an official part of the engine in the future. If you have any problems or suggestions, please post them here. I'll be making updates periodically to the code.

« Last Edit: January 25, 2012, 04:58:40 pm by niccosw »

Alexin

  • *
  • Posts: 3130
Nice job, niccosw!
"Find the fun"
alexin@stencyl.com

Darkhog

  • Posts: 1243
niccosw, about working on portals, you had similar affairs like here (that crossdomain.xml would be needed), but in the end it turned out that it isn't. Maybe it isn't here too?

There are no impossible things. There is only lack of skills.
Don't click this if your computer has less than 641 kilobytes of RAM.
Stencyl stencyling stencylish stencylers :D

niccosw

  • Posts: 91
I uploaded a sample game here and it broke, so I'm pretty sure it won't work without crossdomain.xml implemented.

DoctorMikeReddy

  • *
  • Posts: 180
Click this link:
http://adobe.edgeboss.net/download/adobe/adobetv/gotoandlearn/inspiration.flv
and it will download the file you used in the broken demo. Download the video actor script, add it to an actor. Add a local relative address link to the flv file and place it in the /plaf/flash folder where the test .swf file is generated. Add the actor to a scene. run.

Stand well back. You get a stream of errors. Interesting that the previous Stencyl video behaviour works off the Stencyl web site and with a locally stored file, as attempted above.

It's a scenescript and the web site tells you to use the actor behaviour. However, if it works...

DoctorMikeReddy

  • *
  • Posts: 180
Well that is weird. I changed some code around, inspired by the Stencyl Video Behaviour. Tested it and the actor now worked. then thought to comment out each change untll I saw the one that fixed it. Gradually, I commented out all of my changes! And it still worked! I think there must be a rogue character somewhere in the actor script downloaded from Stencyl. Editing in an external editor did show some weird formatting. So, anyway it works now with local files
:-)
Optionally, you can add:
org.flixel.FlxG.state.addChildAt(vid,1);
before
vid.attachNetStream(ns);
to get the video to play in the scene's (0,0) rather than using the top corner of the actor.
P.S. Speculating here, but I have seen actor behaviours fail before, then miraculously start working after I added an animation (i.e. an image), even when I then take it away again after. It could be that reformatting the script was not the fix after all. Anyone else seen this?

DoctorMikeReddy

  • *
  • Posts: 180
http://www.stencyl.com/game/play/7033
has a test for both of these behaviours. The scene based one works, the actor one doesn't for external URLs. An interesting conundrum as to why one works and the other doesn't. My vote is, therefore, for the scene behaviour until the other is fixed. I also like the "skip" to another scene option, having once made the mistake of playing Metal Gear Solid 4...

DoctorMikeReddy

  • *
  • Posts: 180
Idle speculation. I am wondering if some things need to be done at the script level (the Stencyl equivalent to MovieClip).

niccosw

  • Posts: 91
If there is a reason that the Video Object works without crossdomain.xml while the Actor Video doesn't, it is probably due to the transfer to BitmapData, which sets off all kinds of flags in Flash's security.

It would be possible to make a moving Video Object, but it wouldn't be a Stencyl Actor anymore. You would have to code all of it's behavior yourself instead of using behaviors from StencylForge. If you're fine with that, I say go for it because it is more efficient than grabbing each frame and streaming that to the actor. The point of this script is to trade some FPS and crossdomain.xml for the convince of using it as a normal actor.


soivn

  • Posts: 3
My error :
SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: file:///C|/Documents%20and%20Settings/Minh%20Huy/Local%20Settings/Temp/stencyl2483095220117240727/forge/Game.swf cannot access http://adobe.edgeboss.net/download/adobe/adobetv/gotoandlearn/encodingBasics.flv. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
   at flash.display::BitmapData/draw()
   at scripts::VideoActor/getImage()[C:\Documents and Settings\Nick.LARRY\My Documents\StencylWorks\sandbox\flash\scripts\VideoActor.as:186]

captaincomic

  • *
  • Posts: 6108
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e3f.html

To make a long story short:
When you run an swf locally it can only access local resources.
When you run an swf remote it can only access remote resources (on the same server, or on a sever with a crossdomain.xml).

Looks like you try to access a remote resource from your local swf...

soivn

  • Posts: 3
So I want to download "Video actor" for explore his behavior . But i can't download and i can't playnow . How can i do to fix this problem ?

captaincomic

  • *
  • Posts: 6108
When you want to test locally, you can just download the video file you want to play, and change the URL property in the video actor behavior to point to your local file (The URL has to start with "file://").

For testing online (e.g. on Stencyl.com), you would need some server or hosting service, where you can upload arbitrary files. There you would upload your video file and a file called crossdomain.xml containing the following:
Code: [Select]
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*.stencyl.com"/>
</cross-domain-policy>
This would allow an swf hosted on stencyl.com to access the files on that server.


bernard

  • Posts: 120
Video Actor
version 1.0 - uploaded July 23rd 2011

Video Actor is behavior that allows you to stream video directly into an actor's current sprite. What this means is that video files can behave as normal actors in a game. They can be placed on different layers and interact with other game objects.


Hi

On visiting the forge, I searched for Video and 2 items come up:
Yours dated Jun 17 (Featured) and another scene behaviour.

I selected yourd and clicked "Download" and  Stencyl sits there with a "Opening" message forever. After a while I clicked away from the forge to my game and there is an item called "Stencly Video Behavior" sitting there in my scene logic. So I dbl. click it and again Stencil just sits there with the

"Opening..." message and the behavior never opens.

Quitting and restarting shows that the behavior never downloaded so I try again with same result. I cannot download oe even look at this behaviour in Stencly.

I have the latest Stencyl (v1.4.1(b415))and testing on XP.

So what is up with this behaviour?

captaincomic

  • *
  • Posts: 6108
Hmmm, I have no idea, I could download it without problems.