Archive for the ‘Problems & Solutions’ Category

FLVPlayer common Problems (remote file access and instancing compiler-time problem)

Sunday, January 13th, 2008

FLV player is cool component that provides easy video streaming and displaying management, but, there are some common problems that new users may experience:

1. - Can’t display remote file (FLV stored on some web server, even if file is nest to caller SWF)

2. - When instancing FLAPlayer from fl.video.FLVPlayback; you are getting compiling-time error that fl.video.FLVPlayback definition couldn’t be found.

1. Problem is about security handling.

The simplest way to avoid this problem, is to put

crossdomain.xml file with content like this:

<?xml version=”1.0″?>
<!– http://www.adobe.com/crossdomain.xml –>
<cross-domain-policy>
<allow-access-from domain=”*” />
</cross-domain-policy>

this is example from Adobe’s site. Like this you’re allowing access from all domains to resource files in folder where this XML is. (this will allow .FLV, .SWF .XML and other files to be loaded from domain with crossdomain.xml). In case where you don’t have access to domain’s root, you may include such code in SWF file that is being loaded (alternativly, you can use SWF files with FVL player integrated inside it)

Security
.allowDomain(”www.example.com”)

where www.example.com is domain which contains resource files, with remote files.

and simpler solution could be to load crossdomain.xml file from alternative location inside domain with:

Security.loadPolicyFile(”http://socketServerHost.com/crossdomain.xml”)

2. It’s really strange that you can’t instance FLVPlayer object from code if you don’t have instanced component from Flash Component library and set it somewhere to stage or in asset library. So, solution is to check:

1. if you have proper  import fl.video.FLVPlayback;
statement at begining of your code

2. and if you have FLVPlayer in library asset.

Package and Classes reorganization - import paths replacement horror

Friday, January 4th, 2008

How your project grows, you are becoming aware that your starting package/class organization isn’t the best one and when you decide to change package organization you are facing fact that you have to open every single .as file and to manually replace import class path.

Same thing when you decide to change name of some class or method. Newer Visual Studios (like 2005 and 2008) have automatic replacment tool that sometimes can do great job, sometimes it replaces some property names just because you copy’n'pasted old definition, then started to change it, and without reading popup question clicked ok.

 Flash CS3 doesn’t have such ability but good thing is that there is small Open Source Java tool for quick and simple multi file string replacement.

First tool that I found worked nicely for me:

Tool’s name is SandR
and project’s url:
http://sourceforge.net/projects/sandr/

It can even scan folder and subfolders and replaces all files inside.

But, later I realized that it has problem with UTF-8 file encoding so it puts some bytes at begining of .as file, so you have same situation where you have to open each .as manually.

Better solution is another open source java tool: JReplace

http://sourceforge.net/projects/jreplace/

it worked very good in many cases (in all ;) )

Very handy.

getDefinitionByName() problem

Friday, January 4th, 2008

Once I spotted getDefinitionByName function in flash.utils.* namespace I was very happy with idea to solve objects instancing on elegant and easy way. I’ve created XML decription format like this:

 <ogroup typing=”ifs.ifs3D.Camera” arrayName=”camArray” >
  <ent camPos=”200,200,800″ camTar=”0,0,0″ camRot=”0,0,0″ fov=”90″ focus=”100″ name=”maincam” />
 </ogroup>

 where <ogroup> with it’s <ent /> nodes describes objects and putting it to camArray:Array.
Here usage of getDefinitionByName() sounds great, because ifs.ifs3D.Camera is real classpath.

 But :)

 Problem is that both Flash and Flex compiler AI in this way can’t see that my code will use ifd.ifs3D.Camera class and in compile time it doesn’t put it in resulting bytecode. So I was getting error at runtime:

- Camera value is undefined

Solution is to somewhere in code use classpath that you’re going to call with getDefinitionByName(); in command like:

var proto_i3D:ifs.ifs3D.Camera;

or just

var proto_i3D:Camera;

 So it’s imposable to create totally XML driven object instancing, but getDefinitionByName() is still usable to avoid big switch(xml.@objecttype) structure.

Usefull links:

http://www.as3guru.com/?p=5 - Here I found solution for this problem


tesseractstudio.org | all rights reserved 2005-2008. | tesseractstudio ltd, Serbia
omnetwork.net | tutorialautomated.info | osgamer.org | freeflashscripts.com | tesslabs.com | thefirstexodus.com | thefirstexodus.com