This text is replaced by the Flash movie.

Flash AS3 and Mootools Slimbox

February 26th, 2010
Most the site I made were based on mootools library but when it comes to Overlay Images Scripts I prefer to use Light box v2 that also you can easily call with in Flash AS3 using the ExternalInterface.call using a bridge which is available for download - flashlightboxinjector unfortunately this is base on jQuery library so I tried to find a "Lightbox" similar Overlay Image function that has available javascript that I can call within Flash AS3 code so Slimbox I guess the easiest for me to follow, it got API documentation you can follow http://code.google.com/p/slimbox/wiki/MooToolsAPI.
So this is the code inside the flash movie
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Begin AS3 Script
  import flash.geom.*
  import flash.display.*
 
//Mouse Events  
  import  flash.events.MouseEvent;
//External Command
  import flash.external.*;
 
//gradient background color  
  var fillType:String = GradientType.LINEAR;
  var colors:Array = [0x330000, 0x333307];
  var alphas:Array = [1, 1];
  var ratios:Array = [0x00, 0xFF];
  var matr:Matrix = new Matrix();
  matr.createGradientBox(150, 20, 0, 0, 0);
  var spreadMethod:String = SpreadMethod.PAD;
  this.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);  
  this.graphics.drawRect(0,0,250,200);
//gradient background color  
 
//Add handler Event
  img1.addEventListener(MouseEvent.CLICK, onClickHandler01);
 
 
 
function onClickHandler01(myEvent:MouseEvent){
    //call	Javascript Command
	ExternalInterface.call("Slimbox.open","/images/demon.png", "This Kanji means Demon");
 
}		
 
//End AS3 Script
ExternalInterface.call("Slimbox.open","/images/demon.png", "This Kanji means Demon");
This simply calls the javascript Slimbox.open function that will open an Overlay Image also make sure that parameters that "wmode" = "transparent" and "allowScriptAccess" = "always"
I used swfobject to render my Flash movies. So here how you implement the html code to make the flash work with slimbox.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    <!-- Slimbox Start //-->
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript" src="js/mootools.js"></script>
    <script type="text/javascript" src="js/slimbox.js"></script>
    <link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />
    <!-- Slimbox End //-->
 
 
               <script type="text/javascript">
			var soSlim = new SWFObject("slimbox.swf", "slimbox", "250", "200", "8", "#FFFFFF");
			soSlim.addParam("quality", "high");
			soSlim.addParam("wmode", "transparent");
			soSlim.addParam("allowScriptAccess", "always");
			soSlim.write("flashcontentSlim");
		</script>
Demo:
Flash required


You can also try milkbox

Download Source Code.

Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

Animating View

January 20th, 2010

Make View move upward - UITextField Begin Editing


Attached is the video - what I was trying to do, it happens that my first iPhone app has UITextField positioned where the text keypad will appear also, which will hide the current UITextField. Well I realized that I will encounter this often, so I guess it's important to have this piece of code.


in your interface builder assign the UITextField as delegate

UITextField as delegate

UITextField as delegate

on your .m file declare the static constant at the top of the code.

static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 140;

after at the @implementation put this global variable to be used for all events

 CGFloat animatedDistance;

at the textFieldDidBeginEditing event

- (void)textFieldDidBeginEditing:(UITextField *)textField {
 
	CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
    CGRect viewRect = [self.view.window convertRect:self.view.bounds fromView:self.view];
 
    CGFloat midline = textFieldRect.origin.y + 0.5 * textFieldRect.size.height;
    CGFloat numerator =
	midline - viewRect.origin.y - MINIMUM_SCROLL_FRACTION * viewRect.size.height;
    CGFloat denominator =
	(MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * viewRect.size.height;
    CGFloat heightFraction = numerator / denominator;
 
 
	if (heightFraction < 0.0)
    {
        heightFraction = 0.0;
    }
    else if (heightFraction > 1.0)
    {
        heightFraction = 1.0;
    }
 
	UIInterfaceOrientation orientation =
	[[UIApplication sharedApplication] statusBarOrientation];
    if (orientation == UIInterfaceOrientationPortrait ||
        orientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        animatedDistance = floor(PORTRAIT_KEYBOARD_HEIGHT * heightFraction);
    }
    else
    {
        animatedDistance = floor(LANDSCAPE_KEYBOARD_HEIGHT * heightFraction);
    }
 
	CGRect viewFrame = self.view.frame;
    viewFrame.origin.y -= animatedDistance;
 
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
 
    [self.view setFrame:viewFrame];
 
    [UIView commitAnimations];
}

at textFieldDidEndEditing event

- (void)textFieldDidEndEditing:(UITextField *)textField {
    CGRect viewFrame = self.view.frame;
    viewFrame.origin.y += animatedDistance;
 
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
 
    [self.view setFrame:viewFrame];
 
    [UIView commitAnimations];
}

This event is textfield resign responder, once you press the return keypad it will hide the iPhone keyboard, this is important to test if the view will come back to its previous state.

-(BOOL)textFieldShouldReturn:(UITextField *) textField
{
	[textField resignFirstResponder];
	return YES;
}
Demo.
Get the Flash Player to see this player.


Download the Source


Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

Cake using Multiple Select Checkboxes

December 2nd, 2009

A sample on how to use multiple select checkbox within cakephp views and controller.

 

After reviewing the http://api.cakephp.org/file/cake/libs/view/helpers/form.php#method-FormHelperselect


1.) Inserting to database

-View Decleration Example.

1
2
3
4
5
6
7
8
9
10
11
 <?php 
//add.ctp for example
?>
     <em>How would you describe your job (mark as many as applies):   </em>
           <?php       echo $form->input('describeJob', array('label' => false,
                                                    'div' => false,
                                                    'type' => 'select',
                                                    'multiple'=>'checkbox',
                                                    'legend' => 'false',
                                                    'options' => array('Physical' => 'Physical','Mental' => 'Mental', 'Stressful' => 'Stressful',  'Easy-going' => 'Easy-going', 'Secure' => 'Secure', 'Non-secure' => 'Non-secure', 'Exhausting' => 'Exhausting', 'Relaxing' => 'Relaxing' )
                                                      )); ?>

-On your controller. Use implode php function and add a seperator that you like, for this example I use ","

1
2
3
4
5
6
 <?php 
 //job_controller @add() function
        if (!empty($this->data)) {
        $this->data['Job']['describeJob'] = implode(",",$this->data['Job']['describeJob']);
                $this->Job->create();
?>


2.) Editing part, Retrieving values of the datafield to mark check on those were choosen before. 
-View Decleration Example. In this example I used explode function of php directly in the view, notice the "selected" option added in to the $form->input helper, this will get the values, supposed to be check in that field.

1
2
3
4
5
6
7
8
9
10
<?
//edit.ctp for example
       $piecesJob = explode(",",  $this->data['Job']['describeJob']);
             echo $form->input('describeJob', array('label' => false,
                                                    'div' => false,
                                                    'type' => 'select',
                                                    'multiple'=>'checkbox',
                                                    'legend' => 'false',
                                                    'options' => array('Physical' => 'Physical','Mental' => 'Mental', 'Stressful' => 'Stressful',  'Easy-going' => 'Easy-going', 'Secure' => 'Secure', 'Non-secure' => 'Non-secure', 'Exhausting' => 'Exhausting', 'Relaxing' => 'Relaxing' ),
                                                    'selected' => $piecesJob   )); ?>

That's it :)


Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

Cake Baking Models – Cannot see other tables

November 7th, 2009

Problem.
After I updated the database, I added 1 table; relate it to another table, and go to the command line to bake what I did, after typing "cake bake model" at the command prompt, I found out that the recently added table was not listed.

Cake PHP Bake Model Problem

 

Reason.
Cake caches your model schema. 

Solution.
1.) 
Clear your cache by deleting all files in your app's tmp/cache/models/
and tmp/cache/persistent/

2.) 
Disable caching in your app's config/core.php // make sure to enable back again in production setup

/**
 * Turn off all caching application-wide.  *  
 */  
Configure::write('Cache.disable', true);

After doing the solution, I can now successfully bake the new table.


Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

RegEx and Dreamweaver

September 29th, 2009

Cleaning HTML with Dreamweaver using regular expressions. I happened to clean someone else job putting hard coded styles in font, paragraphs, span tags this is annoying cause I have to look line by line for it with a lot of HTML page to fix. From the help of RegExBuddy 3:
<%TAG%[^>]*>(.*?)</%TAG%>,
RegExBuddy 3 Small Focus

I just replace the %TAG% with font like <font[^>]*> and will find any match like <font style = "font-face:Lucida">

In Dreamweaver when you Find and Replace just check "Use regular expression".

Using Regular Expression Search with Dreamweaver

 


Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

System.NullReferenceException

August 23rd, 2009

While trying Telerik component, I got this error System.NullReferenceException - Object reference not set to an instance of an object, I struggle how to find causing this error, And somehow the solution was


From:


ddbImages.Image = ((Image)item.Tag).GetThumbnailImage(20, 20, null, new IntPtr());
ddbImages.Text = item.Text;

To:


if (item != null)
  {
    ddbImages.Image = ((Image)item.Tag).GetThumbnailImage(20, 20, null, new IntPtr());
    ddbImages.Text = item.Text;
  }

Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

EdiMax – Broadband router

March 19th, 2009
If you want to show the page you are currently working on to your client, but have no time to upload and fix some settings on the remote site and you are using Bayantel DSL broadband - you can use your PC as the host and show the website you are working on.

To do this follow these instruction:

1. Go to Status > Internet Connection - See your IP Address - this IP is live and can be view remotely
Getting Obtained IP Address

2. Then go to NAT > Virtual Server >

Check Enable Virtual Server
add the IP and PORT number

for example in the image
Virtual Server

I use Port 80 for Apache
81 for IIS
3000 for Rails

To get your Local Network IP address, open your console command prompt and type   ipconfig 
Obtain Local Network IP

Testing Rails
Webrick Rails

Once you got disconnected, your IP address will change again just do the number 1 process again to obtain your PC new IP address.

Running Rails at 3000
Webrick RORails

Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

Right way to use sql…

March 3rd, 2009
Right way to use sql join with conditions (Displaying no match data).
After hours trying to figure out what's wrong with my query for displaying list of cities with how many Lease/Sale were there. The problem was getting the cities even not yet added on Lease or Sale type, that means I need to list cities that has no match yet or 0 count.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?
global $mainframe;
$ebconfig = &$mainframe->getParams();
$prop_Type = $ebconfig->get('prop_type', "Lease");
 
 
$db_city =& JFactory::getDBO();
$query_city = "SELECT t1.city, t1.id, COUNT( t2.propCity ) AS city_count
FROM #__listing_city AS t1
LEFT OUTER JOIN #__listing_listings AS t2 ON t2.propCity = t1.city
WHERE t2.propType = '$prop_Type' AND t2.published = 1
GROUP BY t1.city
ORDER BY t1.city ASC";
?>


The code above does not display the cities that has no match on another table. The where clause was giving the problem...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?
global $mainframe;
$ebconfig = &$mainframe->getParams();
$prop_Type = $ebconfig->get('prop_type', "Lease");
 
 
$db_city =& JFactory::getDBO();
$query_city = "SELECT t1.city, t1.id, COUNT( t2.propCity ) AS city_count
FROM #__listing_city AS t1
LEFT OUTER JOIN #__listing_listings AS t2 ON t2.propCity = t1.city
AND t2.published = 1 AND t2.propType = '$prop_Type'
GROUP BY t1.city
ORDER BY t1.city ASC";
?>


Instead putting the condition on "ON Clause" after the matching table condition, fixed the problem.

Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace

Work Telephone: Paypal Sandbox

November 21st, 2008
Work Telephone: The phone number is not properly formatted.
And I'm only trying this for Registering  "Business Account" on sandbox.

This link would help click here


  Try using this format  xxx yyy zzzz (308 555 1234) to get past the code and get into the account. Then once in the account, you can update the account information to the correct phone number through Profile> phone number.

  Frank I.
  PayPal Certified Developer
  PayPal PayWatch Analyst
  http://www.paypaldeveloper.com
  PayPal, an eBay Company


The Social Security Number you entered cannot be validated.

This link would help click here


  A social security number needed to be added. This can be done by you, the number must start with '111'.

  Frank I.
  PayPal Certified Developer
  PayPal PayWatch Analyst
  http://www.paypaldeveloper.com
  PayPal, an eBay Company



Share:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter
  • RSS
  • Add to favorites
  • Yahoo! Bookmarks
  • Reddit
  • Blogosphere News
  • Socialogs
  • MyShare
  • PDF
  • MySpace