Tips.PHP: Removing empty strings, NULL, FALSE, and negative numbers from Array

Often we need to remove empty elements from our array. For example when we split a string with space, we can get the words and also blank strings when there are two or more spaces put together. We can use array_filter function for rescue. When we call array_filter with out passing the filter function it removes all values that evaluate to FALSE. <?php $string = "I love   Luracast...

Read More

Tips.PHP: Securing ViewSource.php

I’m in the process of creating Usage examples for the brand new version of RESTler. Take a look at the work in progress version here (I would love to hear your thoughts). One of the nice features in that is the ability to see the source code. I’m using a getsource.php which will return the source code of any php file when the relative path is passed as a query parameter. It is...

Read More

Adding an icon to all items in the List Component.

List component does not have a default icon. Easy way to add one is to add a Icon function which is very similar to the one we use with Flash v2 components. Only difference is instead of string we need to return a class reference to the image [Embed (source = 'res/image_link.png')] [Bindable] public var image_ico : Class; private function...

Read More

Designing a Search Field .

Utilizing the available application space effectively is one of the important things we need to consider when designing an user interface. Olden search interfaces had two parts text input field and a search button. Then the “search”/”find”/”go” text is replaced with a lens icon. Now a days this lens icon is embedded inside the input text itself. If you want...

Read More

Sending Arrays with offset Index.

Last time we saw the problem with sending ActionScipt 3 Associative Array. Now we let us see where associative arrays can help. Lets Make an Array with offset index in PHP: $arr =array(5=>5); in ActionScript: var arr:Array= []; arr[5]=5; Sending these arrays either way they go with the missing indices filled with null, so the PHP array comes to flash as arr=[null, null,...

Read More

Easy way to Randomize an Array.

Here is the sample code to shuffle the contents of an array // Here is a simple function for randomizing the array function randomsort(a, b) {         return Math.random()&gt;.5 ? -1 : 1; } //usage example var arr = [1, 2, 3, 4, 5]; arr.sort(randomsort); trace(arr); //traces 4,3,1,5,2

Read More

including Actionscript 1 files in Actionscript 2 Project.

When we are including an AS1 file in an Fla which has to be published as AS2, we need to be careful in naming the include file. There shouldn’t be any object initialized in _global which has the same name as the include file. Say for example, I had a include file called Security.As and inside that had _global.Security=new Object(). When I published I got the following ...

Read More

Is Running in Flash IDE?

When testing my application in IDE, I wanted to use some hard coded test data instead of Every time loading the dynamic data. System.capabilities.isDebugger is the boolean property which is true when we are testing in IDE or special Debug Player. Here is the sample code that I’ve used <pre>if (!System.capabilities.isDebugger) {    ...

Read More

Solution for skipping files from getting cached by Server and Browser

Cache is a place to store something more or less temporarily. Web pages we’ve visited are stored in our browser’s cache directory on our hard disk. Likewise, ISPs and Web Servers cache web pages which speeds up access times for users, as the page is being read from the cache memory and not downloaded from the actual web site It can become a problem when we are loading external...

Read More

Compiled components and Actionscript Viewer version 4

With Flash MX 2004 we can create and use Compiled components so source need not be distributed. It is good for many component developers because they need not worry about exposing their code. But when you produce your swf with the component, everything is byte code and can be translated back to Actionscript by the tools like ActionScript Viewer. Compiled components has the extension...

Read More

__bytecode__ and its use

Robin Debreuil mentioned about it in his nice new blog(Welcome Robin!) and further discussed in FlashCoders mailinglist. Using __bytecode(“SomeByteCodeHere”); in your actionscript you can inject some bytecode into swf (It will be inserted at compile time). It can be used to compactly represent some actionscript and hide the code behind in your FLA. But the swf produced is no...

Read More

XML Pre Processing for handling XML

When we want to handle external Html files as XML, say for example using my transformTags() code, we face the problem of unclosed tags like <br> tag. To fix this problem we can overwrite onData method of XML object as shown below. It basically replaces all <br> tags with <br/> before parsing the XML data [UPDATE] included the ActionScript 3 version as well 🙂 It became lot...

Read More

Macromedia Tips Library

I just noticed that Macromedia now has a Tips Library in the Designer & Developer Center, where we can share our favorite product tips. Take a look and post your tips at http://www.macromedia.com/desdev/tips_library?

Read More

Enabling Flash Links in Director

It’s time for Director again (time for Director MX in fact!). Somebody sent me a mail asking why the getURL functions which are supposed to open the links are failing when we embed the flash movie in director? The reason is simple, both getURL and FSCommand are methods for flash to communicate to the container application. When we embed the flash file in a HTML page Flash plugin for the...

Read More

Corrupt Movieclip?

Yesterday I faced this problem. When I imported a audio file into a movieclip of a heavy flash file, It imported the audio but it was truncated (the end portion of the audio is missing) I even tried importing the audio into new flash file and drag and drop it in the library but still got the same problem Finally I managed the situation by * Recreating the movieclip in a new flash file * Dragging...

Read More

Problem importing sound?

When our flash file becomes big and complex we often face this problem. When we try to import the audio we get “One or more files were not imported because there were problems reading them” even when you are sure that the audio format is flash compatible. Solution? Import the audio into a new blank flash file once done drag the imported audio from this library to your project files...

Read More

Dedicated Project Explorer

It is always better to keep all our current project files under projects folder in properly named sub folders particularly in a collaborative environment. Also you may be keeping your project files in a server. In such cases the following tip really helps! You can create My Projects shortcut in the desktop. Which will open a dedicated Explorer for your projects. Just create a shortcut...

Read More

Reducing the file size of Your FLA file

If your flash project includes sound, import the audio as a MP3 file instead of Wave files (convert your wave files to mp3 in your audio editing software). This not only helps to reduce the file size of your .fla file, also reduces the time taken to publish an swf file out of it. This Projects using wave files take longer time to publish because every time it will be compressed based on your...

Read More