Friday, 30 of July of 2010

Tag » flash

Future of flash?

Adobe is going to release next version of Flex with the name of Flash.

Question is where is our old Flash?

Current versions has already lost its legend characteristics of Flash.

I am okay with flex. Good for business based applications. Lots of graphs, easy to use services, components and libraries, rapid development and many revolutionary things. Flash is separate thing to do things differently. Adobe is try to make it dot net kind of environment but I recall this to adobe that people have already things similar to flex but what they do not have is FLASH.

Another problem is Adobe is not keeping its promise to make flash platform independent. I am specifically targeting towards linux. More than a decade and flash or flex is still a dream for linux users.

Therefore, I request Adobe to not to loose legend core of flash.

[The article is not targeting flash environment but that Flash language and IDE]


Do your comment

How to stop internet explorer yellow security bar while loading swf content.

Many times (I even don’t remember) people ask these questions.

1. My swf works fine in mozilla / firefox but not in internet explorer. Why?
2. When I double click a HTML web page to view my flash content (movie), it shows yellow bar at top. Why?
3. How can we remove yellow information bar in IE (internet explorer) while loading my swf content?

….. and so on.

Well the solution is simple and kiddie to those who knows. But what about who is newbie or less knowledge of flash?

Here is an example, how to write HTML code to embed SWF.

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>example</title>
<script language=”javascript”>AC_FL_RunContent = 0;</script>
<script src=”AC_RunActiveContent.js” language=”javascript”></script>
</head>
<body bgcolor=”#000000″>
<script language=”javascript”>
if (AC_FL_RunContent == 0) {
alert(“This page requires AC_RunActiveContent.js.”);
} else {
AC_FL_RunContent(
‘codebase’, ‘http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0′,
‘width’, ’290′,
‘height’, ’340′,
‘src’, ‘images/SWFs/myswf‘,
‘quality’, ‘high’,
‘pluginspage’, ‘http://www.macromedia.com/go/getflashplayer’,
‘align’, ‘middle’,
‘play’, ‘true’,
‘loop’, ‘true’,
‘scale’, ‘showall’,
‘wmode’, ‘window’,
‘devicefont’, ‘false’,
‘id’, ‘myswf‘,
‘bgcolor’, ‘#000000′,
‘name’, ‘myswf‘,
‘menu’, ‘false’,
‘allowFullScreen’, ‘false’,
‘allowScriptAccess’,'sameDomain’,
‘movie’, ‘images/SWFs/myswf‘,
‘salign’, ”
);
}
</script>
<noscript>
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0″ width=”290″ height=”340″ id=”t3fla” align=”middle”>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”allowFullScreen” value=”false” />
<param name=”movie” value=”images/SWFs/myswf.swf” /><param name=”quality” value=”high” /><param name=”bgcolor” value=”#000000″ />    <embed src=”images/SWFs/myswf.swf” quality=”high” bgcolor=”#000000″ width=”290″ height=”340″ name=”myswf” align=”middle” allowScriptAccess=”sameDomain” allowFullScreen=”false” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
</noscript>

</body>
</html>

Probably this could be your HTML code. {You can use this code for exercise.}

Now, you need ac_runactivecontent to run your javascript. The filename is hilighted in red in above code.  This file will reside along with your HTML file.

See in <HEAD>…

<script language=”javascript”>AC_FL_RunContent = 0;</script>
<script src=”AC_RunActiveContent.js” language=”javascript”></script>

These 2 lines add and enable javascript. You need to have the same js file along with the HTML file.

See <BODY>….

<script language=”javascript”>
if (AC_FL_RunContent == 0) {
alert(“This page requires AC_RunActiveContent.js.”);
} else {
AC_FL_RunContent(
‘codebase’, ‘http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0′,
‘width’, ’290′,
‘height’, ’340′,
‘src’, ‘images/SWFs/myswf‘,
‘quality’, ‘high’,
‘pluginspage’, ‘http://www.macromedia.com/go/getflashplayer’,
‘align’, ‘middle’,
‘play’, ‘true’,
‘loop’, ‘true’,
‘scale’, ‘showall’,
‘wmode’, ‘window’,
‘devicefont’, ‘false’,
‘id’, ‘myswf‘,
‘bgcolor’, ‘#000000′,
‘name’, ‘myswf‘,
‘menu’, ‘false’,
‘allowFullScreen’, ‘false’,
‘allowScriptAccess’,'sameDomain’,
‘movie’, ‘images/SWFs/myswf‘,
‘salign’, ”
);
}
</script>

Now what?

We need your swf that you need to load. Say… your swf name is myswf.swf and it resides in SWFs folder in images folder.

Put images folder along with HTML as shown below.

image

Copy your swf name with relative path and paste in place of blue colored text as per above example. Keep in mind that you don’t need to write swf extension with its file name. Check carefully.

And you know green colored text script very well so I think I don’t need to elaborate this part.

Double click to open the html to load swf content. If everything fine, your SWF will load perfactly without any security (yellow bar) related problem.

Have a nice day!


Hidden add-ons on Flash CS4

Have you ever checked Flash CS4 About dialog window? 

As many of us knows that it is tradition that on almost all versions of Flash editor environment, you can find something hidden. In Flash CS4 about dialog window, you can also find these things…

1. In line below FL, you can find 2 dots. Click the first dot and click and click. As number of clicks increases, the casting animation accelerates. Same as the second dot but this dot deccelerates the animation. 

4. Now click on “4″ in the same line. :) Now you will get lots of photographs as slideshow without any introduction. Now click on photographs to change it rapidly.

 

Check it out yourself. Thanks.


Code optimization and AS3

Everytime after finishing bulky code writing, you would often need to optimize your code to minimize memory consumption. This is little bit tedious job for who wouldn’t keep their eye over code optimization and AS3 coding guidlines.

 First and foremost thing is CODE OPTIMIZATION IS NOT A BIG PROBLEM IF YOU TAKE CARE OF FEW THINGS.

Lets start what you should remember while writing code and how.

 Lets go with how first. For a developer coding is just like daily routine so you must have to follow desciplines/rules/protocols while coding.

Now following are few things that you should always keep in mind.

 If you start a very new project from scratch, always create an interface that would have just 2 things. One would be toString()  and other is dispose(). 
 /**

* Interface implemented by each class.
* @author Your Name
* @version 0.1
* @date 14-11-2008
*/

package com.core
{
public interface ICore  
{
function toString():String;
function dispose():void;
}
}

Always implement this interface into your every class whereever you write. This may help you to collect garbage.

In each and every class don’t forget to update this dispose method. This would contain everything that you need to distroy.

/**
* Dispose.
* @author Pravin Ranjan
* @version 0.1
* @date 16-7-2008
*/

public function dispose():void
{
removeChild(_mcTooltip);
for (var i:String in _arrItems)
{
_arrItems[i].dispose();
removeChild(_arrItems[i]);
}
_arrItems = null;
_mcTooltip = null;
_objMain = null;
Main.getInstance().removeChild(this);
}

Often programmer think that they have removed the sprite and everything will washed away. AS3 JIT is right now not so intelligent to remove what you think. Therefore it is always keep in mind to remove things manually. I don’t think this is a bad habit. You can write 5000 lines of code so better if you could write 5200 lines of robust and memory intelligent code.

What precisely I am talking about is to remove each and every instance you have created, whether it could be local, class variable or global (static). Remove everything manually.

As you know some data types allocate memory to copy similar things. Others use reference like array and objects.

Remove each and every events that you have created. In some cases, lets say, you use an event only one time, destry it immediately. In another case like call a class, assign listener and forget. In this case too, remove listener immediately.

var obj:SwfExportDlgBox = MessageBox.getInstance().showSwfExportDialog(“Title”, “Message”);
if (obj != null) obj.addEventListener(MessageEvent.MSG_OK, clbSWFExport); 

private function clbSWFExport(event:MessageEvent):void
{
event.stopImmediatePropagation(); //Generally you don’t need propagation.
//Remove the listener.
event.target.removeEventListener(MessageEvent.MSG_OK, clbSWFExport); 

//START YOUR CODE HERE. 

}

Always set each object, string, class instances to null just after use. Keep in mind that a static variable never dispose itself untill you clean it manually. If you use a static variable in a class, always set it to null before removing it. If not so, JIT alwyas think about you class that it has some variable and should not be cleaned. :D and you may think opposite.

Always dispose a bitmapdata object. A bitmapdata object doesn’t clean itself(By JIT). You need to dispose it manually. Some programmers return a bitmapdata object from a method and forget. For safe practice, if a method get a bitmapdata object as a parameter, don’t forget to remove it, if it is unnecessary.

Other safe practices are to optimize loops, reusability and other things that you better know and would already practicing. 

In later posts, I’ll share my other programming experiences.

See y then! [Forget about my spelling mistakes as I am not a regular writer]


1 comment

Welcome to pravinranjan’s blog

I am pleased to announce that all blog posts has got its new and stable home and that is called http://pravinranjan.com/blog. 

Sorry for unstability till date. From now onwards, I’ll write my all posts in this location.

Cheers!


Do your comment

I have launched my new forum

Hi all,

I have launched my new forum today. This is pravinranjan.com

Thanks,

Flas3


3 comments