Vagrant and VirtualBox, modified files do not update when viewed in either NGINX or Apache, change image also

Posted in web

python e commerce worth to try

cartridge, saleor (satchless), oscar

Posted in web

my 幻想 docker flow

  • just write your code first, without docker
  • git push your application when you can first deploy
  • create a docker image, in dockerFile or init of your image, git clone the lastest code
  • pack it into image
  • for old machine, update the container with new image

  • one application one docker
  • mysql no need include in docker, and it should not go into a separate docker. just find a machine or one of a machine to run it.
Posted in web

[ios] convert mpmediaitem to m4a

-(NSString*)convertToM4A : (MPMediaItem * ) mediaItem {
    NSURL *url = [mediaItem valueForProperty: MPMediaItemPropertyAssetURL];

    AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil];

    AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset

    exporter.outputFileType = @"";

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * myDocumentsDirectory = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;

    /* Using date to be file name so no conflict
    [[NSDate date] timeIntervalSince1970];
    NSTimeInterval seconds = [[NSDate date] timeIntervalSince1970];
    NSString *intervalSeconds = [NSString stringWithFormat:@"%0.0f",seconds];*/

    NSString* mediaTitle = [mediaItem valueForProperty:MPMediaItemPropertyTitle];
    NSString* songTitle = [[NSString alloc]initWithFormat:@"%@",(mediaTitle.length>0 ? mediaTitle : @"Unknown")];

    NSString * fileName = [NSString stringWithFormat:@"%@.m4a", songTitle];

    NSString *exportFile = [myDocumentsDirectory stringByAppendingPathComponent:fileName];

    NSURL *exportURL = [NSURL fileURLWithPath:exportFile];
    exporter.outputURL = exportURL;

    // do the export
    // (completion handler block omitted)
    [exporter exportAsynchronouslyWithCompletionHandler:
         int exportStatus = exporter.status;

         switch (exportStatus)
             case AVAssetExportSessionStatusFailed:
                 NSError *exportError = exporter.error;
                 NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
             case AVAssetExportSessionStatusCompleted:
                 NSLog (@"AVAssetExportSessionStatusCompleted");
                  NSData *data = [NSData dataWithContentsOfFile: [myDocumentsDirectory

                  NSLog(@"Data %@",data);
                  data = nil;
             case AVAssetExportSessionStatusUnknown:
                 NSLog (@"AVAssetExportSessionStatusUnknown"); break;
             case AVAssetExportSessionStatusExporting:
                 NSLog (@"AVAssetExportSessionStatusExporting"); break;
             case AVAssetExportSessionStatusCancelled:
                 NSLog (@"AVAssetExportSessionStatusCancelled"); break;
             case AVAssetExportSessionStatusWaiting:
                 NSLog (@"AVAssetExportSessionStatusWaiting"); break;
                 NSLog (@"didn't get export status"); break;
    return [exportURL absoluteString];
Posted in mobile

ORA-00979 not a group by expression

group by 個堆 attribute 一定要有曬 select 個堆

Posted in 編程

[ios aubio]ld: symbol(s) not found for architecture arm64

Undefined symbols for architecture arm64:
  "_vDSP_ctoz", referenced from:
      _aubio_fft_do_complex in aubio(fft.c.1.o)
  "_vDSP_fft_zrip", referenced from:
      _aubio_fft_do_complex in aubio(fft.c.1.o)
  "_vDSP_minv", referenced from:
      _fvec_min in aubio(mathutils.c.1.o)
  "_vDSP_create_fftsetup", referenced from:
      _new_aubio_fft in aubio(fft.c.1.o)
  "_vDSP_maxvi", referenced from:
      _fvec_max_elem in aubio(mathutils.c.1.o)
  "_vDSP_vsmul", referenced from:
      _aubio_fft_do_complex in aubio(fft.c.1.o)
  "_vDSP_maxv", referenced from:
      _fvec_max in aubio(mathutils.c.1.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Don’t cry.
Try to import Accelerate.framework which is default in frameworks of xcode.

Posted in mobile

dun use /documents to save your sqllite in ios (which is default setting when you tick use CoreData)

please store it in application support / library

Posted in mobile

scrollview with a uiview in masonry

A tableview which scrollview and the tableview can scroll to right

self.tableView = [[UITableView alloc]init];
self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
self.tableView.backgroundColor = [UIColor whiteColor];
[self.tableView setAllowsSelection:NO];

    //build the scrollabe view
    self.scrollView = [[UIScrollView alloc] init];
    self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;

    // add subview tree
    [self.scrollView addSubview:self.tableView];
    [self.view addSubview:self.scrollView];

    //build footer view
    self.footerView = [[DetailsTableVTViewFooterView alloc] init];
    self.footerView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:self.footerView];
    [self.footerView.saveButton addTarget:self action:@selector(saveLocalChanges) forControlEvents:UIControlEventTouchUpInside];

    // Using Masonry for autolayout
    [self.footerView makeConstraints:^(MASConstraintMaker *make) {

    self.scrollView.backgroundColor = [UIColor redColor];

    [self.scrollView makeConstraints:^(MASConstraintMaker *make) {

    [self.tableView makeConstraints:^(MASConstraintMaker *make) {
Posted in iphone

if you face strange position of keyboard or some uiview component, you may try to debug using this first

Posted in iphone

[!] The `BP Mobile Inspection [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig’. This can lead to problems with the CocoaPods installation

Posted in iphone

Server Deployment Common Practice


  • You has a admin user call your name. Say roychung for me. And other admin has own account too.
  • A user call deploy or your service name for the main service of your written code. It should not be a sudoer. And suppose you cannot login via ssh.
  • For different service, may be redis. You may consider to open an account for it too.
  • So how to deploy to the deploy user? You may consider using sudo su deploy
  • Using Fabric for deployment, login with your own admin account and sudo su make your life easier when there are several server
  • Using redis as example, you may use sudo to install redis (or using redis user install on it home folder), but running redis command will be using that redis user. So other user can modify it without knowing your account
Posted in web

icon 素材

Posted in graphics

music player in background ios

Solution 1. MPMusicPlayer ipodPlayer

it is actually calling the ipod player, which it is not related to the app anymore. Easy implement, 但有時 load 得多歌 會有d lag, 超建議開多個 tableView 做, 可以 store 住d mediaItemCollection, 因為呢個 framework 係唔會 交返d mediaItemCollection 你, 除非你用 hidden private API

Solution 2. AVPlayer with MPRemoteCommandCenter and MPNowPlayingInfoCenter

you can implement like this. Good Point is the music playing will also appear in the universal toolbar (the bottom one), and click one it, it will show yr app instead of ipod Music. Bad Point is no itunes cloud music can play, and many feature need to implement yrself, 連 previous 都好似無, shuffle 都有d 難做, 但用個d remoteCommand , 下面d 制都可以用, 同埋 用 nowplayinginfocenter 可以 改個 lock screen 個d song info. 無記錯呢個方法要改少少 plist, 有 background audio, 如果做完前者, 出 app無 聲, 試下

MPMusicPlayer ApplicationPlayer is a good choice 如果你想只播歌係你個 app 入面, 因為一出 app 就會 收聲

ref: (solution 1)

小米音樂 app (solution 2)

Posted in mobile

UITableView will drop down 20px ? ok, change yr storyboard order

solution 1. content inset -20px

solution 2. weird. Just dun put yr uitableViewcontroller in first order in STORYBOARD

Posted in mobile

Correct method for uibutton in tableViewCell

Many methods will tell u using button.tag…

but it only store an integer, if u want a indexPath , try the official method:

Posted in mobile

custom sort of core data

Posted in web

Core Data Transient Properties [MUST READ IF YOU USING CORE DATA]

Posted in mobile

UIBarButtonItem title 入 nil 唔好入 @””

用 code 整 nav button … 如果無 title 就入 nil … 入 @”” … 佢會因為其他有 component 郁 而 會移動並出現在 strange position

UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithTitle:@""

UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithTitle:nil
Posted in mobile

utf8mb4, string (or say varchar) want create key, length = 191

Posted in web

why python string has b, u in prefix

Posted in web

decorator in python

class entryExit(object):
def __init__(self, f): 
    print 'entry init enter' 
    self.f = f 
    print 'entry init exit'
def __call__(self, *args): 
    print "Entering", self.f.__name__ 
    r = self.f(*args) 
    print "Exited", self.f.__name__ 
    return r
print 'decorator using'
def hello(a): 
print 'inside hello' 
return "hello world " + a
print 'test start' 
print hello('friends')
>>> ================================ RESTART ================================ 
decorator using 
entry init enter 
entry init exit 
test start 
Entering hello 
inside hello 
Exited hello 
hello world friends
Posted in web

property inheritance in ios

How to access backing ivars for inherited properties in Objective-C
I had a superclass that declared and synthesized a read only property, meant to be set in its subclasses. The code was something like this:

@interface A : NSObject
@property (nonatomic, readonly) NSUInteger prop;

@implementation A
@synthesize prop = _prop;

@interface B : A

@implementation B

  • (void)establishValueForProp
    _prop = 1; // PROBLEM !!!


The instance variable backing the property seemed to be invisible in the subclass. The error was pretty unclear when compiling an iOS app: “Use of undeclared identifier ‘_prop’”. To get around the error I did the following:

@interface A : NSObject {
NSUInteger _prop;
@property (nonatomic, readonly) NSUInteger prop;

That is, I explicitly declared the backing variable in the declaration of the superclass.

Interestingly, when I was preparing this blog post I compiled the code above as a “Command Line Tool” type of project, not an iOS app. The error was different, dare I say better, more telling of the root cause: “Instance variable ‘_prop’ is private”. So it’s a matter of the visibility of the ivar, so perhaps a better fix would be:

@interface A : NSObject {
NSUInteger _prop;
@property (nonatomic, readonly) NSUInteger prop;

Kind of interesting though that properties are synthesized by default as private ivars. Learned something new.
Posted by Bogdan Hapca at 12:09 PM
Email This
Share to Twitter
Share to Facebook
Share to Pinterest

Labels: iOS, Objective-C
1 comment:

Liviu Macsen said…
Thank your Bogdan for your solution. I found that you can also synthesize in subclass in order to solve this problem.

@implementation B

@synthesize prop = _prop;

  • (void)establishValueForProp
    _prop = 1; // Working !!!


Posted in mobile

NSFetchResultController be datasource

Posted in mobile


debug YES becoz u only want to build in your testing device (or compile too long time and waste the other arch build)

release NO u should make sure all ios devices can run

Posted in mobile

fill the image in imageView according to fit width, and auto height

        self.artworkView.contentMode = UIViewContentModeScaleAspectFill;

        [self.artworkView makeConstraints:^(MASConstraintMaker *make) {
Posted in mobile

set segue.destinationViewController property

method 1. typecast

APPDetailViewController myController = (APPDetailViewController)segue.destinationViewController;
myController.myString = string;

method 2. selector

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    if ([segue.destinationViewController respondsToSelector:@selector(setMyData:)]) {
         [segue.destinationViewController performSelector:@selector(setMyData:) 

in destination View Controller

@property (nonatomic, strong) MyData *myData;
Posted in mobile

Assertion failure in -[XXXView layoutSublayersOfLayer:]

2014-08-06 12:17:02.511 Jtab[6255:60b] *** Assertion failure in -[JTChordCollectionView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2935.138/UIView.m:8794 2014-08-06 12:17:02.512 Jtab[6255:60b] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Auto Layout still required after executing -layoutSubviews. JTChordCollectionView’s implementation of -layoutSubviews needs to call super.’

    [super layoutSubviews];

    [chordLabelView makeConstraints:^(MASConstraintMaker *make) {

solve by add [super layoutSubviews]; before add constraints ….

Posted in mobile


-(void)fitFontSize:(UILabel*)label {
CGFloat actualFontSize;
[label.text sizeWithFont:label.font
label.font = [label.font fontWithSize:actualFontSize];
label.adjustsFontSizeToFitWidth = NO;

usage: self.keyLabel = [self makeLabel:[UIFont fontWithName:@"AkzidenzGroteskBE-BoldCn" size:45.0f]];

    self.keyLabel.frame = CGRectMake(0, 0, self.cellWidth / 4.0, self.cellHeight);
    self.keyLabel.text = @"C";

    [self fitFontSize:self.keyLabel];
    [self.keyLabel sizeToFit];
    [self.keyLabel makeConstraints:^(MASConstraintMaker *make) {
Posted in mobile

if you using storyboard, but some property need set in code (may be xcode GUI dun provide enough setting)

  • drag to property first
  • write a setter, it will autoload

// this function will auto load by storyboard
-(void)setKeyLabel:(UILabel *)keyLabel {
    if (_keyLabel != keyLabel) {
        _keyLabel = keyLabel;
        _keyLabel.font = [UIFont fontWithName:@"SOME-FONT-NAME" size:20.0f];
        _keyLabel.textColor = SOME-UI_COLOR;
Posted in mobile

Masonry in ios

constraints is funny

if u use Masonry or updateConstraints to a UIView, may no reaction till u drag one constraints to it…


  1. storyboard default has constraints already (if u dun drag any) it just the current frame be the constraints (if u tick autolayout which is usually ticked)
  2. when u drag the constraints, it override
  3. when u code using Masonry or constrains programming, it override

But sometimes it will say broken, becoz the constraints jammed… so… one solution:

it will ignore all the storyboard constraints, so u can use the coding one now.

Posted in mobile

auto size font size uilabel

- (void)drawPageLabel {
  self.pageLabel = [[UILabel alloc] init];

  [self addSubview: self.pageLabel];

  self.pageLabel.textColor = [UIColor blackColor];
  [self.pageLabel setAlpha:0.5];
  self.pageLabel.font = [self.pageLabel.font fontWithSize:140];
  [self.pageLabel setNumberOfLines:1];
  self.pageLabel.adjustsFontSizeToFitWidth = YES;
  self.pageLabel.minimumScaleFactor = 0.5f;

  // get a approiate font size using "1" char
  self.pageLabel.text = @"1";

  // make a frame for it to adjust it width for suitable fontSize
  CGFloat innerCircleWidth = self.radius * 0.2f * 2;
  self.pageLabel.frame = CGRectMake(0, 0, innerCircleWidth, innerCircleWidth); // maintain a square size

  // remeber the recommended font size
  CGFloat actualFontSize;
  [self.pageLabel.text sizeWithFont:self.pageLabel.font

  // use the recommended font size and dun adjust anymore
  [self.pageLabel setFont:[UIFont systemFontOfSize:actualFontSize]];
  [self.pageLabel sizeToFit];

  self.pageLabel.adjustsFontSizeToFitWidth = NO;

-(void)updatePageLabel:(int)currentNumber {
  self.pageLabel.text = [NSString stringWithFormat:@"%d", currentNumber];
  [self.pageLabel sizeToFit];
  self.pageLabel.frame = CGRectMake(self.pageLabel.superview.frame.size.width/2 - self.pageLabel.frame.size.width/2,
                                    self.pageLabel.superview.frame.size.height/2 - self.pageLabel.frame.size.height/2,

CGFloat actualFontSize;
[self.pageLabel.text sizeWithFont:self.pageLabel.font

this make my life … get the recommend font size after adjustsFontSizeToFitWidth
stupid sizeToFit only fit for the setted font size

Posted in mobile

kvo , key value observer script

in swipeView:

pair set:
– willChangeValueForKey:
– didChangeValueForKey:

or call this
- setValue:forKey:

[self.swipeView addObserver:self

self 個到有

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
Posted in mobile

- (CGSize)sizeThatFits:(CGSize)size

- (CGSize)sizeThatFits:(CGSize)size

the latter size is the boundary for the caller … so should be the superview size

Posted in mobile

show all text uilabel

label.text = "some text";
label.numberOfLines = 0;
[label sizeToFit];

CGRect frame = label.frame;
frame.size = [label sizeThatFits:CGSizeMake(320, 10000)];
label.frame = frame;
Posted in mobile

define const for color

#define ULIKELA_ORANGE [UIColor colorWithRed:244.0/255.0 green:189.0/255.0 blue:15.0/255.0 alpha:1.0]
Posted in mobile

when u add coreData, error : Receiver type is forward declaration

Posted in web

Markdown playground

test of markdown

  1. line 1
  2. line 2
Posted in web

navigation bar overlap webview ios7

webView.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
webView.scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(64, 0, 0, 0);

Posted in mobile

vagrant simple example

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider “virtualbox” do |v|
v.memory = 1024
v.cpus = 1
config.vm.define “prod” do |prod_config| = “jamnplayer” “forwarded_port”, guest: 8080, host: 8081 “forwarded_port”, guest: 5000, host: 5001 “forwarded_port”, guest: 22, host: 2200, auto_correct: false, id: “ssh”
prod_config.vm.host_name = “prod”


# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider “virtualbox” do |v|
v.memory = 2048
v.cpus = 1
config.vm.define “default” do |default_config| = “ubuntu-14.04″ “forwarded_port”, guest: 6543, host: 6543 “forwarded_port”, guest: 8080, host: 8080 “forwarded_port”, guest: 5000, host: 5000 “forwarded_port”, guest: 22, host: 2222, auto_correct: false, id: “ssh”
default_config.vm.host_name = “default”

Posted in web

sqlalchemy __init__ without declare all column property

def __init__(self, *agrs, **kwargs):
super(Song, self).__init__(**kwargs)
self.artist_hash = self.artist + “_” + self.md5

Posted in web

vagrant override ssh port forwarding “forwarded_port”, guest: 22, host: 2222, auto_correct: false, id: “ssh”

Posted in web

the virtualbox system ubuntu bit maybe wrong

I know at least 2 ways. Open a terminal and type:

uname -a

Result for 32-bit Ubuntu:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

whereas the 64-bit Ubuntu will show:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux


file /sbin/init

Result for 32-bit Ubuntu:

/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

whereas for the 64-bit version it would look like:

/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

Posted in 無分類

python property, getter, setter

Try this: Python Property

The sample code is:

class C(object):
def __init__(self):
self._x = None

def x(self):
“””I’m the ‘x’ property.”””
print “getter of x called”
return self._x

def x(self, value):
print “setter of x called”
self._x = value

def x(self):
print “deleter of x called”
del self._x

Posted in web

virtualenv python install will only install in the virtual env py/lib/python3.4/site-packages

virtualenv -p /usr/bin/python3.4 py3.4
(without source … )
py3.4/bin/python install
by using env python program,
it will not install in local, but in env

Posted in web

python framework mostly call views be controller

and views are templates

Posted in web

summarize of @wrap

>>> add = wrapper(add)

This pattern can be used at any time, to wrap any function. But if we are defining a function we can “decorate” it with the @ symbol like:

>>> @wrapper
… def add(a, b):
… return Coordinate(a.x + b.x, a.y + b.y)

Posted in web

[python] 中文字 secure_filename

Posted in web

[ios] filter music from ios by MPMediaQuery

MPMediaQuery *songQuery = [MPMediaQuery artistsQuery];
// OR
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];

// local only
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithBool:NO] forProperty:MPMediaItemPropertyIsCloudItem]];

NSArray *songs = [songQuery items];

And u will retrieve a list … but music video is still here…
becoz music video is 2049 … ok u see

enum {
// audio
MPMediaTypeMusic = 1 << 0,
MPMediaTypePodcast = 1 << 1,
MPMediaTypeAudioBook = 1 << 2,
MPMediaTypeAudioITunesU = 1 << 3, // available in iOS 5.0
MPMediaTypeAnyAudio = 0x00ff,

// video (available in iOS 5.0)
MPMediaTypeMovie = 1 << 8,
MPMediaTypeTVShow = 1 << 9,
MPMediaTypeVideoPodcast = 1 << 10,
MPMediaTypeMusicVideo = 1 << 11,
MPMediaTypeVideoITunesU = 1 << 12,
MPMediaTypeAnyVideo = 0xff00,

MPMediaTypeAny = ~0
typedef NSInteger MPMediaType;

tht’s it:

MPMediaTypeMusic: 1
MPMediaTypePodcast: 2
MPMediaTypeAudioBook: 4
MPMediaTypeAudioITunesU: 8 (iOS 5)
MPMediaTypeAnyAudio: 255
MPMediaTypeMovie: 256
MPMediaTypeTVShow: 512
MPMediaTypeVideoPodcast: 1024
MPMediaTypeMusicVideo: 2048
MPMediaTypeVideoITunesU: 4096
MPMediaTypeAnyVideo: 65280

2049 is MPMediaTypeMusicVideo + MPMediaTypeMusic

MPMediaQuery *songQuery = [MPMediaQuery artistsQuery];
OR MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
OR [songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMusic] forProperty:MPMediaItemPropertyMediaType]];
even add comparisonType:MPMediaPredicateComparisonEqualTo

3 methods no work … it want mediaType contain 1
and 2049 is still here

method : filter it:

NSArray *songs = [songQuery items];
NSMutableArray *finalSongs = [NSMutableArray array];

[songs enumerateObjectsUsingBlock:^(MPMediaItem *song, NSUInteger idx, BOOL *stop) {
NSInteger mediaValue = [[song valueForProperty:MPMediaItemPropertyMediaType] integerValue];
if (mediaValue == 1)
[finalSongs addObject:song];

Posted in mobile

play pause button ios

method 1
UIButton image change

method 2

playbutton.hidden = YES
pauseButton.hidden = NO

Posted in mobile

ios delegate tutorial

Posted in 編程

squidman see GET parameter

strip_query_terms off

add this into the template of squid

if u want more parameter
add a log formart
and using access log to activate it

Posted in 編程

AFNetworking using manager to eat @”text/plain”

make AFHTTPRequestOperationManager can eat text/plain (or other content-type)
rmb re-init serializer for it…
the default one like JSON very much … but i m not doing JSON …

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];

rmb add “file://” when using multipart form file
NSString *file = [[NSString alloc] initWithFormat: @”file://{file_address}];

Posted in mobile

[ios] debugger show nil 不用驚

check check 係咪 release mode, 或者 optimize 左 個 compiler …

Posted in mobile

import vamp into ios

put all library into a Vendors/VampPlugin folder
add -lstdc into build settings, other linker flags
edit the to “library” if needed
(dun add the simple host first)
comment the main a gXXx.c , since it crash the “main”
compile and goodbye

Posted in mobile

install harmtrace in linux

install haskell-platform
update cabal
cabal install HarmTrace

it will warn u no gsl
install gsl then

sudo apt-get install libgsl0-dev liblapack-dev

cabal install HarmTrace



harmtrace recognise –file=/Users/roychung/project/harmtrace/let_it_be.mp3 –mode=group –grammar=pop -o=/Users/roychung/project/harmtrace/output –log-dir=/Users/roychung/project/harmtrace/log –csv-dir=/Users/roychung/project/harmtrace/csv –sa-path=/Users/roychung/project/harmtrace/sonic-annotator –vamp-dir=/Users/roychung/project/harmtrace/vamp

in /Users/roychung/project/harmtrace/vamp need transform file
which is generate by sonic annotator

then it will say no sox

then sox want lame and mad (from readme)
install them

transform file is sth like :
$ sonic-annotator -s vamp:vamp-example-plugins:fixedtempo:tempo
@prefix xsd: <> .
@prefix vamp: <> .
@prefix : <#> .

:transform a vamp:Transform ;
vamp:plugin <> ;
vamp:step_size “64″^^xsd:int ;

vamp:block_size “256″^^xsd:int ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "maxbpm" ] ;
vamp:value “190″^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "maxdflen" ] ;
vamp:value “10″^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "minbpm" ] ;
vamp:value “50″^^xsd:float ;
] ;
vamp:output <> .

beat-tracker transform need change to 256 …
it has error about it, or u cannot generate the beat-tracker.txt

Posted in web

something about harmtrace on mac and ubuntu

i m going to install your harmtrace in my mac to make some chord file. but unluckily, i always got buildFail when linking to a package call hmatrix-gsl-stats-0.2

<... some loading package message above .. >
Loading package vector- … linking … done.

Loading package hmatrix- … linking … done.

Loading package hmatrix-gsl-stats-0.2 … linking … ghc:

lookupSymbol failed in relocateSection (relocate external)

/Users/roychung/Library/Haskell/ghc-7.6.3/lib/hmatrix-gsl-stats-0.2/lib/HShmatrix-gsl-stats-0.2.o: unknown symbol `_mean’

ghc: unable to load package `hmatrix-gsl-stats-0.2′

Failed to install HarmTrace-2.2.0

Updating documentation index /Users/roychung/Library/Haskell/doc/index.html

cabal: Error: some packages failed to install:

HarmTrace-2.2.0 failed during the building phase. The exception was:

ExitFailure 1

do u have idea to solve ?

i m in OSX 10.9

Roy Chung

Thx so much for u reading this email (though u dun solve my problem)


I just reinstall the whole things. and turn off “shared: False” in cabal config when face this linkage problem. This will turn off the linkage dynamic lib of apple , i think the problem is occur by here. And harmtrace can be succeed install.

And i try to install virtualbox and install an ubuntu image. It just install successfully and smoothly. (so i think linux is better … )

Posted in 編程

VM on mac for testing in ubuntu

box list :

Posted in 無分類, 編程

[ios] SEL

Posted in mobile

NSNotificationCenter, dispatchEvent and addEventListener d fd

Posted in mobile

[ios] audio conversion using AVAssetExportSession / AVAssetWriter from AVFoundation

Target : ipod library -> aiff / wav / caf (which eat by libsndfile (already ported to ios))

first, i think AVAssetExportSession can solve my problem due to this link:

but it is for converted-to-mp3 only (or converted-to-m4a)

(Trick :

Some points you need notice:
when you init AVAssetExportSession object, the “presetName” argument must be “AVAssetExportPresetPassthrough”.
The “outputFileType” may be “”.

And rename to mp3)

why i know it is for mov or m4a

if u write :
NSLog(@”export.supportedFileTypes : %@”,export.supportedFileTypes);

u will get:
exporter.supportedFileTypes : (

but it is only telling u these type exporter can convert
in api:
Not all presets are compatible with all assets.

So after i run
NSLog(@”%@”, [AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
2014-05-27 18:29:35.792 Jtab[1723:60b] (

only m4a is available (and mp3 using mov one)
whatever your ipod library song is mp3, m4a, wav (i tried)
so it is fail

And note that using AVAssetExportSession, the output extension is concerned, if type != extension will error

So i go to other solution AVAssetWriter:

wav example:

wav example:

caf example:


Easy AAC compressed audio conversion on iOS


But i think use AVAssetExportSession to m4a can solve the problem…,so TPAACAudioConverter is useless now

Posted in mobile

[go] getting start in mac local

GOPATH in ~/.bash_profile and GoSublime

Posted in web

[ios] custom font

Posted in mobile

wordpress starter theme

Posted in Blog

strong vs retain and weak vs assign and blah blah blah

After reading so many articles, SO posts and demo apps to check variable property attributes, I decided to put all the attributes information together:

atomic //default
strong=retain //default
assign //default
readwrite //default
Below is the detailed article link where you can find above mentioned all attributes, that will definitely help you. Many thanks to all the people who give best answers here!!

Variable property attributes or Modifiers in iOS

1.strong (iOS4 = retain )

it says “keep this in the heap until I don’t point to it anymore”
in other words ” I’am the owner, you cannot dealloc this before aim fine with that same as retain”
You use strong only if you need to retain the object.
By default all instance variables and local variables are strong pointers.
We generally use strong for UIViewControllers (UI item’s parents)
strong is used with ARC and it basically helps you , by not having to worry about the retain count of an object. ARC automatically releases it for you when you are done with it.Using the keyword strong means that you own the object.

@property (strong, nonatomic) ViewController *viewController;

@synthesize viewController;
2.weak -

it says “keep this as long as someone else points to it strongly”
the same thing as assign, no retain or release
A “weak” reference is a reference that you do not retain.
We generally use weak for IBOutlets (UIViewController’s Childs).This works because the child object only needs to exist as long as the parent object does.
a weak reference is a reference that does not protect the referenced object from collection by a garbage collector.
Weak is essentially assign, a unretained property. Except the when the object is deallocated the weak pointer is automatically set to nil
Example :

@property (weak, nonatomic) IBOutlet UIButton *myButton;

@synthesize myButton;
Strong & Weak Explanation:

Imagine our object is a dog, and that the dog wants to run away (be deallocated). Strong pointers are like a leash on the dog. As long as you have the leash attached to the dog, the dog will not run away. If five people attach their leash to one dog, (five strong pointers to one object), then the dog will not run away until all five leashes are detached. Weak pointers, on the other hand, are like little kids pointing at the dog and saying “Look! A dog!” As long as the dog is still on the leash, the little kids can still see the dog, and they’ll still point to it. As soon as all the leashes are detached, though, the dog runs away no matter how many little kids are pointing to it. As soon as the last strong pointer (leash) no longer points to an object, the object will be deallocated, and all weak pointers will be zeroed out. When we use weak? The only time you would want to use weak, is if you wanted to avoid retain cycles (e.g. the parent retains the child and the child retains the parent so neither is ever released).

3.retain = strong

it is retained, old value is released and it is assigned retain specifies the new value should be sent
retain on assignment and the old value sent -release
retain is the same as strong.
apple says if you write retain it will auto converted/work like strong only.
methods like “alloc” include an implicit “retain”

@property (nonatomic, retain) NSString *name;

@synthesize name;

assign is the default and simply performs a variable assignment
assign is a property attribute that tells the compiler how to synthesize the property’s setter implementation
I would use assign for C primitive properties and weak for weak references to Objective-C objects.

@property (nonatomic, assign) NSString *address;

@synthesize address;
share|improve this answer
edited Nov 14 ’13 at 8:25

Posted in mobile

cannot get position, or cell reuse animation cannot control

if u r doing AVAudioPlayer, and u grep currentTime, if u wanna has a more accurate time, it cannot do it … since it is quite discrete (for compress song like mp3) … so

CACurrentMediaTime() may help u

beginTime = CACurrentMediaTime()

… some animation …

animateTime = CACurrentMediaTime() – beginTime

so i have some value can calculate the view if the animation wanna pause in the middle

(too complicated animation recommend use CAKeyFrameAnimation)

Posted in mobile

storyboard want something to update by programming

override the setter :)

-(void)setKeyLabel:(UILabel *)keyLabel {
if (_keyLabel != keyLabel) {
_keyLabel = keyLabel;
_keyLabel.font = [UIFont fontWithName:@"AkzidenzGroteskBE-BoldCn" size:20.0f];

Posted in mobile

[ios] simple method to increase hitarea for a button

btn.frame = CGRectInset(btn.frame, -x, -y)


togglebutton.contentEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0); //set as your reqirement

Posted in mobile

[ios] KVO Key-Value Observing (咪即係 改 value -> dispatchEvent 器)

Posted in mobile

[ios] declare const

1. private

NSString *const SelectionSort = @”SelectionSort”;

2. public

extern NSString *const SelectionSort;
and in myfile.m define them

NSString *const SelectionSort = @”SelectionSort”;

It works, but only if you need a non global constant. Static constant is not visible outside the file. Otherwise use the 1st option.


The #define is a pre-processor macro. That means that it basically goes through your code and replace your macro with what you’ve defined.

If you use a const, it’s going to be a pointer to the string in memory. It’s way more efficient than having the same string being allocated wherever/whenever it is used.

To do that, you’ll need both .h and .m files. Your .h file will look something like:

extern NSString * const YOUR_STRING;
And your .m file:

NSString * const YOUR_STRING = @”your string”;

no need Class.THIS_IS_A_CONST , just THIS_IS_A_CONST then ok


會出現warning:(Sending ‘const NSString *__strong’ to parameter of type ‘NSString *’ discards qualifiers)
extern NSString * SelectionSort;
const NSString *InsertionSort = @”SelectionSort”;

extern NSString *const SelectionSort;
NSString *const SelectionSort = @”SelectionSort”;

Posted in mobile

UICollectionView 的心路歷程

project 是寫一個 guitar chord + music player
data 只有 那些 chord, 我的 project 就是要 用 cell 一格格的跟住音樂 著燈

1. using UICollectionView
problem 1: offset
因為我用了 endTime – startTime, 原來會累積 一些 error ,導致後面不準

problem 2: UICollectionView reloaditemsAtIndexPath 有 animation 在閃
求其 set 了 就繼續做
[UIView setAnimationsEnabled:NO];

到第一個 deadline : 發現這兩問題

首先要解決閃的問題,因為 setAnimationsEnabled:NO 會令到 needle (音樂器的秒數指標)

solution 1 : 用了 PSTCollectionView ,改 src code, 熄了那 .3 的 animation
所以轉了第二個 function

用 reloadData , 其實是整幅 cells reload
壞處是不能有 animation 在其中,不斷 call 的話,scroll 也不能
visibleCells 也有不準的情況 (其實放在 reload 前 就會o岩了)

offset 問題,本想用 ticker 可處理
每 0.01 秒去 發 notification 和 cells 對話
cells 轉自己的 isCurrentChord = YES 同埋
call delegate (viewController) 話邊粒係 current
本應很好,但 0.01 秒去 call 一個 reload function
call reloadData 還好,call reloaditemsAtIndexPath 簡直炒晒
因為 refresh 得太密, scroll 要自己設計,click 亦不能,此路不通

solution 3 : 返回基本步,用 UICollectionView ,仍覺得閃可以解決,使用了
[UIView animateWithDuration:0 animations:^{
[collectionView performBatchUpdates:^{
[collectionView reloadItemsAtIndexPaths:indexPaths];
} completion:nil];

needle 仍舊不能動

好友提議下,將 endTime – startTime 改成 currentCell.startTime – musicPlayer.currentTime 做 timer interval
currentIndex++ after one timer trigger

offset 問題解決了,誤差不會再 stack 上去, 就算有誤差,都係本身一個 cell 的極少誤差

reloadItemsAtIndexPaths 不能用,唯有用 relaodData
注意 reloadData 係 async 的
亦 rmb use layoutIfNeeded 去 trigger update
但因為無用 ticker, 小心處理動畫問題,用起上來蠻方便的

Posted in mobile

[ios] view init some view

-(void)setFrame:(CGRect)frame {

[super setFrame:frame];

// do yr graphics stuff here


Posted in mobile

list 內 的 hyperlink 不能 preventDefault

Posted in web, 無分類

jquery know user view the element

using 3rd party plugin (same concept as calculating the offset)


Posted in web

[magento] the only way that can getimageurl from categroy

Posted in web

[magento] catalog product widget


Posted in web

[magento] some important file

read the following file can know more about the route and flow

store/app/code/core/Mage/Core/Controller/Varien/Front.php <== front controller
store/app/code/core/Mage/Core/Model/App.php <== (Main) App Model (Object)

about REFERENCE : 即係跳 block 專用技

Diagram 3

is used to make reference to another block. By making a reference to another block, the updates inside will apply to the it correlates to (see diagram 3).

In order to make the reference, you must target the reference to a block by using the ‘name’ attribute. This attribute targets the tag’s ‘name’ attribute. So if you were to make a reference by , you’re targeting the block called .

Posted in web

[magento] debugging ? open css hint

need some tricks:

Categories: Blog, Magento
Developing in Magento without these debugging tips can be challenging! Here is how you can debug magento:

Turn on Template Path Hints
Turn on error/system logging
Turn on SQL logging
Display PHP errors

Turn on Template Path Hints

Would you like to see the path of the file that is producing the HTML for each block on the page?

1. Log into the admin

2. Goto -> System ->Configuration, and on the bottom of the list select “Developer”

3. click on Debug – you will only see “Profiler”. Here is the trick – you have to switch the “Current Configuration Scope:” [in the upper left] to a website instead of default. Select “Main Website”.

4. Now you will see the selection for Template Path Hints – check yes. This will display the path of the template for each block of the page so you can find stuff! You can also choose to “Add Block Names to Hints” to see the corresponding model class for the block.

Turn on error/system logging

1. In the admin Goto -> System ->Configuration, and on the bottom of the list select “Developer”

2. Select the Log Settings tab and put Enabled = Yes

3. *to avoid any permissions issues, create folder/file


Turn on SQL logging

To enable SQL Debugging find the file


change line 45
protected $_debug = false;

protected $_debug = true;

It will then generate the file var/debug/sql.txt.

*If you have any issues create this file manually first…

Display PHP errors

Frustrated you can’t see your PHP errors? This is how you turn them on – for development use only, don’t do this on a production site!

In Index.php change


ini_set(‘display_errors’, 1);

Posted in web

flat icon 素材

Posted in 設計

mac freeze login steam

You should now be able to see the Steam folder, and the registry.vdf file inside that. Simply rename the file, or delete the full stop so that Steam doesn’t recognise the file (you can delete the file, but best to rename first as if this fails, you might want to be able to revert back).

Once the file has been renamed, you should be able to start up Steam and get back online. Note: if the above fails, try following all of the steps again but rather than starting up Steam, re-install it instead.

Worked for me – I’m now back online.

Posted in 無分類

get sharedpreferences from android

Posted in mobile

Accessing Windows system variables in Java 1.4

Posted in 編程

正野 mobile game tutorial

Posted in mobile

Cocos2D-X Tutorial for iOS and Android: Space Game

Posted in mobile

rhythm game tutorial in JAVA

Posted in 編程

android timer, or ScheduledThreadPoolExecutor

threadPoolExecutor = new ScheduledThreadPoolExecutor(1);
		threadPoolExecutor.scheduleAtFixedRate(new Runnable() {
			public void run() {
		}, 0, 1, TimeUnit.MINUTES);
t = new Timer();
		t.schedule(new TimerTask() {			
			public void run() {
		}, 0, 60*1000);
Posted in mobile

php return_array()[0] <== 唔得的解決方法

Posted in 無分類

multiple domain to subfolder htaccess rewrite

RewriteEngine On
RewriteBase /

# —————————————
# BEGIN Domain to folder mapping

# pointing to folder_1
ReWriteCond %{HTTP_HOST}
ReWriteCond %{REQUEST_URI} !so9sad/
ReWriteRule ^(.*)$ so9sad/$1 [L]

# pointing to folder_2
ReWriteCond %{HTTP_HOST}
ReWriteCond %{REQUEST_URI} !youtube9loop/
ReWriteRule ^(.*)$ youtube9loop/$1 [L]

# END Domain to folder mapping
# —————————————

# —————————————
# BEGIN htaccess pretection

order allow,deny
deny from all

# END htaccess pretection
# —————————————

With wordpress:

RewriteEngine On
RewriteBase /

# —————————————
# BEGIN Domain to folder mapping

# pointing to folder_1
ReWriteCond %{HTTP_HOST}
ReWriteCond %{REQUEST_URI} !folder_1/
ReWriteRule ^(.*)$ folder_1/$1 [L]

# pointing to folder_2
ReWriteCond %{HTTP_HOST}
ReWriteCond %{REQUEST_URI} !folder_2/
ReWriteRule ^(.*)$ folder_2/$1 [L]

# END Domain to folder mapping
# —————————————

# —————————————
# BEGIN WordPress

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
# —————————————

# —————————————
# BEGIN htaccess pretection

order allow,deny
deny from all

# END htaccess pretection
# —————————————


Posted in web

Twitter User Search Document

Posted in web

抄到佢仆街 電擊文庫 layout

Posted in web

gaplo 推薦 素材網

Posted in web

free music loop (chris recommend)

Posted in web

footer stick to height

Posted in web

iphone app beginner

Posted in mobile

photoshop script read write file

Posted in graphics

about viewport, when u do mobile

Posted in 手機

ableton live some useful features

slice to midi = slice the selected sound track into yr drum rack
quantumize = crop and fit in a box in midi piano

Posted in music

jquery template

Posted in web

a jQuery dynamic layout plugin

Posted in web

整 drop down menu 必看

Posted in web

廣告公司 可試

Posted in 創業

好靚的 design studio 出品

Posted in 藝術

Mobile browser detection for WordPress – embedded is_mobile() function

Posted in web

[靚] Brands Icons And Color Style Guides

Posted in web

好靚既 db 素材

Posted in graphics

回帶睇完又睇, php 30 common tips (u always forget)

Posted in web

Using Dynamic Font with canvas using Typeface.js

Posted in web

icon for social network

Posted in graphics

Dynamic loading of Facebook Comments Plugin throwing JS error in IE 6/7/8

Posted in web

PHP pass by indenifier?

all pass by value expect object pass by reference,  but specificy say it is pass by idenifier. 

since when u assign a var is object,  it is forever object …. until u using ‘&’ to pass it by refenerce to change it.

ref link:  http://

Posted in 無分類

php and mysql time conversion

Posted in web

LEARN PadControl


Posted in music

fb logout by php

Posted in web

cscart php hook advance using (like adding search field before SQL)

Posted in web

how to override a skin / template

Posted in web, 編程

Hiding Product tabs in Admin

Posted in web

又有 icon !

Posted in graphics

apache rewriteCond 的小知識

Posted in web

[android] center a drawText

For y :

int yPos = (int) ((canvas.getHeight() / 2) – ((paint.descent() + paint.ascent()) / 2)) ; //((textPaint.descent() + textPaint.ascent()) / 2) is the distance from the baseline to the center.

For x :

Posted in 手機

knob code scriptlet

Posted in mobile

Solve WebView problem


add this back 有discuss

try this, turn off the alpha channel (no use)

more ref, and have many hints !

change to translateX (try)

or read this

add this
-webkit-overflow-scrolling: touch;

change RenderPriority and CACHE SETTING (try)!topic/android-developers/4YATUvb-t68

try large heap true (try)

change all png to jpg
(no transparency channel in yr app)

Posted in mobile

smooth transition trial

1. try webkit back face visibility hide
2. try the slide animation time is linear ie deltaX * 10ms, but not diff distance but same time
3. try window.location.href = “#body” to do a fast auchor

good luck

Posted in mobile

very good free icon, can fight with wp-zoom


Posted in 無分類

Swipe for mobile

Posted in web

jquery change page

Posted in 無分類 d layout

function enhance

layout framework

Posted in web


Posted in web

活用 CI log to know a model is loaded

You can use the log_message() function and put it in the constructor, so it will be executed when it initiated

Put this in your model’s constructor (parent::Model())

log_message (“debug”, “Yourmodel is loaded”);
don’t forget to set the log config to debug mode, see the config.php file

$config['log_threshold'] = 2;
And set the system/logs directory permission to writable (by default CI will create the log files here)

or set the logs directory in another dir

$config['log_path'] = ‘another/directory/logs/’;
CI will then create the log file in the directory. monitor the log files as you like. You can get the debug message to see if your model is already loaded or not in the log files.

src :

Posted in web

wp solve break line problem

Posted in web

codeigniter x fb connect

Posted in web

ad by google for android

Posted in mobile, 無分類

mobile native app wrapper for js and html

Posted in web

take html for wp content

Posted in web

phonegap on scratch

Posted in mobile


Posted in web

%2F 係 browser url 到照當 “/”

Posted in web

jquery wheel [good]

Posted in mobile, web

jquery 中間個 wheel

Posted in mobile

jquery 摔左摔右 plugin

Posted in mobile


Posted in mobile

going to extend the controller in CI

Posted in web

html5 ebook framework for iphone

a tutorial about e magazine in mobile

Posted in mobile, 編程

simple login of CI

Posted in web


Posted in 電子

加點點落d 圖到,low res 都唔驚

Posted in web

ie9 web font …

Posted in web

free icon again

Posted in graphics

quite good example of mvc

Posted in web

右 click 之 menu

Posted in web

[codeigniter] load model , want parameter

Posted in web

Which method is best to select values present in one table but missing in another one?

Posted in 編程

DIY CD cover

Posted in 藝術

ulikela and fdpayforme

$0.1 – $1 侮辱及讚賞

just buy our product to solve the debt!

Posted in IDEA

Learning JavaScript Design Patterns ( a good book should read )

Posted in web

MIME does not mean anything … just check the stupid extension …

Posted in web

Camera 搵物器

idea: y dun we mark down … using camera to store and locate the stuff

Posted in IDEA

use gettext to set the language of php

command “locale -a” to check the lang code set
rmb zh-HK , 細階細階-大階大階

Posted in web

click input file for firefox

$(“#uploadImg”).click(function(e) {

but it may fail for IE

Posted in web

Check browser can drop and drop files

Posted in web

JS public private static

Posted in web, 編程

[IDEA] 太陽可能是核聚變發電站失誤而成的

火星可能是 核聚變災難後的星球, 所以以前有生命跡像


Posted in IDEA

web font to css

Posted in web

save me time ! solve BeanCreationException for TilesConfigurer

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’tilesConfigurer’ defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.view.tiles2.TilesConfigurer]: Constructor threw exception;


add this dependencies to solve :

Posted in web, 編程

Using tile to define layout

Posted in web

a good tutorial to start spring web mvc

Posted in web

flex library very good, wirte flex application 必備

Posted in AS3

cloudflare , suggest server service

Posted in web

[素材] many icons

Posted in web

unable to bind to property的解决办法

see lower for better solution

Posted in AS3

good psd for web design

Posted in web

Flex alert no button, answer 2 work

Posted in AS3

[flex] drag drop using list, very quick dev!

Posted in AS3

Learn cairngorm, framework of flex

Posted in AS3, 編程

why SwiftSuspenders and use Inject

Posted in AS3, 編程

Embed movieClip in flex, on9, u will get error

//[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert tex_main_menu@6921e21 to flash.display.MovieClip.

solution 1 : use sprite


solution 2 : add one more frame in sprite , then it is movieClip

Posted in AS3

[robotlegs][flex] capture the event in command , so i can get the data which is bring by event

Posted in AS3

study 下 swiftsuspenders [as3][flex]

Posted in AS3

FLEX module的使用(转载)

1 ModuleLoader组件概述



1.3 ModuleLoader类的继承关系

* IModuleInfo – module接口,所有的module都实现了此接口,可以提供module信息,比如url 和 加载状态。
* Module – 基于MXML的module的基类
* ModuleBase –基于ActionScript的module基类
* ModuleManager –一个系统只有一个此类,用于管理所有动态加载的module
* ModuleEvent – module相关事件

1.4 相似组件


ModuleManager类提供了低层次的处理Module的装载卸载以及事件响应等方法。这种方式比起纯粹的 ModuleLoader方式稍微复杂一点,但是ModuleManager提供了比ModuleLoader更加强大的能力来管理Module模块的加 载过程。


[3] Flex Modules .

2 ModuleLoader常用属性和方法
@font-face { font-family: “宋体”; }@font-face { font-family: “@宋体”; }p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 10.5pt; font-family: “Times New Roman”; }div.Section1 { page: Section1; }
String类型。要加载的外部MXML module 的url.,详见例3.1和例3.2
格式:loadModule (url:String = null, bytes:ByteArray = null):void
当module已下载(通过info()函数访问),但module并没有加载完成时(not ready)派发

3 ModuleLoader使用方法
3.1 通过URL自动加载module和Alert使用举例


import mx.managers.PopUpManager;
private var pop:PopUpManager=new PopUpManager();


(2) creationComplete事件表示,当加载完成时,将当前应用程序的域赋给module1,这个语句可以不加,为防万一,最好加上。

protected function openAlert_clickHandler(event:MouseEvent):void
{“欢迎”, “欢迎点击Alert”, Alert.OK, this);


函数说明:loadModule (url:String = null, bytes:ByteArray = null):void

public function loadModule21():void
mod_loader.url = “example/ModuleExam21.swf”;
public function loadModule22():void
public function unload():void
mod_loader.url = null;//注意,卸载完成后必须设置URL为null,否则内存泄露

(2) mod_loader.url = null;必须在卸载完成后加上,否则内存泄露


3.3 module常用事件举例

protected function mod_loader_errorHandler(event:ModuleEvent):void
lbRecord.text=lbRecord.text+”\n error:”+event.module.url;
protected function mod_loader_readyHandler(event:ModuleEvent):void
lbRecord.text=lbRecord.text+”\n ready:”+event.bytesLoaded+”bytes:”+event.bytesTotal;
protected function mod_loader_progressHandler(event:ModuleEvent):void
lbRecord.text=lbRecord.text+”\n progress:”+event.bytesLoaded+”bytes:”+event.bytesTotal;
protected function mod_loader_unloadHandler(event:ModuleEvent):void
lbRecord.text=lbRecord.text+”\n unload:”+event.bytesLoaded+”bytes:”+event.bytesTotal;

3.4 Application调用module中的方法举例


private function getTitle():void {
s = (m1.child as ModuleExam4).getModTitle();

public function getModTitle():String {
return “Child Module 1″;
(m1.child as ModuleExam4).getModTitle(),表示将m1中的属性child对应的对象强制转换为ModuleExam4类,再调用这个对象的方法。


3.5 通过ModuleLoader的URL向module传递参数举例

public function submitToModule():void {
var s:String = “example/ModuleExam5.swf?”
+ “firstName=” +ti1.text + “&lastName=” + ti2.text;
m1.url = s;

var myPattern:RegExp = /.*\?/;
var s:String = this.loaderInfo.url.toString();
s = s.replace(myPattern, “”);
// 通过&拆分成数组name=value,保存为String类型数据
var params:Array = s.split(“&”);
// 显示数组中各个元素的值
var keyStr:String;
var valueStr:String;
var paramObj:Object = params;
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
ta1.text += keyStr + “:” + valueStr + “\n”; //keyStr的值为0。1.2…
// 通过=拆分各个元素,并保存到变量salutation中
for (var i:int = 0; i < params.length; i++) {
var tempA:Array = params[i].split("=");
if (tempA[0] == "firstName") {
o.firstName = tempA[1];
if (tempA[0] == "lastName") {
o.lastName = tempA[1];

对于Module模块和Application对象间的通信,可以定义一个ActionScript接口,Module模块对象实现了这个接口中定义的方 法和属性,那么Application就可以访问这个接口中定义的属性和方法。接口中定义了Module模块对象和Application需要共享的数据 和方法,是两者间共同的一个契约,同时也实现了接口和实现的分离,达到了松耦合的目的。

public interface IModuleInterface extends IEventDispatcher {
function getModuleName():String;
function setAdjusterID(s:String):void;
function setBackgroundColor(n:Number):void;

layout="vertical" width="60%" height="60%">
public function setAdjusterID(s:String):void {
adjuster = s;
public function setBackgroundColor(n:Number):void {
bgcolor = n;
public function getModuleName():String {
return “module Insurance”;

private function applyModuleSettings(e:Event):void {
// m1.child 是接口IModuleInterface的具体实现对象
//var ichild:* = mod.child as IModuleInterface;
var ichild:IModuleInterface = m1.child as IModuleInterface;
if (m1.child != null) {
currentModuleName = ichild.getModuleName();

3.8 Module与Module之间数据交互举例



public var m1:String=”module1″;
public function getProperty(event:MouseEvent):void {
public function getMethod(event:MouseEvent):void {


public var m2:String=”module2″;
public function getModuleName():String {
return lbmodule2.text;



Flex Modules .

3.9 applicationDomain属性举例
ApplicationDomain 类是一个容器,用于管理不同swf的安全域和类之间的关系。它们允许同一个类存在不同的ApplicationDomain。
ApplicationDomain是一个树形结构,Application所在的域(以下简称主域)就是它唯一的子域,使用Loader类加载swf时可以通过指定ApplicationDomain 参数将swf加载到不同的域(Domain)。
ApplicationDomain最根部的是系统域(system domain),主程序所在的域(以下简称主域)就是它唯一的子域。SWF 文件中的所有代码被定义为存在于应用程序域(ApplicationDomain)中。主应用程序在”当前域”中运行。”系统域”中包含所有应用程序域 (包括当前域),也就是,它包含所有 Flash Player 类。

有两种方式可以访问 ApplicationDomain :

虽然 ApplicationDomain有个 parentDomain 属性,但子域已经自动获得了父域的类定义,所以通过 ApplicationDomain.currentDomain 就可以获取父域定义了——包括主程序和加载到主域的共享库。(注:系统域不可直接访问,主域和所有新域即系统域子域的parentDomain属性为 null)

此方式可以访问任何方式加载的swf的 ApplicationDomain。对于主程序来说,加载到同域的库定义已经存在于 ApplicationDomain.currentDomain ,而模块的类主程序一般用不到。所以这种方式个人不推荐使用。
使用Loader类加载swf时可以通过指定 ApplicationDomain参数将swf加载到不同的域(Domain):
var loader : Loader = new Loader();
var context : LoaderContext = new LoaderContext();
/* 加载到子域(模块) */
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
/* 加载到同域(共享库) */
context.applicationDomain = ApplicationDomain.currentDomain;
/* 加载到新域(独立运行的程序或模块) */
context.applicationDomain = new ApplicationDomain();
loader.load(new URLRequest(“loaded.swf”), context);

context.applicationDomain = new

(2)加载到同域(RSL) —参见图中的用法B
context.applicationDomain = ApplicationDomain.currentDomain;

(3)加载到新域(独立运行的程序或模块) —参见图中的用法A
context.applicationDomain = new ApplicationDomain();
loader.load(new URLRequest(“loaded.swf”), context);

好处就在于,卸载一个加载到子域的模块时,只要确保清除所有到该模块的引用,模块的所有类定义将被垃圾回收(Garbage Collection)。


1. Flex 中ApplicationDomain.
2. flash 中的 ApplicationDomain .
3. AS3应用程序模块化开发与ApplicationDomain .

3.10 module中使用PopUpManager和DragManager异常说明
通常将module加载为主域的一个子域,module里面的类都不属于主域的。比如第一个module载入了类PopUpManager,那么整合到 Application中,它就成了PopUpManager的拥有者,因为像这种manager都是单例的,如果另外一个模块稍后要使用这个 PopUpManager,就会引发运行时异常。
import mx.managers.PopUpManager;
import mx.managers.DragManager;
private var popUpManager:PopUpManager;
private var dragManager:DragManager;

这项技术同时也被应用到组件中,当module第一次使用组件时,将在它自己的域中拥有这些组件的类定义。如果别的module试图使用这些已经被另一个 module使用的组件,它的定义将会不能匹配到现存的定义中。因此,为了避免组件的定义不匹配,在主应用程序中创建组件的实例,让所有的module去 引用。
但是这个坏处很明显,这些声明看起来莫名其妙,成为了一个个”木偶变量”。另一个解决方法是借助 ApplicationDomain 来共享这些代码和资源。在ModuleLoader 的creationComplete方法中加入moduleLoader.applicationDomain = ApplicationDomain.currentDomain; 表示将其加载到运行时库。对于使用ModuleManager,则可以在IModuleInfo的load方法里指定域。


Posted in AS3

Flex, Mate, Modules and GC – another approach

Posted in AS3

Using JavaScript’s Prototype with MVC

Posted in web

Dump for as3

Posted in AS3

When to new your model?

you dun need actually
public class AuthorModel extends Actor
private var _list:Array;

public function get list():Array
return _list;

protected function initializeList():void
var twain:Author = new Author(“Twain”);
var poe:Author = new Author(“Poe”);
var plato:Author = new Author(“Plato”);
var fowler:Author = new Author(“Fowler”);

twain.quote = “Why, I have known clergymen, good men, kind-hearted, liberal, sincere” +
“, and all that, who did not know the meaning of a ‘flush.’ It is enough ” +
“to make one ashamed of one’s species.”;
fowler.quote = “Any fool can write code that a computer can understand. ” +
“Good programmers write code that humans can understand.”;
poe.quote = “Deep into that darkness peering, long I stood there, wondering, ” +
“fearing, doubting, dreaming dreams no mortal ever dared to dream before.”;
plato.quote = “All things will be produced in superior quantity and quality, and with greater ease, ” +
“when each man works at a single occupation, in accordance with his natural gifts, ” +
“and at the right moment, without meddling with anything else. “;

_list = [twain,fowler,poe,plato];

got it ?

Posted in AS3

solve module load in flex, getStyle problem

Flex App 直接引用外部 Module 的問題
最近同事遇到一個 Flex 問題,只要 Module 內放了其它組件
執行就會出現各種奇怪 Error
後來發現是因為在 Main Application 直接引用編譯到 Module Class
然後又企圖用 ModuleLoader 再載入一次相同的 Module SWF
當然這樣做是錯誤的範例,Flash Builder 也會給予警告

Warning: Mod is a module or application that is directly referenced.
This will cause Mod and all of its dependencies to be linked in with MainApp.
Using an interface is the recommended practice to avoid this.


譬如以下的例子 MainApp.mxml



直接引用到外部 Module,又企圖載入一次同一個外部 Module – Mod.mxml

width="100%" height="100%">

隨著 Module 內放置組件不同,可能會得到以下各種錯誤訊息

Main Thread (Suspended: ArgumentError: Error #2004: 有一個參數無效。)
flash.display::Graphics/drawRect [no source]

Main Thread (Suspended: TypeError: Error #1009: 無法存取 Null 物件參考的屬性或方法。)
mx.core::UIComponent/get horizontalCenter
Flex ModuleLoader 預設載入外部 Module 時
是會從目前 ApplicationDomain 建立一個 child ApplicationDomain 作為載入之用
也就是說假如 Main App 已經包含一份 Module 定義
實際上,被 new 出來的實體其實是 Main App 內定義的

問題就是出在這裡了,用 ASV 分別去觀察兩個 SWF 內的 Module 類別

當 Flex Module 編譯為獨立 SWF 時
MXMLC Compiler 會塞入一些額外的 Metadata Tag, Code… 做初始化
可是 MainApp 內的 Module 定義少了這些動作,導致無法正常執行

解決的方式不難,ModuleLoader Ready 時
自己手動執行一下關鍵的初始動作就好了 – styleManager.initProtoChainRoots();



ready=";" />

Posted in AS3

robotlegs in module, 3 種方法解決


裝呢個 addon, 共用同一個 injector,
但不能使用 module loader

min code of this method


可以 dynamic 了,但其實是將 module 的 applicationDomain hardcore 同 mainApp 一樣


一人一個獨立 robotlegs,但要 hack 少少 code 先做到,其實都係 override 下 je :)

Posted in AS3

asynchronous-processes-and-robotlegs [READ pls]

Posted in AS3

change the stupid namespace from flashdevelop default template of mx


It state is halo, if u dun change
or u cannot use canvas blah blah blah

Posted in AS3

get URL by loaderInfo or BrowserManager

for loaderInfo , pls see the comment

Posted in AS3

RIA free ebook

Posted in 編程

flex 3 in flex 4

Posted in AS3

advanced use module in flex, in enterprise scare

Posted in AS3

new IDE , try !

Posted in 編程

compile module with flashdevelop and some tutorial about modules


Posted in AS3

using flashdevelop to compile module

Posted in AS3

Flex Problem

急急。。。Flex4 Module中不能Alert?


A flex code example using module

Create an ActionScript-Based Module

Posted in AS3, 無分類

good comment in a flex problem

Posted in AS3

eshop sample

Posted in 無分類

keep-generated-actionscript -> mxml to as3

Posted in AS3

Must read for deploy AIR on playbook

Posted in mobile

js object and js function class

var yung = { variable : xxx, add: function () { } }

they are all accessible by other

yung.Class = function(someSetting) {

var privateVar
function privateFunction
function publicFunction

//public function
$.extend(this, {
publicFunction: publicFunction

yung.obj = new yung.Class(someSettings);



(function(object1, jquery, window, settings) {


})(object1, jquery, window, settings);

Posted in web

unload module effectively FLEX

Posted in AS3

[FLEX] modular robotlegs !

Posted in AS3

view states using AS3 only, no mxml

Posted in AS3

flex minimal

Posted in AS3

very good tutorial for deploy blackberry playbook app

Posted in mobile

blackberry debug token

About Configuring your application

About tablet xml

Posted in mobile

openGL tutorial recommend by jimmy

Posted in algorithm, 編程

playbook ref

FlashDevelop and BlackBerry PlayBook Development: The Basics

Tools port AIR -> playbook

Debug token (on simulator)

Posted in mobile

git 之速查

Posted in 編程

as3 funny class as function, use a function to return a Class

Posted in AS3

trick on as2

dynamic new a movieClip with init var

WORTH to read, many FAQ about as2

event receive and dispatch and delegate example

hope example help

reference will be missed at first explanation

EventDispatcher instantiate methods

container constructor first -> button constructor
container constructor want to call button stuff, but button hvnt construct

Posted in AS3

open source as2 compiler

Posted in AS3, 編程

seems very good play:Set up a home file server using FreeNAS

Posted in web

Prestashop, a eshop framework

Posted in web

zend form tutorial

the tutorial is a bit old, may not suit yr need , but can do ref

Posted in web

zend : view helper for js and css

Posted in web

Free icon 素材 again :)

Posted in graphics, 設計

cron job 既朋友 for windows

Posted in web, 編程

iframe jquery (no cross domain by browser … )

Posted in web

SD card 救 相

Posted in 軟件介紹

actually wt i want project

Posted in web

quick start of zend framework

Posted in web

wtf bitmapData

SWF 13+ (Flash Player 11, AIR 3) the practical limit is the amount of memory available. (The theoretical limit to width or height is the largest positive integer — divided by 20 to allow for twips, but you will hit memory limits long before reaching this size.)
SWF 10 (Flash Player 10, AIR 1.5) the maximum size for a BitmapData object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels wide, it can only be 2,048 pixels high.)
SWF 9 (Flash Player 9, AIR 1.1) the limitation is 2,880 pixels in height and 2,880 pixels in width. If you specify a width or height value that is greater than 2880, a new instance is not created.

Flash Player 11 is very good :)
Flash Player 10 need alchemy :(
Flash Player 9 no byteArray, so no need think of playing dynamic image processing :((

Posted in AS3

WTF Flex 4.5.1 eat shit SDK for UIComponent

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()
at fl.controls::LabelButton/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::ScrollBar/draw()
at fl.core::UIComponent/callLaterDispatcher()

I know u meet this error

i know you read this:

or this

but still cant play the UIScrollbar
What i think is, i the past, i use this method still can use, i think it is the issue of flex sdk, okok,

i got it

// trick to bring in the skins for the button
sb.setStyle( “ScrollArrowDown_downSkin”, new ScrollArrowDown_downSkin());
sb.setStyle( “ScrollArrowDown_overSkin”, new ScrollArrowDown_overSkin());
sb.setStyle( “ScrollArrowDown_upSkin”, new ScrollArrowDown_upSkin());
sb.setStyle( “ScrollArrowUp_disabledSkin”, new ScrollArrowUp_disabledSkin());
sb.setStyle( “ScrollArrowUp_downSkin”, new ScrollArrowUp_downSkin());
sb.setStyle( “ScrollArrowUp_overSkin”, new ScrollArrowUp_overSkin());
sb.setStyle( “ScrollArrowUp_upSkin”, new ScrollArrowUp_upSkin());
sb.setStyle( “ScrollBar”, new ScrollBar());
sb.setStyle( “ScrollTrack_skin”, new ScrollTrack_skin());
sb.setStyle( “ScrollThumb_downSkin”, new ScrollThumb_downSkin());
sb.setStyle( “ScrollThumb_overSkin”, new ScrollThumb_overSkin());
sb.setStyle( “ScrollThumb_upSkin”, new ScrollThumb_upSkin());
sb.enabled = true;
sb.visible = true;

add this, where sb is the scrollbar object :)

Posted in AS3

by pass as3 8191px problem

Core Concept : Dun draw in bitmap

in urUploader, Thumbnail can over 8191px, loadBytes is according to file size, so if file size too large, yr machine will hang.

private function genThumbnail():void {
			var l:Loader = new Loader();
			l.contentLoaderInfo.addEventListener(Event.COMPLETE, onThumbnailComplete);
		private function onThumbnailComplete(e:Event):void {
			var b:Bitmap = MCUtil.scaledImage(Bitmap(, new ThumbnailLayout().width);
			var data:Object = { uploadJob : this };
			dispatchEvent(new UploadJobEvent(UploadJobEvent.THUMBNAIL_GENERATED, data));

This is the scale function, so after scale to small size, now can draw :)

public static function scaledImage(bd:BitmapData, s:Number = 120) : Bitmap
            var newWidth:Number;
            var newHeight:Number;
            var result:BitmapData;
            var bitmap:BitmapData = bd;
            var size:Number = s;
            var matrix:Matrix = new Matrix();
                if (bitmap.width > bitmap.height)
                    newWidth = size;
                    newHeight = bitmap.height * (size / bitmap.width);
                    newHeight = size;
                    newWidth = bitmap.width * (size / bitmap.height);
                matrix.scale(newWidth / bitmap.width, newHeight / bitmap.height);
                result = new BitmapData(newWidth, newHeight);
                result.draw(bitmap, matrix);
                return new Bitmap(result);
            catch (e:Error)
                trace("Scaled image error");
            return null;
        }// end function

ref: photobox photobook program

Posted in AS3

alchemy error : if range invalid …


4. Sep 23, 2010 5:30 AM (in response to boris.reitman)
Re: Range Error 1506 when CLibInit.init()
Dont init CLibInit twice. Insted use static value to hold it for reuse and refer to it. Worked for me.

Posted in AS3

js 放係 head,speed up 個 load .js 既 process

Posted in web

regular expression tester

Posted in web

ref of fdpayforme

look and feel, font

Posted in web

The best oldies

Posted in music

start up js and css framework

Posted in web, 編程

jpeglib encode decode example

here is a good tutorial for using jpeglib to do decode and encode. It states the usage of some common parameter of decode and encode.

Posted in C++

compile ijg, alchemy issue

Posted in algorithm

read write bytearray use in alchemy

Posted in AS3

alchemy gluegen : link C library to as3 :)

Posted in AS3

advance alchemy article : about memory

Posted in AS3

gstate: alchemy memory

Posted in AS3

super strong flash guy

Posted in AS3

ijg jpeg rare tutorial

this one is really good example :)

this one also :)

Posted in C++, 編程

alchemy, libjpeg ref

日文翻譯文,教你裝同 run


教你用 libjpeg


config alchemy

how to include jconfig.h, jpeglib.h …

using alchemy to do bubble sort

Posted in AS3

simple explanation on bytecode

AS3 -> ABC (bytecode) -> AVM (Flash player) -> Windows, Linus, Mac…
落 bytecode 等唔同 OS 既 VM 都行到,但 點解唔直行 AS3 要 compile 落 bytecode ,因為你寫d 野太7 ,變做 While Loop,改你d var, function 名 改短d 靚d 好過 :)

Posted in algorithm, 編程

setup alchemy environment

Posted in AS3

Potrace Transforming bitmaps into vector graphics

alchemy version:

Posted in algorithm

Good Grid design for frontend

Posted in web, 無分類

Super strong as3 developer! see his project for some hints to difficult problem

Posted in AS3

event driven in java and IBM java theory and practice column

Posted in algorithm, 無分類

alchemy IJG investiage

- find find wt is beginEncodeJpegFileToPixsense, Pixsense encode …. ummm

Posted in web

js design pattern for beginner

Posted in web, 無分類

as3 <--> bridge <--> as2

Posted in AS3

gordon recommend CSS engine

Posted in web

flash is suck in urlStream or fileRef.upload

urlStream is always good, it trigger the browser request to server, but very raw and cannot detect the upload progress (no progress event fire during upload) ( cal the speed and use Timer to pretend the progress bar )

but fileRef.upload is really poor, it use its user agent, so it is independent to browser, so no session can be save, it make a new session i think

judge yourself use which class then :)

Posted in AS3, web

css framework (but ruby :( )

Posted in web

skype development ref

@ww_boy6 roy:
this can help ?
actually they think so 麻煩 becoz they want to do VOIP
but we only need msg
u see this web app can do skype

for ww

Posted in web

Freeware multi-platform file splitters

Posted in web

read this post for shopping cart in Zend, can use library or write yr own

Posted in web, 創業

網上 Q&A 平台 ,o岩細站用

Posted in 創業

URL request in Flash

IE -> 用 domain 做 base-path
Firefox, chrome -> 用 swf 個 file 個 location 做 base-path

okok, 唔好煩,用死 absolute path, server_url + relative_url 好無 ?

Note Update :

用呢個 “.” d swf location 就會係 swf 個個位置

Posted in AS3

wordpress localization step 1

Posted in web

supreme strong image processing class present by alchemy

Posted in web

html5 and music

Posted in web

study this uploader!

Posted in web

jquery ui bridge tutorial

Posted in web

let’s try to write Jquery UI widget

Ok, this one is better

Posted in web

jquery .add

.add is a function tht “add” the selector into jquery object list. This add is not mean append.

Posted in web

ext core, try this js framework

Posted in web

basic knowledge to VBscript

ms tech note

return is a object

Posted in web

[plupload] about resize and upload



SWF size limit

Posted in web

在 ASP.NET中使用 Include語法

Posted in web

[mysql] 複製一個 db

Posted in web

share box


Posted in web

as2 or other graphics technique, set Bounds in short code

if (_bounds != undefined) {
mc._x = Math.max(_bounds.xMin, Math.min(mc._x, _bounds.xMax));
mc._y = Math.max(_bounds.yMin, Math.min(mc._y, _bounds.yMax));

Posted in AS3

wp 必讀

language :

writing plugin:
o岩o岩開波d format :
action/filter default hook:

hook list with src:

Posted in web

as2 can do addEventListener and dispatchEvent too

normal use method:

package method:

Posted in AS3

[as2] shadow filter in as2

Posted in AS3

[as2] graphics algorithm in as2

Posted in AS3, 編程

[as2] kill a mouse event function

_handle_layer.onMouseMove = undefined;

Posted in AS3

[as2] onMouseDown和onMouseUp则不管鼠标在什么地方

Posted in AS3

[as2] some movieClip property you may always need

	function resetStartProps():Void {
		delete _startProps; //Aids in memory management
		_startProps = {};
		var sp = _startProps;
		var axisPoint_obj = this.axisPoint;
		var mdx = _targetObject._parent._xmouse - axisPoint_obj.x; //Distance to mouse along the x-axis
		var mdy = axisPoint_obj.y - _targetObject._parent._ymouse; //Distance to mouse along the y-axis
		var md = Math.sqrt(mdx * mdx + mdy * mdy); //Total distance to mouse
		var angleAxisToMouse = Math.atan2(mdy, mdx);
		var rdx = _targetObject._x - axisPoint_obj.x; //Distance between axis point and registration along the x-axis
		var rdy = axisPoint_obj.y - _targetObject._y; //Distance between axis point and registration along the y-axis
		var angle = _targetObject._rotation * (Math.PI / 180); //rotation translated to radians
		var rAngleAxisToMouse = angleAxisToMouse + angle; //Rotated (corrected) angle to mouse (as though we tilted everything including the mouse position so that the _targetObject is at a 0 degree angle)
		sp.centerX = this.centerX;
		sp.centerY = this.centerY;
		sp.axisX = axisPoint_obj.x;
		sp.axisY = axisPoint_obj.y;
		sp._x = _targetObject._x;
		sp._y = _targetObject._y;
		sp._xscale = _targetObject._xscale; 
		sp._yscale = _targetObject._yscale; 
		sp._rotation = _targetObject._rotation; 
		sp.angle = angle;
		sp._xmouse = _targetObject._parent._xmouse;
		sp._ymouse = _targetObject._parent._ymouse;
		sp.angleAxisToMouse = (angleAxisToMouse + Math.PI * 2) % (Math.PI * 2);
		sp.distAxisToMouseX = Math.cos(rAngleAxisToMouse) * md;
		sp.distAxisToMouseY = Math.sin(rAngleAxisToMouse) * md;
		sp.distAxisToMouse = md;
		sp.distRegToCenterX = _targetObject._x - sp.centerX;
		sp.distRegToCenterY = _targetObject._y - sp.centerY;
		sp.distAxisToReg = Math.sqrt(rdx * rdx + rdy * rdy);
		sp.angleAxisToReg = Math.atan2(rdy, rdx);
		if (_bounds.xMax != undefined) { //If we need to constrain dragging to stay within a rectangle...
			var bnds = _targetObject.getBounds(_targetObject._parent);
			sp.xMin = _bounds.xMin + (_targetObject._x - bnds.xMin) + 1;
			sp.xMax = _bounds.xMax - (bnds.xMax - _targetObject._x) - 1;
			sp.yMin = _bounds.yMin + (_targetObject._y - bnds.yMin) + 1;
			sp.yMax = _bounds.yMax - (bnds.yMax - _targetObject._y) - 1;
			sp.angleAxisToTL = (Math.atan2(_bounds.yMin - axisPoint_obj.y, _bounds.xMin - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToTR = (Math.atan2(_bounds.yMin - axisPoint_obj.y, _bounds.xMax - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToBR = (Math.atan2(_bounds.yMax - axisPoint_obj.y, _bounds.xMax - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToBL = (Math.atan2(_bounds.yMax - axisPoint_obj.y, _bounds.xMin - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
    /*      get-set Function                      */
     function get centerX():Number {
		return this.centerPoint.x;
	 function get centerY():Number {
		return this.centerPoint.y;
     function get centerPoint():Object {
		var p = {x:_localCenterX, y:_localCenterY};
		return p;
	function get axisX():Number {
		return this.axisPoint.x;
	function get axisY():Number {
		return this.axisPoint.y;
	function get axisPoint():Object {
		var p = {x:_localAxisX, y:_localAxisY};
		return p;

    /*                                                                           */
    /*      This is the function to find the relative center Point               */
    /*                                                                           */
    function resetCenterPoint():Void {
		var rotation_num = _targetObject._rotation;
		_targetObject._rotation = 0; //We need to straighten it temporarily to measure accurately...
		var bounds_obj = _targetObject.getBounds(_targetObject._parent);
		var x1 = (bounds_obj.xMax + bounds_obj.xMin) / 2; //Find the center x-coordinate when the rotation is 0
		var y1 = (bounds_obj.yMax + bounds_obj.yMin) / 2; //Find the center y-coordinate when the rotation is 0
		var dx = x1 - _targetObject._x; //distance between the _targetObject's registration point and center point along the x-axis
		var dy = _targetObject._y - y1; //distance between the _targetObject's registration point and center point along the y-axis
		var radius = Math.sqrt((dx * dx) + (dy * dy)); //Find the distance between the _targetObject's registration point and the center point.
		var angle1_num = Math.atan2(dy, dx);
		var angle = (rotation_num * (Math.PI / 180)) - angle1_num; //Total angle that we're adding/moving (we have to subtract the original angle to just get the difference)
		var x = _targetObject._x + (Math.cos(angle) * radius);
		var y = _targetObject._y + (Math.sin(angle) * radius);
		_targetObject._rotation = rotation_num; //Re-apply the rotation since we removed it temporarily.
		var p = {x:x, y:y};
		_localCenterX = p.x;
		_localCenterY = p.y;
    /*                                                                           */
    /*      This is the function to find the relative X Y                        */
    /*                                                                           */
	function setAxis(x:Number, y:Number):Void { //x and y according the the _targetObject._parent's coordinate space!
		var p = {x:x, y:y}; //Make a point so that we can do localToGlobal()
		_targetObject._parent.localToGlobal(p); //Translates the coordinates to global ones (based on _root)
		_targetObject.globalToLocal(p); //Translates the coordinates to local ones (based on _targetObject)
		_localAxisX = p.x;
		_localAxisY = p.y;
Posted in AS3, 編程

basic matrix and geometry

Posted in algorithm

[jquery] xxx.fn.funtionName() {} is prototype


All objects have a prototype property. Whenever the interpreter looks for a property, it also checks the prototype. jQuery uses that extensively to add methods to jQuery instances.

var form = $(“#myform”);
form.clearForm; // undefined
form.fn.clearForm = function() {
return this.find(“:input”).each(function() {
this.value = “”;
form.clearForm() // works for all instances of jQuery objects, because the new method was added to the prototype

(This example needs clarification: how does it modify the prototype when the word “prototype” doesn’t appear anywhere? The implication is that form.fn is simply an alias for form.prototype, but if that’s the case then it should be explained. :-?)

In javascript:the definitive guide 5 edition,dont add attibute to Object.prototype

Posted in web

super strong html5 photobook editor

Posted in web

check empty string? if(strValue) is already enough

Posted in web

jquery onlyInt validation

Posted in web

disable the auto complete of browser (so annoying sometime u click on a input field and pop sth out)

Posted in web

cookies, using php or js?

use js pls
php setCookies cant trigger by user if he press “BACK” button

Posted in web

[js] quick revise js

Posted in web

read this, web developer

Posted in web

[js][php] language solution

Posted in web

Javascript null, undefined and default value?


var option = para || {};
option.color = option.color || “#B0B0B0″ ;
option.height = option.height || 1;

Posted in web

old jquery dun hv parseXML function, add it yrself

Posted in web

ignore enter submit form by ie and other browser

event.preventDefault ? event.preventDefault() : event.returnValue = false;

event.preventDefault = many browser
event.returnValue = ie :)

Posted in web

[js] read The Infamous Loop Problem to know more about always get the last element when event trigger and can learn more abt scoping too!

Posted in web

[js] a quite good tutorial for js beginner

Posted in web

batch rename and thumbnail

batch edit image:

batch rename program:

Posted in web, 編程

amfphp, zend php [client <-> server]

Posted in web

advice to jquery append, html, remove vs hide/show

pls dun depends on remove , append
they perform badly and hv bug with complicated tag

always use hide / show for module switching!

u already face in urbanmonk, y wrong again in vierzen!

Posted in 無分類

[js] always need to advise : how to make object in js

Posted in web, 編程

html word wrap attribute for diff browser

white-space: pre-wrap; /* CSS3 */
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* Opera <7 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* IE */
white-space: normal !important; /* IE 7*/


Posted in web

jquery plugin template

quite good jquery plugin template

Read more ›

Posted in web, 無分類

[jquery] very good to modify this to combo box

Posted in web

[wp] related post

Posted in web

jquery bubble tip

Posted in web

[jquery] combobox, and can type yr own text too

Posted in web

wordpress change upload file config

Posted in web

[jquery] read this if u want to write plugin

diff pattern for plugin

defaults and settings/option

Posted in web, 編程

some example of online photo, card design and print system

photo create
-> bubblepix
-> purrprint
momento au



Posted in 影像

[webdesign][PS] learn some photoshop effect for your web design

Posted in web

[css] clear: both, very useful!

when u r making some layout float:left ….
then u want next component dun want float anymore =.=
use CLEAR attribute!!!

Posted in web

ping again

Posted in 無分類

ulikela ref site

main style:

comment style:

Posted in web

something i learn from hactl

1. Dun leave a place easily, yes, u can still change yr job from AP to SA, but if u go too rapidly, u miss the skill building period.

2. Dun just follow a trend to build software. Say IPad, if ipad is hit and release app, then the hit is gone, u got only money. Build your career.

3. If u want to be developer, go other place out of HK. This is commercial place, we are only users. You can do what you want but you cant change the fact.

4. You can leave, if you learn most of the things. You can try to tell yourself wt u done n learnt. If u can tell, u learnt.

Posted in 創業

opensource font, real good

Posted in font, 設計

[as3] quite good tutorial for learning vector, velocity, direction

Posted in AS3

blog tool – related post widget.

Posted in web

learn code Ignitor X jquery

Posted in web

ping test

Posted in 無分類

[blog] a good blog for css learning

Posted in web

[php] a blog always talk php.
呢個 blog 都無咩 update ,不過d 舊文都 ok 有用

Posted in web, 編程

some web magazine

Posted in Blog

[git] git cheatsheet;

Posted in 編程

iphone stuff blog, check it

Posted in iphone, mobile

CSS button , hv a nice try

Posted in web

font again , some r gd

Posted in font

[photoshop] how to draw ipad app layout

Posted in graphics

[nodejs][php] long polling n related concepts



Posted in web

apple wallpaper

Posted in graphics

[wp] you are doing on comments, right ?

Posted in web

[wp] learn it first, beginner

Posted in web

[ai] learn draw for some web design

Posted in 無分類

[wp] I think u can learn fm them

Posted in web

[apache][phpmyadmin] change phpmyadmin to 443 using default phpmyadmin package

idea: rewrite engine to make http => https

1. go to .htaccess in /usr/share/phpmyadmin

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

2. activate the rewrite engine by a2enmod rewrite , then restart apache2

3. make SSL cert, some command like the following
#openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem


4. permission for the cerf : #chmod 600 /etc/apache2/apache.pem

5. Listen 443 in ports.conf

6. Set the phpmyadmin conf in sites-available:

# phpMyAdmin default Apache configuration
Alias /phpmyadmin /usr/share/phpmyadmin

DocumentRoot /usr/share/phpmyadmin
SSLEngine on
SSLCertificateFile “/etc/apache2/apache.pem”

Options Indexes FollowSymLinks
AllowOverride All
DirectoryIndex index.php

AddType application/x-httpd-php .php

php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .

# Authorize for setup

AuthType Basic
AuthName “phpMyAdmin Setup”
AuthUserFile /etc/phpmyadmin/htpasswd.setup

Require valid-user

# Disallow web access to directories that don’t need it

Order Deny,Allow
Deny from All

Order Deny,Allow
Deny from All

7. Finish.

Posted in web

Protected: it is the manual of my server, somehow for ref

This content is password protected. To view it please enter your password below:

Posted in 無分類

[webdesign][template] some free webpage template, can borrow some graphics component to use

Posted in web

[WP] Learn WP beginner!

theme option page

Posted in web

some font u will feel good, and it is free

Posted in font

[js] image slider, ok 好用

Posted in web, 編程

nav 升升降降……係我想要既野了…. nggggggg

Posted in web

Pushbutton Engine and Haxe: a natural fit

Posted in AS3


Posted in graphics, web

dropkick for HTML dropping list

Posted in web

Poise Drum, real gd fd with yr mpc

Posted in Audio

let jam song with mlrv

Posted in music

learn jquery la!

Posted in web

Zinc, f-in-box 之 Z-drive 之謎?


来源: 发布时间:星期三, 2008年9月24日 浏览:44次 评论:0
这样可以实现保护flash文件,而且用flash做界面发布时不要带swf文件,很方便,国外有一个 Control 可以实现,大家一起来讨论一下这样实现的技术方案.
ShockwaveFlash1.Movie = ‘c:\temp\temp.swf ‘;

ShockwaveFlash1.EmbedMovie = True
ShockwaveFlash1.Movie = ‘-_-!! ‘;


虚拟硬盘 这个玩大了
这样就必须用到驱动 flashplayercontrol用驱动不可能吧
反汇编 跟踪 发现真的搞了一个虚拟硬盘,生成了一个临时文件Z:\FromMemory\46A10F369771449587DE913EFC0A258C\1\E4ED7C01D28A43418DBF2CB92CC35E56.swf

Posted in AS3, 編程

強~用css 做 tab style

Posted in web, 編程

read this first when u go REST

Posted in web

first html5 game tutorial with box2d

Posted in web, 編程

some free sample design work

Posted in 設計

Last moment 後制,我的 icon


download 小工具 ko 吧


或者 on9 solution

Posted in Windows, 編程

iOS beginner blog 中文呵

Posted in Blog, mobile

[iOS] 一d code examples

Posted in mobile, 編程

[配色專用] colorapi

Posted in graphics

[素材] Vector graphics of social media icon

Posted in graphics, 設計

Useful HTML-, CSS- and JavaScript Tools and Libraries,堅得。

Posted in web

Learn about GIT

Posted in 無分類

Quick Test JS 用

Posted in web

js secret

Posted in web, 編程

htaccess cookbook

Posted in web

[web] 想 update web content 但又唔想 reload page

Typical 做法:
用 hash-hack #

HTML5 做法:
window.history.pushState(“object or string”, “Title”, “/new-url”);

Posted in 無分類

a common creative share place, music or sth else

Posted in 設計

Optimizing content for Apple iOS devices [其實 d skill desktop version 都用得著]

Posted in AS3, mobile, 編程

[as3] Unicode range of Flash

睇睇 flex4 sdk / frameworks 裡面 flash-unicode-table.xml

Posted in AS3, 編程

[UX] Mock Up software 紹介 … (即係 layout design)

Posted in web, 編程

[UX] Tools for UX (web analytic) (web analytic) (micro usability tests)

Posted in web, 編程

[as3] 唔勁,但可以睇下

Posted in AS3, 編程

a real-time graphical programming environment for audio, video, and graphical processing

Posted in music, 編程

ebook framework~

Posted in web, 編程

[audio] 研究下,將 d signal 轉做 midi 既 工具~

Posted in music

Push Button Engine and the console!

Posted in AS3, 編程

[rest] kaze 話

restful + spring + freemaker

可以玩下 rest 野,try try try

Posted in web, 編程

[as3] 畫圖形的 library



Shape 之一覽


當然可以 extend 佢 d 野 畫d 複雜d 既野~

Posted in AS3, 編程

em…browser 字

原來……中文個d 係無腳字……Sans-serif

Posted in web, 編程

[box2d][as3] multiple gravity

Posted in AS3, 編程

[audio] 第一篇 audio post, ableton tutorial

Posted in music

正野,畫 pixel art 用,同埋寫 game 專用技 <== 呢條友鍾意用 wor

Posted in graphics, Windows, 編程, 設計, 軟件介紹

[box2d][as3] 睇下 tutorial

Beginner 教程

直接睇 wiki

Posted in AS3, 編程

[as3] blog, 講 flash games, 幾過癮既

Posted in AS3, 編程

box2d as3 的一般 tutorial

Posted in AS3, 編程

[web] flv movieplayer for web

Posted in AS3, web, 編程

素材,好野,web 或者 software 用

Posted in graphics, web, 編程, 設計

JavaScript Tricks And Good Programming Style

Posted in web, 編程

[jquery] slider and gallery

Posted in 無分類

[as3] Copying Timeline Animation into a Class

Posted in AS3, 編程

又有素材, social media 野

Posted in graphics, web, 編程, 設計

[away3d] 做得好靚既 away3d ,下次做睇睇佢d code 學下野

Posted in 3D, 編程

[web][js] fancybox 靚過 lightbox 咁囉

Posted in web

Keith Peters 用的 Host

Posted in web, 編程

[pbe][as3]既然玩緊 push button,就睇埋呢個。

Posted in AS3, 編程

mobile framework again

Posted in mobile, 編程

[PBE][AS3] Article Studies

Posted in AS3

[wp] 好靚,wordpress 改裝 QC system

Posted in web

[pbe] Push Button Engine 入門

Posted in AS3

[pbe][AS3] Experiment: Using SWF MovieClips in PushButton Engine

Posted in AS3, 編程

[mac][tricks]Use Tab To Switch Between Dialog Buttons

The one single “bug” on Mac OS X by far is the ability to switch buttons in dialog boxes. For example I mean using Tab to go between OK, Cancel, Don’t Save etc. For a long while until today I had just got used to using the mouse. Although you can use some shortcut keys for Save, but these aren’t always reliable. Windows has the ability to tab through button options. Why not Mac? Well you can and it is blindingly obvious.
To enable you to tab through dialog boxes go to System Preferences > Keyboard & Shrotcuts. At the very bottom there will be an option saying about full keyboard access. Check the radio button that says “All Controls”.

Now when you find a dialog box (a new file in TextEdit is quickest), when you hit tab you will be able to move through the dialog box options. Very neat. As the option at the bottom states if you hit Control + F7 you will be able to change this setting, although I doubt would have to.

Posted in 軟件介紹

[web] Comment management social community

Posted in web, 編程

[mysql/php] Using MySQL Stored Procedures with PHP mysql/mysqli/pdo

Posted in web, 編程

[VC++]我想用 regex 但無左 atlrx.h

Posted in C++

[IDE][Cloud] Cloud 9 , a JS IDE for JS

Posted in web

[素材] Social Icons 1.0 既圖

Posted in web

[software] 其實有d 都 ok, 尤其個 ommwriter




Posted in 軟件介紹

[PSD] many good effect tutorial, CD album i think

Posted in graphics


Posted in AS3

[as3]What can you do with bytes ?

Posted in AS3

[web][js] 3 ways to define a JS Class

Posted in web, 編程

[AIR][AS3] Playing around silent install AIR

Cmd 教你裝


一炮過 setup.exe

forum discuss about this

Posted in AS3, 編程

[adobe] a blog of adobe news

Posted in AS3, 編程

[as3] readObject, writeObject of ByteArray, good for save 低 d野~

Posted in AS3, 編程

[wordpress] 整 wordpress theme 用 framework

Posted in web, 編程

[webdesign] 興! 極速做 3D banner for web

Posted in web, 編程


Posted in AS3, 編程

[as3] fscommand fix

fscommand(“exec”, “abc.exe”)
呢個你識用啦,將個 abc.exe 放係 fscommand 既 folder 到
好啦,但係好大問題就係 你想入 argument 入去 係唔 work
fscommand(“exec”, “abc.exe argu1″),無呢回事



再用 C++ 寫個小 program
個 program 就係貼上 clipBoard 既字再 run
咁就乜 seven 都 run 到啦!
唔洗下下用 C++ 自己寫 flash player 或者 d zinc framework 咁煩~

Posted in AS3, 編程

[as3] 搵左咁耐終於有教,d 網只係教人爆 zip,唔教人 zip 野


或者用 nochump

Posted in AS3, 編程

[M$] 玩 mfc 了嘛?

Posted in C++, 編程

[AS3][JQuery] jotaquery, as3 直 call jquery 既 script

Posted in AS3, web, 編程

[web][design] Japan sample site

Posted in web, 書簽, 設計

[as3][C++]有 vc++ 就好 lu

Posted in C++

學少少 bat cmd 梗有用

Posted in Windows, 編程

[web font] web font concept

Posted in web

unicode range

常用正規表達式, 繁簡體中文日文韓文的Unicode字元範圍
//日文 : [\u0800-\u4e00]
//漢字 : [\u4e00-\u9fa5]


Posted in 編程

[as3] Generative Art in Flash

a href=””>


Posted in AS3, 藝術

[web][font] typekit, a company provide web fonts

Posted in font, web

[as3] Polygon area calculation

Posted in AS3

[as3] Displacement filter, 可以玩放大,mapping 等等


Posted in AS3, 編程

[Web Design] Japan website sample

Posted in 設計

[Photoshop]學用 Pen Tool Video!5753624/basics-of-photoshop-basic-drawing-and-layouts

Posted in 軟件介紹

[C++][AS3] C++ insert Flash

Posted in AS3, C++

[font] font collection

Posted in font, 設計

[Web]How to Build an RSS Reader with jQuery Mobile

Posted in web, 編程

[JS] 其實好 OK, js Magazine style framework

Posted in web, 編程

[AS3] Zinc 夾 GAIA, d path 錯曬!
Solution here~

July 5, 2009 by Alistair Stead in ActionScript, Flash Comments ( 3 )
The Gaia Framework for Adobe Flash is a something I have been using for some time. It is one of the most useful frameworks I have found for use with Flash. It adds a great deal of useful functionality and can generate large swathes of source code that you would otherwise need to write from scratch. However it is a very lightweight and unobtrusive ActionScript framework, you are still free to build your flash application in the same way you always have. You can continue to use your existing workflow but also take advantage of the framework features such as scaffolding, swfAddress, SEO optimization and asset loading and pre-loading.

With all this said when using the Gaia Framework with MDM Zinc application wrapper you have a couple of issues to resolve.

File paths and references from the application executable.
External Interface calls.
Most flash developers are likely unfamiliar with developing installable applications so these issues may be daunting when first encountered. However once explained there are simple solutions to both these issues that I will explain in detail.

File Paths and References

When Flash is used within a website it is served by a webserver and files can always be referenced from the root of the website e.g. /flv/example-video.flv or relative to the location of the .swf e.g. flv/example-video.flv.

However when your .swf is running inside the MDM Zinc wrapper it can no longer reliably reference files using the absolute path from root or a relative path. To resolve this you will need to evaluate the location that the application is running at before creating a path to the files based on this computed path.

Zinc Context Object

To solve this problem I have created a singleton context object. This object allows me to run the required application setup code and access the application properties from everywhere within my Gaia based application.

package com.designdisclosure.utils.mdm
import mdm.*;
import flash.display.*;

public class ZincContext extends Sprite
private static var _instance:ZincContext;
public var zincGlobals:ZincGlobals;

* Public static method to instantiate the ZincContext object.
* @return ZincContext Object Instance
public static function get instance():ZincContext
if(_instance === null)
_instance = new ZincContext(new SingletonEnforcer());

return _instance;

public function ZincContext(pvt:SingletonEnforcer):void
if(pvt == null)
throw new Error(“Error: Instantiation failed: Use ZincContext.instance instead of new.”);

// Initialize an MDMZinc application and create a callback method for when this is completed
mdm.Application.init(this, onMDMinit);

private function onMDMinit():void
// Use this method to setup your Zinc application
// This is the same as applicationDidFinishLaunching from cocoa

* Get the absolute path to the application and its files.
* I use a VMWare machine during testing and found
* that the application path is alittle un-reliable
* and needs modification when running in the VM.
public function getApplicationPath():String
var path:String = mdm.Application.path;

return path;

public function get isZincApplication():Boolean
return (getApplicationPath.length)? true : false;

internal class SingletonEnforcer {}
This object can be used to obtain the application path, an absolute location at which the Zinc application is running. The can then be used in any function the loads external resources. However here is the main problem within the Gaia framework. It is possible to update the path to the site.xml file that is loaded in but even if you load the file from an absolute path the framework does not update the paths used to load any assets referenced in the xml file its self.

Fixing the file paths

Although my next suggestion is not by any means ideal as it involves modifying the framework, I have yet to find a better solution. This obviously will lead to problems when updating the framework to future revisions. However these changes re fairly limited in scope as it is only a single file Here are my modifications that inject the application path if it exists into any location where external files are loaded.

public function load(path:String):void
if (path == null) path = “site.xml”;
if (path != “xml/site.xml” && path != “site.xml”) GaiaDebug.log(“site.xml path = ” + path);
var request:URLRequest = new URLRequest(CacheBuster.create(ZincContext.instance.getApplicationPath()+path));
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoadComplete);
private function parseSite():void
_title = _xml.@title || “”;
_preloader = _xml.@preloader || ZincContext.instance.getApplicationPath()+”preload.swf”;
_menu = (_xml.@menu == “true”);
_delimiter = _xml.@delimiter || “: “;
_routing = !(_xml.@routing == “false”);
_history = !(_xml.@history == “false”);
_indexFirst = (_xml.@indexFirst == “true”);
_assetPath = _xml.@assetPath || ZincContext.instance.getApplicationPath();
// preloaderDepth
var depth:String = String(_xml.@preloaderDepth).toLowerCase();
if (depth == Gaia.MIDDLE || depth == Gaia.BOTTOM) _preloaderDepth = depth;
else _preloaderDepth = Gaia.TOP;
// preloaderDomain
var domain:String = String(_xml.@preloaderDomain).toLowerCase();
if (domain == Gaia.DOMAIN_CURRENT || domain == Gaia.DOMAIN_NEW) _preloaderDomain = domain;
else _preloaderDomain = Gaia.DOMAIN_NULL;
// defaultFlow
var flow:String = String(_xml.@flow).toLowerCase();
if (flow == Gaia.PRELOAD || flow == Gaia.REVERSE || flow == Gaia.CROSS) _defaultFlow = flow;
else _defaultFlow = Gaia.NORMAL;
if (_routing) _routes = {};
private function parsePage(node:XML, parent:PageAsset = null):PageAsset
validateNode(node, true);
var isIndex:Boolean = (node.@id == _indexID);
var page:PageAsset = new PageAsset();
page.node = node; = node.@id;
page.src = ZincContext.instance.getApplicationPath()+node.@src;
page.title = node.@title;
page.bytes = node.@bytes;
page.assetPath = ZincContext.instance.getApplicationPath()+node.@assetPath || _assetPath;

page.preloadAsset = true; = (node.@menu == “true”);
if ( && page.title.toLowerCase() == “about”) GaiaDebug.warn(‘* Warning * “About” is not permitted in Flash context menus’);
if ( && page.title.length > 0) _menuArray.push(page);
page.landing = (node.@landing == “true”);
// domain
var domain:String = String(node.@domain).toLowerCase();
if (domain == Gaia.DOMAIN_NEW || domain == Gaia.DOMAIN_CURRENT) page.domain = domain;
// depth
var depth:String = String(node.@depth).toLowerCase();
if (!isIndex)
page.external = (node.@src.split(“.”).pop() != “swf” || node.@src.indexOf(“javascript”) > -1);
if (page.external) page.window = node.@window || “_self”;
if (depth == Gaia.TOP || depth == Gaia.BOTTOM || depth == Gaia.NESTED) page.depth = depth;
else page.depth = Gaia.MIDDLE;
if (depth == Gaia.TOP || depth == Gaia.MIDDLE) page.depth = depth;
else page.depth = Gaia.BOTTOM;
// flow
var flow:String = String(node.@flow).toLowerCase();
if (flow == Gaia.NORMAL || flow == Gaia.PRELOAD || flow == Gaia.REVERSE || flow == Gaia.CROSS) page.flow = flow;
// assets
if (node.asset.length() > 0 || node.@seo != undefined) page.assets = parseAssets(node.asset, page, node.@seo, int(node.@seoBytes));
// child pages
if ( > 0)
page.defaultChild = node.@defaultChild;
page.children = parseChildren(page,;
if (!page.children.hasOwnProperty(page.defaultChild)) page.defaultChild =[0].@id;
// terminal page
if (page.src.substr(page.src.length – 4) == “.swf”) page.landing = true;
if (isIndex) GaiaSWFAddress.isSinglePage = true;
// only add terminal and landing pages to routes
if (_routing && page.landing)
var route:String = node.@route || page.title;
if (isIndex) route = route ||;
page.route = getValidRoute(route,;
_routes[page.route] = page.branch;
return page;
These changes allow you to test your application within the flash authoring environment as the application path will be empty and it will load the files with local references. If you run the application inside a Zinc wrapper the files will be references with an absolute path.

External Interface calls

In order for flash applications to communicate with the browser they use External Interface. This is used extensively within the Gaia framework for logging and also search engine optimization with swfAddress. However MDM Zinc does not handle these calls particularly gracefully and as it is not possible to turn this functionality off within the framework we again need to make a couple of modifications.

Blocking external calls

Inside there is a test for ExternalInterface.available however inside Zinc this will incorrectly report true. The only fix for this is as follows:

private static var _availability:Boolean = false; // used to be ExternalInterface.available;

The solutions I have proposed here will resolve the issues the prevent you from using Gaia within a Zinc application. However I believe that these issues could be resolved in a number of ways within the respective products.

MDM Zinc need resolve the issue with ExternalInterface and the its incorrect implementation as this is essentially a bug in the platform.

The issues with the Gaia framework can not be considered bugs as the framework does exactly what it was intended to do. However I would suggest that the framework would be greatly improved if additional configuration were made available to users. Being able to turn off the SEO modules such as SWFAddress and external calls would be very helpful. Not only for use within MDM Zinc but also in situations where the flash application is not the entire web page. If you use Gaia to be build a smaller component within a page the SWFAddress calls can also cause problems.

The loading of assets would also be greatly improved if it were possible to update their paths at run time. Obviously this is not a common requirement but it would make the framework much more flexible and far more useful.

Posted in AS3, 編程

[webdesign] 素材,the noun project always good!

Posted in 設計

[jquery][plugin] 好多正野,學野無妨

Posted in web, 編程

[webdesign] 素材一大堆 Update

Posted in 設計

[webdesign][css] gradient 靚靚 menu bar

Posted in web, 編程

[design] 做 font 既 website, 幾靚, 做 logo o岩晒~

Posted in font, 設計

[Design][AI]一堆 paper, memo background 素材

Posted in AI, 設計

[AS3] 似曾相識的錯,tweenlite removeTint re 極都 re 唔到

TweenPlugin.activate([TintPlugin]);, 1, {removeTint:true});


TweenPlugin.activate([RemoveTintPlugin, TintPlugin]);
funny, 原來有 RemoveTintPlugin =x=

我知啦! 原來舊版本先係咁
成日用 gaia framework 又 update 下個 tweenlite =x=

Posted in AS3, 編程

[wordpress]Theme 抄下參下

Posted in web, 編程

[AS3] Signal 野: Signal VS DeluxeSignal
up 一大春英文,搞咩,超簡單
signal 係可以 pass parameter,但 pass 個個 object 就係個個 object 囉

DeluxeSignal 就勁啦,係 pass event
event signal 都識 pass 啦,咁你就錯
呢個 event 係 as3 d fd,你 pass 左,過到去,有翻曬你以前 event 玩既野
例如 event.currentTaret, event.type, 咁

Posted in AS3, 編程

[AS3] 兩個 SWF event 傳黎傳去既方法

你仲想利用個 event 傳data ?

mother.addEventListener(CustomEvent.MODULE_CLOSE, onModuleClose)

function onModuleClose(e:*):void {

var data =;


var data = {a:1, b:"hello"};

swf.dispatchEvent(new CustomEvent(CustomEvent.MODULE_CLOSE, data));


如果要玩 bubbling: 記得 extend 個陣 要 override 埋 clone 呢個 function!

Posted in AS3, 編程

[AS3] Loading SWFs into AIR 1.5.X and LoaderInfo.sharedEvents

我見佢打散個 swf 做 byteArray ,再用 loader 砌翻埋佢

Posted in AS3, 編程

[AS3] GAIA Framework, 自己整 custom attribute for site.xml ,這世界突然美好了。

Posted in AS3, 編程

[Web][AS3] 有趣的 web service – digital publishing

Posted in web app, 軟件介紹

[AS3] 又黎一d framework

Swiz is a framework for Adobe Flex and ActionScript that aims to bring complete simplicity to RIA development.

話勁過快過 event 既 singal

Posted in AS3, 編程


download 完, 開 system requirement

Posted in 軟件介紹

[AI] Good AI Techique!

Posted in AI, 設計

[AS3] Hit on hitTestObject

hitTestObject is always use

but do u know:


if target.visible = false and target.alpha =0

其實都 hit 中 return true

小心d 啦~ 最好加多個 condition

mc.hitTestObject(target) && target.visible

Posted in AS3, 編程

[web] Modernizr

Modernizr is a small and simple JavaScript library that helps you take advantage of emerging web technologies (CSS3, HTML 5) while still maintaining a fine level of control over older browsers that may not yet support these new technologies.

Posted in web

[web] wunderlist 其實 open src ,學野啦~

Posted in web

[iphone, mac] blog of cocoa

Posted in iphone

[iphone] development platform, cocos2d 既 朋友

Posted in iphone, 手機

[AS3] SWF Sheet, flash mc -> sequence img format, good for iphone!

Posted in AS3, 編程

[Paper] Silencing

Silencing is a new illusion that shows it’s hard to notice when moving objects change.

Posted in Papers

[Windows] BAT file Library

Posted in Windows, 編程

[AS3] Generate Pdf by AS3 Library

Posted in AS3, 編程

[AI] How to distribution Objects Around the Circle

Posted in AI, 設計

[AS3] Concept of display list

Highlight : Stage -> Main -> DisplayObject(s) -> …

Posted in AS3, 編程

[AS3][Function]Anonymous, inline, and named functions in ActionScript

what is inline function …

Posted in AS3, 編程

[AS3] Flash Tips (MUST READ)

Flash Tips

Posted in AS3, 編程

[AS3] Mac Dock Style Flash

read this more happi

Posted in AS3, 編程

[AS3] 搵翻 GAIA 唔洗 FLASH,用 ANT 都得!

Posted in AS3, 編程

[Math] 單位 px 與 cm 如何轉換

單位 px 與 cm 如何轉換?

1cm = ?px, 1px = ?cm.

在 PowerPoint (ppt) 製作, 要在網頁的截圖上開始畫畫時, 特別需要~
公分(cm) 與 px 如何轉換?

* 1px = 0.04cm
* 1cm = 25px

Posted in 設計

[AS3] Flex no MXML using Application

	import mx.core.Application;
	import mx.styles.StyleManager;
	import mx.styles.CSSStyleDeclaration;
	import mx.controls.Button;
	import mx.skins.halo.HaloBorder;
	import flash.display.Bitmap;

	public class Main extends Application
		public var UpState		: Class;
		public var OverState	: Class;
		public var DownState	: Class;

		public function Main()

			this.layout = "absolute";
			this.addEventListener(FlexEvent.CREATION_COMPLETE, handleComplete);


		private function setupStyles() : void
			var style:CSSStyleDeclaration = new CSSStyleDeclaration();
			style.setStyle( "borderSkin", mx.skins.halo.HaloBorder );
			StyleManager.setStyleDeclaration( "Application", style, false );

			style = new CSSStyleDeclaration();
			style.setStyle( "textAlign", "left" );
			style.setStyle( "fontAntiAliasType", "advanced" );
			style.setStyle( "fontGridFitType", "pixel" );
			style.setStyle( "paddingLeft", 10 );
			style.setStyle( "paddingRight", 10 );
			style.setStyle( "paddingTop", 5 );
			style.setStyle( "paddingBottom", 5 );
			style.setStyle( "horizontalCenter", 0 );
			style.setStyle( "verticalCenter", 0 );
			style.setStyle( "upSkin", UpState );
			style.setStyle( "overSkin", OverState );
			style.setStyle( "downSkin", DownState );

			StyleManager.setStyleDeclaration( "Button", style, false );

		private function handleComplete( event : FlexEvent ) : void
			var button : Button = new Button();
			button.label = "labelBtn";
			addChild( button );
Posted in AS3

[3D] 3d 必學 algor

Posted in 3D, 編程

[影像] 影像玩到咁,不枉此生

Posted in 影像, 藝術

[AS3] 靚波請睇

d 波點做?
一個波其實好多 point 組成,再用 curve 連成
wave effect 係 叫d point 郁少少 x 同 郁少少 y

Posted in AS3

[WebDesign] CSS Font-Size: em vs. px vs. pt vs. percent

Posted in web, 編程

[AS3] Open source Page Flip Engine

Posted in AS3, 編程

[Maths] Algorithms DB

Posted in algorithm

[JS] 新既圓型 concept photo slider

Posted in web

[AS3] Flash Video Player

Posted in 無分類

[天文]觀星用 software

Posted in 軟件介紹

[CSS] 將網頁分割,放棄 960 grid 的一個原因

Posted in AS3, 編程

[AS3] Saving file by FileReference


(題外話,講 load 的)

叫你注意 loader.dataFormat = URLLoaderDataFormat.BINARY;

如果 advance d coding的話,用 fscommand出一個小exe將 bytearray -> jpg都得。

Posted in AS3, 編程

[AS3/Flex] Start Module Programming!

Posted in AS3, 編程

[RoR]Ruby on Rails Guides

Posted in web, 編程

[WebDesign] 素材!



Posted in web, 編程, 設計

[AS3] AS3 Framework / API Collection

Adobe APIs
corelib, mappr, flickr, youtube and more.…apis:libraries
APE (Actionscript Physics Engine)
ActionScript 3.0 library for interacting with Amazon S3
Actionscript 3.0 library for sound editing
AS3 Data Structures For Game Developers
ActionScript 3 Cryptography Library
Animation Library for AS3
ebay API
AS3 API to access Facebook’s Platform API
Flest Framework for Adobe Flex and ActionScript3 Applications
Actionscript 3 class library to load standard ZIP archives and extract/decompress contained files.
Actionscript 3.0 library to access the web services
A set of ActionScript 3 Libraries, primarily for Flash game development.
Salesforce Flex Toolkit
Full featured animation library
Twitter AS3 API
Lightweight AS3 UI component library
XMPP client library
Yahoo AS3 APIs

Posted in AS3, 編程

[html5] 超勁 canvas 既 function api reference!

Posted in web, 編程

[JS] 靚靚 progress bar

Posted in web, 編程

[JS] Canvas Framework

作者 = jquery 作者

Posted in web, 編程

[Flash] Hacking SWF – Everything You Never Wanted To Know About Shapes In Flash

must read item!!!!!!!!!!!!!

Posted in AS3, 編程

[C++] C++ program with Flash GUI

Posted in 編程

[HTML5] JS Game Engine – ImpactJS

Posted in 編程

[HTML5] Canvas Demo Blog

Posted in 編程

[HTML5] AI -> canvas

Posted in 編程

50 Powerful Time-Savers For Web Designers

Posted in 編程

[AS3] About Sound

Posted in 編程

[Flash 3D] Z-sorting for flash native 3D

Posted in 編程

[PV3D]SLERP Concept

see this first

similar things

the concept


Posted in 編程

[C++]OpenFramework Very Powerful Graphics framework in C++

Posted in 編程

[3d graphics] demo of some important concept (e.g. quadTree)

Posted in 編程

[Math] Vector Maths

Posted in 無分類

[pv3d] USING QUADTREES IN PAPERVISION3D (solve 3D obj collision problem)

with 2 very good demos inside~

another tutorial, it also mention  cube.meshSort = DisplayObject3D.MESH_SORT_FAR; // before line 50


Posted in 無分類

The Essentials of Writing High Quality JavaScript

Posted in 無分類

[Design pattern] Why extends is evil

Why extends is evil

Posted in 編程

[Flex] Beginner for flex


Splitting Flex application into modules

Using Flex 3 Component without MXML – only AS3 (FLEX 3333333333333333333333333!)

Posted in 編程

[AS3] About Vector and Advanced Drawing API

Posted in 無分類

jquery fundamental tutorial

Posted in 編程

mozilla js guide

Posted in 編程

Automation API sample applications & Advanced Analytics For Flex and Flash RIAs

i dun know wt is this , stay here for reference

(i know la, this is an toolkit to record down user action like scroll, click, and u can make use of it to do some software like vnc etc.)

reference about this too

Advanced Analytics is also mention in this tutorial

Posted in 無分類

[JQuery] Slidar Gallery

Posted in 無分類

[iphone] tutorial

iphone code blog簡介/

cocos2d 簡介


tutorial of cocos2d and obj C

Posted in 無分類

[iphone] iphone game framework

Posted in 無分類

InnerFade with JQuery

Posted in 無分類

jQuery: how to tell if you’re scroll to bottom? (or aka wt is scrollHeight)

Posted in 編程

JSFL compile all

Posted in 編程

Tweenlite: colorTransfrom vs colorMatrixFilter

colorTransform colorTransform

ColorTransform is like color multiply (疊加)

ColorMatrix is like Color Overlay but still hv the color depth or gradient 係到

Posted in 無分類

example for a static class function Class to run constructor first (Singleton use)

this is an example of stageReference singleton

but it is also a good example using static var instance to store itself,

so a class (with static function use) can run a constructor first

Posted in 編程

game on jsfl~

Posted in 編程

jsfl tutorial

Posted in 編程

Using String to call function (可以玩 “jump” + “offense” / “jump” + “attack” 既 call function 做法)

同場加映 apply function (try it), ….)

個 mc 都係玩 apply 咋

Posted in 編程

about mask


Posted in 編程

JSFL recommend


find these jsfl ! this would be good to u and faster development

Posted in 編程

Motion XML Elements (係咪我想要既野)

Posted in 編程

[trytry佢]Runtime Font Publisher, a tool for runtime font sharing.

Posted in 編程

Jquery Test, Mini Jquery Lab

Posted in 無分類 Tagged with:

會唔會太靚,日本靚 flash Lab

Posted in 無分類

終於搵得翻,isometric world example

Posted in 無分類 Tagged with:

3D site concept

某某科學展。 3d pixel is used!

Posted in 設計

女,AXE 永遠都最正。+others 女 site!



鬼妹 model

日本 bra

Posted in 設計

Website recommendation

有靚女,mouseover 埋去轉相的諗法

日清意粉。用顏色分類之 concept

Posted in 設計

Notes on Cross Domain Event Flow

Posted in 編程

a good hitTest class (for isometric too)

Posted in 編程

About isometric world depth sorting

Posted in 編程

game framework (3d game engine) (isomeric engine) (so u heard of it already) (one more then)

Posted in 編程

isomeric world 學野啦

Posted in 編程

SiON ActionScript3 software synthesizer library (造聲必備)

Posted in 編程

ANT on flash develop

Posted in 編程

presentation 之 software (video capture screenshot 個d)

Posted in 編程

Web material and DHTML RIA

open laszlo <—— dhtml RIA

web 既發布技術之一

Posted in 編程

flash runtime on javascript

Posted in 編程

developer blog

flex <-> ruby developer

ajax animator 個作者

Posted in 編程

speed up as3 swf file by apparat framework

a passage to introduce apparat

Posted in 無分類

finite state machine in as3 (for game develop)

Posted in 編程

about outline finding

search about canny edge too

Posted in 編程

meta tag introduction

talk about bindable tag

talk about event tag

general brief of the metatag

frame tag, for making preloader for flex

Posted in 編程

關於 tab 個個核突黃色框

see the comment as well~answer is in comment…..XD

Posted in 編程

Flash Blogs

Posted in 編程

Web Toolbar~~~

Posted in 編程

The MovieClip life cycle, Event.FRAME_CONSTRUCTED, and Event.EXIT_FRAME.

Posted in 編程

Tricks on AS3

Posted in 編程

Using getDefinitionByName and getQualifiedClassName

Posted in 編程

swf and Browser trick




Posted in 編程

swf2exe d solution 成日要人俾錢,用 Screenweaver 啦

花d時間研究下d haxe 同 neko 先

Posted in 編程

Packages are actually namespaces in ActionScript 3 (我都估到架啦!)

Posted in 編程

GUI for as3, with no flash component

Posted in 編程

error 2007, load swf with Flash UI component error

TypeError: Error #2007: 參數 child 不能是 Null。
at flash.display::DisplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()
at fl.controls::BaseButton/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::ScrollBar/draw()
at fl.controls::UIScrollBar/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::TextArea/updateScrollBars()
at fl.controls::TextArea/drawLayout()
at fl.controls::TextArea/draw()
at fl.core::UIComponent/callLaterDispatcher()

TypeError: Error #2007: 參數 child 不能是 Null。

當你用了 load swf,而咁o岩裡面個 swf 有用到 UI component d 野
(e.g. scrollbar, checkbox 等)
你用 main 個個 swf load 佢,本身都應該相安無事
但你搞下個 fl library,例如玩下 focusManager,又或者 (我估) add 其他 UI component
咁佢就會鬧你 load swf 個個搵唔到適當既 UI component
其實無咩野,出下 error,想解決就係 main library 都加埋 個個 UIcomponent la~

Posted in 編程

Flash右鍵另存圖片 with FP10

package  {
 import flash.display.Loader;
 import flash.display.Sprite;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import flash.ui.ContextMenu;
 import flash.ui.ContextMenuItem;
 import flash.utils.ByteArray;

  * ...
  * @author Focus1921
  * 實作Flash右鍵另存圖檔demo
 [SWF(width = "800", height = "600", backgroundColor = "#ffffff", frameRate = "30")]
 public class Main extends Sprite {
  private var imgDataLdr:URLLoader;
  private var imgRequest:URLRequest;
  private var imgData:ByteArray;
  private var imgLdr:Loader;
  private var imgSprite:Sprite;
  private var imgFileRef:FileReference;
  private var imgContextMenu:ContextMenu;

   * 建構式
  public function Main() {
   if (stage) {
   }else {
    addEventListener(Event.ADDED_TO_STAGE, init);


  private function init(e:Event = null):void {
   removeEventListener(Event.ADDED_TO_STAGE, init);

   stage.scaleMode = StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;

   var _demoMark:DemoMark = new DemoMark(stage.stageWidth);

   imgRequest = new URLRequest();
   imgRequest.url = "assets/p1.jpg";

   imgDataLdr = new URLLoader();
   imgDataLdr.dataFormat = URLLoaderDataFormat.BINARY;
   imgDataLdr.addEventListener(Event.COMPLETE, onImgDataLdrComplete);

   imgSprite = new Sprite();
   imgSprite.y = _demoMark.y + _demoMark.height;

   imgLdr = new Loader();

   imgFileRef = new FileReference();


  private function setupImgMenu():void {
   imgContextMenu = new ContextMenu();

   var _itemSaveAs:ContextMenuItem = new ContextMenuItem("另存圖片...");
   _itemSaveAs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onItemSaveAsSelect);
   imgSprite.contextMenu = imgContextMenu;

//---Event Handler---------------------------------------------------------------------------------------

  private function onImgDataLdrComplete(e:Event):void {
   imgData =;

  private function onItemSaveAsSelect(e:ContextMenuEvent):void {
   var _url:String = imgRequest.url;
   var _defalutName:String = _url.substr(_url.lastIndexOf("/") + 1);, _defalutName);



import flash.display.GradientType;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

class DemoMark extends Sprite {
 public function DemoMark(_width:Number) {
  var _matrix:Matrix = new Matrix();
  _matrix.createGradientBox(_width, 20);

  graphics.beginGradientFill(GradientType.LINEAR, [0x333333, 0x333333], [1, 0], [0, 255], _matrix);
  graphics.drawRect(0, 0, _width, 20);

  var _txt:TextField = new TextField();
  _txt.autoSize = TextFieldAutoSize.LEFT;
  _txt.textColor = 0xffffff;
  _txt.text = "Flash實作右鍵另存圖片, demo by focus1921--(圖檔上按右鍵/另存圖片...)";
  _txt.x = _txt.y = 2;

right click 另存圖片!


Posted in 編程

duplicate MC……自己 load 自己


package  {
 import flash.display.Loader;
 import flash.display.MovieClip;
 import flash.display.Stage;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import flash.utils.ByteArray;
  * ...
  * @author Focus1921
  * 複製無綁定類別movie clip場景實體(stage instance)實作demo(fla文件類別)
 public class DocTest extends MovieClip {
  //stage instance
  public var test_box_mc:MovieClip; //場景上僅有的movie clip, 實體名稱test_box_mc
  private var ba:ByteArray;   //儲存自己這個swf的byte array
  private var ldr:Loader;    //建一個loader來load ba
  private var tmpX:Number;
  private var tmpY:Number;
   * 建構式
  public function DocTest() {
   if (stage) {
   }else {
    addEventListener(Event.ADDED_TO_STAGE, init);
  private function init(e:Event = null):void {
   stage.scaleMode = StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;
   if (parent is Stage) {
    trace("parent is Stage");
    //建構url loader(binary)去load自己的byte array
    var _urlLoader:URLLoader = new URLLoader();
    _urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
    _urlLoader.load(new URLRequest(root.loaderInfo.url));
    _urlLoader.addEventListener(Event.COMPLETE, onURLLdrComplete);
   //建構loader, 註冊complete完成偵聽
   ldr = new Loader();
   ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLdrComplete);
   stage.addEventListener(MouseEvent.CLICK, onStageClick);
  //---Event Handler-----------------------------------------------------------------------------
  private function onURLLdrComplete(e:Event):void {
   e.currentTarget.removeEventListener(Event.COMPLETE, onURLLdrComplete);
   //把load到的byte array存起來
   ba =;
  private function onLdrComplete(e:Event):void {
   //用實體名稱去抓到要複製的movie clip,每次load完都會傳不同的引用
   var _mc:MovieClip = <div style="display: inline; height: auto; position: absolute; visibility: hidden; width: auto; ">MovieClip</div>MovieClip(ldr.content).getChildByName("test_box_mc") as MovieClip;
   _mc.x = tmpX;
   _mc.y = tmpY;
   _mc.alpha = Math.random();
  private function onStageClick(e:MouseEvent):void {
   tmpX = e.stageX;
   tmpY = e.stageY;
   //loader去load(loadBytes)存起來的byte array(ba)
Posted in 無分類

focus unwork as3???

注意 flash IDE 個 flash player 對 focus 是虧的……

另外自己再用 flash player 開過黎試……


Posted in 編程

Object Handler (MC transformer 既 framework)

Posted in 編程

Hack Flash Projector to change some value (e.g. title name)

Player without minimize, maximize and close buttons when not full screen:

Using third party projector tools such as mProjector, Zinc, SWF Studio or Screenweaver. Flash alone cannot do that.

Another way to hide the minimize, maximize and close buttons (and also, if you want, to modify/remove others menus, dialog windows etc.), but only applicable at a projector file, is to use a resource editor program, also called ‘hacking’ program. With such programs (for example: ‘XN Resource Editor’, ‘Resource Hacker’), you can usually ‘hack’ Win32 PE files (modules); that is why you will be able to edit only the projector file.

Posted in 編程

Using swc rather than Embed tag


What is Flex Assets?

When using [Embed] to store some bitmap, it will extends BitmapAssets, etc……….

so somethime may not want to use Embed tag, then u can import the Asset class inside and extends by yrself!

Posted in 編程

Flash game framework (one is for pixel game!)

flixel is a flash game framework for pixel games

flashpunk is a flash game framework~~~

Posted in 編程

as3 event bubbling notice

The event can only bubble up through the display list if the object that dispatched the event is a DisplayObject (or an ancestor of DisplayObject, such as a Sprite or MovieClip) so that it can be in the display list AND it is added to the display list at the time of the event dispatch.

唔係你係類面 new 個 instance ,佢就識玩 bubble

而係 addChild 落個 displaylist 到先識玩 bubbling

new object 個個你就要一層層咁自己 dispatch~

Posted in 編程

edwin 介紹的 web host

Posted in 編程

Flash compile exe -> Flash player 可選!

最新既 flash player 10 多左個 digital cert 功能,可惜的是 IE 去開既時候會鬧你無正確既 digital cert,咁點解決呢

1. 用 zip -> sfx 既方法,IE 就唔當 flash player 開

2. compile 既時候,換個 flash player,用 無cert 既 9 或者用 10 既 debug version (但希望你個 program 無 bug,唔係出 error)


program files -> flash -> player

換左類面個 player 佢

export 出黎既 exe 就係包呢款 player,

(projector 原理: 包個 flash player,叫佢開個 swf 之嘛)

無 cert 既 projector 就過關了!

Posted in 無分類

2D Array -> 1D Array -> Vector -> bitwise Vector 越黎越快


Posted in 編程

Debug Monster

a very good debug tool for writing as3

Posted in 編程

K2, a view framework for wordpress

Posted in 編程

Design pattern for as3 Blog

Posted in 編程

Interface trick (main swf –> load external swf and want to call it function)

同場讀埋,interface 有咩用?

Posted in 編程

模擬 multiple inheritance

用 implement interface + #include 去摸擬

實際上佢 implement 個 interface,但只有 function 名,對嘛

然後每個要 (扮) extends 個個 class implement 完左 #include 一定要個d functions,

咁咪一定要用個d function 囉?

咁就 == 一定有個堆 function 兼 function 名 及可以用 is 等等

咁就可以無限 (扮) extends!

(not a gd practice, btw)

Posted in 編程

AS3 的一些怪野,必睇

Posted in 編程

Many Great resources, 最正係 MC transform

Posted in 編程


呢個 library 可以一次過抽起曬 d definition 出黎 new

Posted in 無分類

Playing Audio with Flash 我由呢個 demo 開始睇 有呢個好正既 sound filter, 識做 echo, phase, feedback, cutoff, resonance 個d effect

用 pixelBlender Mix 歌

載入 mp3

Posted in 編程

有擬似 bindable for Flash 既 library (explanation) (src)