All posts by Ronald Timoshenko

Internet Explorer, Flash, Alignment Gotcha

I ran into a rather annoying issue the other day related to content alignment in Flash; as usual, this problem exists exclusively in Internet Explorer. To be more specific, it is an issue with how the Flash Player ActiveX control is written.

If you are aligning content in Flash that uses the Stage width or height as a variable (e.g., you want to center a MovieClip) and you do it on initialization (i.e., in code and on the first frame), you may run in to this issue. Here is an image demonstrating what you might see:

Note that in the “before” screen, the content is centered horizontally, while in the “after” screen, the content is only half-visible and appears to be “centered” on the left margin.

If you run a test – output the Stage width to a text field, you’ll see that the width will be returned as 0.

As far as I know, there are two solutions to this problem. If you’re embedding your Flash using swfObject, then make sure that you omit the “scale” attribute. For example, modify the following:

var params = {
    bgcolor: "#000000",
    menu: "false",
    scale: "noScale",
    allowFullScreen: true
};

To something that looks like this:

var params = {
    bgcolor: "#000000",
    menu: "false",
    allowFullScreen: true
};

Alternatively, if you absolutely need that attribute. You can create an “EnterFrame” event listener that detects when the Stage width is greater than 0 and then remove the listener. Here’s an example in ActionScript 2:

this.onEnterFrame = function() {
    if (Stage.width > 0) {
        init(); // Pass to initialization function
        this.onEnterFrame = null; // Clear enterFrame listener
    }
}

T_PAAMAYIM_NEKUDOTAYIM

Parse error: syntax error, unexpected ‘)’, expecting T_PAAMAYIM_NEKUDOTAYIM in …

I encountered this weird PHP error today; if it happens to you it’s probably because you forgot to declare a variable by leaving off the ‘$’ prefix (e.g., ‘myVar’ instead of ‘$myVar’). More info here: http://en.wikipedia.org/wiki/Paamayim_Nekudotayim.

Obviously, it’s a fairly cryptic error message; albeit its cause is simple to resolve. It is exactly these types of things that makes it easier to understand why so many developers dislike PHP – it doesn’t keep me from using it though.

Zend Framework & Flash

Here’s a quick little “gotcha” when using the Zend PHP Framework:

If you plan on using Flash at all (i.e., SWF or FLV files) be sure to append the necessary extensions the .htaccess file in the “public” folder to the rewrite rule:

RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|flv)$ index.php

Note the added “swf” and “flv” extensions. Otherwise access to these files will return an error. Firebug (if you use it) will say that the files are being loaded (200 OK), but if you look at the response, it’s the error page not the actually requested file that is being returned.

Granted, this isn’t exclusive to the Zend Framework – it’s a result of the .htaccess configuration (regardless of which framework/engine you use); but it’s just something to keep in mind.

Update:

Here’s a better declaration (via: http://framework.zend.com/manual/en/zend.application.quick-start.html):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

ActionScript 2.0 NetStream Annoyance

Here’s a “heads up” to anyone who may be pulling his/her hair out wondering why NetStream won’t load an FLV. For whatever reason (I’m guessing it’s a bug), if you have a strongly-typed NetStream within a function, it will not work.

For example, the following code will work on “_root”:

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("video1.flv");

Try dropping this into a function or class and you will see that it does not work at all. To make it work, you must completely remove the data typing and variable declaration for the NetStream and NetConnection:

var my_video:Video; // my_video is a Video object on the Stage
my_nc = new NetConnection();
my_nc.connect(null);
my_ns = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video1.flv");

See Adobe’s LiveDocs on this topic for more information.

I wasted far too many hours trying to figure this out thinking that the problem was with my code. I hope I can save someone else from the same frustration.

Mozilla Firefox and XML Limitations

I wish I was informed earlier of the XML limitations in Firefox. I was racking my brain trying to figure out why my external XML entities were not working only to discover that this essential XML feature is unsupported by Firefox.

This will NOT work:

<!DOCTYPE root [
<!ENTITY sample SYSTEM "sample.xml">
]>
<root>
&sample;
</root>

How disappointing. I understand the rationale, but It’s unfortunate that this capability is completely unavailable.

Prado PHP 5 Framework

I’ve been reading a lot about ASP.Net (with C#) recently. I want to learn to use ASP.Net proficiently so that I can add it to my web “toolkit” (development languages I’m familiar with). A major downside to learning a new language is that as you consistently practice the new, it seems that you lose your grasp on what was once familiar – the old.

Fortunately, PHP and C# aren’t too different (not as dissimilar as PHP and VB anyway). But, ASP.Net itself (regardless of which language you use with it; VB or C#) is a component and event based framework, requiring certain rules and components to tie the back-end to the front-end (generally speaking). PHP, on the other hand, is not built this way; most PHP code is written inline. So when switching back-and-forth between developing in ASP.Net and PHP (or any multitude of languages), there are unique approaches that are required in accomplishing the same tasks. Obviously, this can become very confusing.

To get to the point: last week, I happened to come across the Prado PHP Framework. My first thought was, “Oh, another PHP framework”, but then I took a closer look at the syntax and the page rendering model. As I looked through the tutorials and documentation, it dawned on me that by using Prado I wouldn’t have to worry about using different approaches to server-side development. I could use the same model with ASP.Net and with PHP.

I immediately became excited at the possibilities. How simple would it be to develop and application in one language and port it to the other? If you’re already using the same model, all you would be switching is the “engine”. Anyway, before I digress too much (this post is already exceedingly lengthy) and ramble forever I’ll conclude with this: If you’re a PHP developer and interested in ASP.Net, or if you’re an ASP.Net developer interested in PHP, Prado is the way to go. Check it out at www.pradosoft.com.