Tuesday, January 5, 2010

Flash Embed getting "TypeError: Error #1007: Instantiation attempted on a non-constructor"

When use the actionscript developed in Flex, I got the following error:
TypeError: Error #1007: Instantiation attempted on a non-constructor
TypeError: Error #1007: 嘗試個體化非建構函式。

Code as following:

package
{
import flash.display.MovieClip;

public class SampleMovieClip extends MovieClip
{
[Embed(source="main_visual.png")]
private var _bmp:Class;

public function SampleMovieClip() : void
{
addChild(new _bmp());
}
}
}


It is because Flash Actionscript doesn't support Metadata "Embed", refer to following page for a solution:
http://blog.wezside.co.za/2008/04/everything-embe.html

Quick snippet:

[Embed(source="as3_pages_source.swf", mimeType="application/octet-stream")]
private var SWFBytes:Class;

private var applicationDomain:ApplicationDomain;

private function init(event:Event=null):void
{
this.loadApplicationDomain();
}

private function loadApplicationDomain():void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderLoaded);
try{
loader.loadBytes(new SWFBytes() as ByteArray);
} catch (err:Error)
{
loader.removeEventListener(Event.INIT, onLoaderLoaded);
trace(err + ", \nLawfui noted: [Embed] is not allowed in Flash IDE, loadApplicationDomain_SWF is used instead");
loadApplicationDomain_SWF("as3_pages_source.swf");
}
}

public function loadApplicationDomain_SWF(url:String):void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderLoaded);
loader.load(new URLRequest(url));
}

private function initPageFlipCore():void
{
core = new PageFlipCore( this.applicationDomain );
core.x = 200;
core.y += 150;

this.addChild(core);
}

private function onLoaderLoaded(event:Event):void
{
var loaderInfo:LoaderInfo = event.currentTarget as LoaderInfo;
applicationDomain = loaderInfo.applicationDomain;
initPageFlipCore();
return;
}

Starting a actionscript project with width and height set

When using Flex for a Actionscript project development, I always run into a situation that the testing movie doesn't have a prefered size, even I set the mc.width and mc.height in the script.

The following is the solution:

package
{
import flash.display.MovieClip;

[SWF(width="1000", height="628", backgroundColor="0x000000", frameRate="30")]
public class SampleMovieClip extends MovieClip
{
}
}

Thursday, April 2, 2009

Some find tunes for the amfphp settings

Trying to figure out how to sending/receiving strongly typed objects between ActionScript and AMFPHP

some find tunes needed in the following files:

globals.php
$voPath = "services/vo";
$servicesPath = "services/";


gateway.php
$gateway->setCharsetHandler("utf8_decode", "UTF-8", "UTF-8");

Thursday, April 17, 2008

Rendering Performance

I like to set the props / layout of the component/application by overriding updateDisplayList();

However, I experience a drop of rendering speed in Flex application when the application is developed into a larger size. And I discover that the key issue was using "setStyle" everytime when the updateDisplayList() is executed.

Actually the setStyle just need to apply once after the application is initialized. So the problem can be solved after I added _init flag into the application and run the setStyle procedures only if the _init is true...

Monday, April 14, 2008

wmode on Firefox

when u set wmode in html, and the page is opened in Firefox, it will mess up your special chars input such as Chinese / German or whatever... so lame...

https://bugzilla.mozilla.org/show_bug.cgi?id=347185

https://bugs.adobe.com/jira/browse/SDK-12420

http://www.google.com/search?hl=zh-TW&rls=com.microsoft%3Azh-hk%3AIE-SearchBox&rlz=1I7GZAZ&q=firefox+wmode+bug&lr=

Wednesday, February 27, 2008

Cairngorm + Modules

There are a few notes to take care:

1) For Singleton Class like DragManager which holds data, it is better to put in ApplicationDomain as RSL.

2) While using Modules, the modulesInfo needs a differnet ID even the class is the same, i.e. new another ModuleInfo even the source is the same.

3) The "Modular" Package is adopted.

For now I didn't get ServiceLocator to work as I want. Will think of adopting the Prana framework anyway. We'll see.

Tuesday, February 19, 2008

Modular Programming

Stopped flex programming for like 2 months, I am return finally.

Well... I stopped the latest development of Flex Project: [Bast] becuz I found out the file size and codes will go eventually too large for the applicant to be efficient and fluent. I was thinking about making some component as smaller part application and load it into main application container whenever it is needed. But never figure it out... and finally I get to read part of the Modular Programming notes.

And I plan to try out the following:
1) Program modules <-- can apply framework
2) Link the Progress event against preloader of DisplayObjectContainer or ProgressBar Control

Just a simple concept, let's see if it works or not.

On the other hand, I participated in Adobe FMS3 seminar this week, seems the price of FMS3 is kinda cheap nowadays.