DanDev.com

Author Archive

Flex HDividedBox/VDividedBox divider double-click event oddity

by admin on Dec.01, 2009, under Development, Flex, Software

I ran across an interesting case today while looking into an issue for someone else related to capturing the double-click event on the divider for a HDividedBox. It’s a little tricky to get the event to be captured by Flex. A quick search of the interwebs turned up nothing but people with the same issue. There is even an open bug in the Adobe Flex bug tracker(you have to login) that seems to be the exact issue, but there is no resolution named. Through some quick experimentation I figured out you can get it to work like so:

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
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute"
    width="600" height="588"
    applicationComplete="start()">
    <mx:HDividedBox id="divBox" 
    	height="100%" width="99%"
    	liveDragging="true"
    	doubleClickEnabled="true">
          <mx:Canvas width="50%">
          		<mx:Text text="Some example text" />
          </mx:Canvas>
          <mx:Canvas width="50%">
          		<mx:Text text="Some example text" />
	      </mx:Canvas>
     </mx:HDividedBox>
     <mx:Script>
          <![CDATA[
               private function start():void {
                    divBox.getDividerAt(0).addEventListener(MouseEvent.DOUBLE_CLICK, handleDoubleClick);
               }
 
               private function handleDoubleClick(e:MouseEvent):void {
                    Alert.show('Event captured!');
               }
          ]]>
     </mx:Script>
</mx:Application>

The specific resolution was to enable liveDragging and add the event to the divider itself(most people try to set it on the doubleClick property of the DividerBox).

Hopefully this post will be helpful to some people out there with the same issue!

3 Comments :, , , , , , , , more...

GAIQ Certified!

by admin on Nov.15, 2009, under Development, Software

So, I took the GAIQ certification test the other day and passed. It was a little harder than I expected, but not too crazy. I definitely recommend you watch all of the Google Conversion University videos about GA and be ready to look things up if you aren’t sure. A lot of the questions were common sense, but there were a few tricky ones that required some advanced knowledge.

Leave a Comment :, , more...

Flex Tip: Accessing your AS functions/properties from imported classes

by admin on May.25, 2009, under Development, Flex

Every once in a while you might run across a case where you need to access a property or method from the parent application, and you don’t have the ability to pass the value you need to the class. Or, for example, you’re debugging and you don’t want to write a bunch of code that you’ll have to remove later just to test the value of a variable.

So, with that said the process is fairly simple. The following is a hypothetical example of a class you have imported into your application:

package com.example.scope
{
    private var myVar:String = 'This is NOT the value we're trying to get';
 
    public class scopeExample
    {
        public function scopeExample()
        {
            import mx.core.Application; // make "Application" available in the current scope
            trace(Application.application.myVar); // outputs the value of myVar in the main application
        }
    }
}

You could also use:

trace(parentDocument.myVar); // if the component is a child of the main application

I ran across a post on Holly Schinsky’s blog the other day that had good descriptions of the various scope keywords, and a few tips. All of which is good knowledge to possess, so check it out.

1 Comment :, , , , more...

PunkBuster Invalid O/S Error on Vista

by admin on Mar.20, 2009, under Games, Life, Software

Just a quick note, for anyone having trouble playing games that have Punkbuster integrated with it. If you’re getting an “Invalid O/S Error” when you try to join a server, this is related to the game not having enough permissions to  open/alter certain files. There have been several fixes suggested, and some work for some people… some work for others. The one that seems to solve most people’s problem is running the game as an administrator. Simply being logged in as an administrator isn’t enough because your programs are still executed with limited privileges. You just have to confirm it when they’re needed(if you have UAC enabled).

To run as administrator you have a couple of options.. if you’re running a home version of Vista, you might not have some of them:

  1. Right-click on the Shortcut or game executable and click Run as Administrator
  2. Right-click on the game executable and Click Properties->Compatibility->Check the “Run as Administrator” box, Apply
  3. Right-click on the Shortcut, Click the “Shortcut” tab->Advanced, Check the “Run as Administrator” box, Apply

Now, with that said, none of these would work properly for me. The only solution I could find that would work is downloading this update from PunkBuster, adding my game, and hitting Update. Once updated the game ran fine without giving it extra privileges.

Good luck!

4 Comments :, , , , more...

Flex Tips: Keyboard Codes

by admin on Mar.10, 2009, under Development, Flex

If you ever have the urge to capture a specific key pressed in Flex or AS3 in general, there is an excellent list of the keycodes, and costants you can use to represent them in your code here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html

3-10-2009-5-36-24-am

You can use them statically(without instantiating an object) like so:

trace(Keyboard.TAB); // 9
Leave a Comment :, , , , , , , more...

Optimizing the SWF filesize for your Flex App

by admin on Mar.08, 2009, under Development, Flex, Pics

While wandering through the ginormous forest that is Flex I’ve noticed how the filesize grows exponentially when you start to add a lot of content, or some external libraries. This is annoying, especially when the app I’m making is supposed to be used by a large group of people at the company I work for. So, I went looking for ways to slim it down, and I have found a couple of gems that work really well. First of all there is an excellent video posted by Serge Jespers of the Adobe Platform Evangelism – European team that gives some detailed tips with an example of how to make your application smaller with Flex Builder.

Namely:

  1. Use “Release” build — by default the SWF is built with Debug mode and has debug & profiler code in it that your application doesn’t need.
  2. Move your panels into modules(see movie)
  3. Use the RSLs instead of compiling the Flex framework into your SWF

Using these suggestions has removed over 500K from my app.

The video shows you how to do all of these in Flex Builder.


Here is how you can perform the same optimizations in FlashDevelop:

Number 1 is fairly easy: Just find the only drop-down menu in the main interface, and change it from “Debug” to “Release”.

tip1

With number 2 you follow the same instructions, but you can get to the menu to add an item by right-clicking on your project in the “Project” pane of the right column, or by going to “File”->”New”.

tip2

Number 3 is slightly more complicated. First you need to get to your project’s properties menu, which you can do one of several ways. Here is a screenshot of going through the “Project” menu:

tip3-1

Then, click on the “Compiler Options” tab, and select the “Advanced Compiler Options” by clicking on it and clicking the “…” button. Then add the line “-static-rsls=false” to it as shown(or append it on a new line if you have other options set already).

tip3-3

Now, you have to copy the “framework_3.2.*.swf” and “framework_3.2.*.swz” files to the “bin” directory in your project, and upload them to your site when you upload your app. These contain the Flex framework that will be cached by the Flash Player when you run your app. They are located in “flex_sdk_3\frameworks\rsls” in the Flex 3 SDK folder. Note that whatever version of the SDK you compiled your app with is the version you have to use the RSLs from. If you compile your app on on build, and then try to use the RSLs from another one(ie. you switched machines/reinstalled the sdk/use another ide that uses a different sdk version, etc.) you will get a message when your app loads about RSL 1 loading(but it never will). So, if you reinstall the SDK, or any of the things I mentioned recompile your app with the new version. *phew*

I hope these tips are helpful to you!

2 Comments :, , , , , , , , , , more...

Flex: getType() schmettype

by admin on Mar.07, 2009, under Development, Flex

I’ve started dabbling in Flex recently, and something that was apparent(and annoying at times) to me  early on was it’s strongly-typed nature. Not type as in a keyboard, but variable types. Flex cares very much whether your variable is an Array, or ArrayCollection as it’s knowledge of types is key to it’s processing. This is quite the converse to a language like PHP, which is loosely-typed to say the least.

Anyway, I came upon a case where I needed to know the type a variable was so I could cast it properly(and for debugging), and I found that Flex doesn’t have a function to simply return a variable’s type. There is describeType(), but this returns an XML object with all of the information about the variable — not just the type. Plus you have to import the proper class to use it. So, I threw together this function quickly that will perform the import, and return/alert the type as needed:

private function getType(value:*, alert:Boolean = false):String
{
	import flash.utils.*;
	var description:XML = describeType(value);
	if(alert)
		Alert.show(description[0].@name);
	return description[0].@name;
}

I hope someone else can find it useful. :)

3 Comments :, , , , , , more...

Fatal error: Cannot redeclare pclziputilpathreduction()

by admin on Jan.25, 2009, under Development, PHP, WordPress

I’ve seen this in a couple of places already, so I’ll go ahead an post it: If you’re getting an error with your WordPress install similar to: “Fatal error: Cannot redeclare pclziputilpathreduction()” and you’re using WP 2.7+, disable your WPAU – WordPress Automatic Upgrade plugin. This error is caused because in version 2.7 WordPress added the ability to update itself, so this plugin is no longer needed. Here is an image of what the deactivated plugin should look like on the plugins page:
wpau-deactivated

Update: This appears to be fixed in the latest version of the plugin. I was able to enable the plugin and browse around without getting errors. But I don’t see the need for this plugin in WP installs newer than 2.6 anyway.

6 Comments :, , , , more...

Happy Holidays

by admin on Dec.27, 2008, under Life, PHP

I’d like to say Happy Holidays to you and yours this season. No matter your religion, race, nationality, whatever… I wish you the best in the new year.

happy-holidays-tux

PHP.net’s holiday logo was finally updated this year. The previous one was a bit dated.

12-27-2008-11-10-27-pm

1 Comment :, , more...

100cc of Browser Security, Stat!

by admin on Dec.18, 2008, under Software

Both Microsoft and Mozilla have released patches for their flagship browsers in the past 24 hours or so.

Microsoft’s patch was a response to a security hole that could allow an attacker to steal passwords from your computer using a drive-by download initiated on an infected site you might visit, or be sent to. Every version of IE, from IE5 to IE8 beta 2 is affected, so you should update immediately if you don’t use Automatic updates(or if you have it set for a long time in between updates).

Firefox versions 2 and 3 both had patches released too, though the security flaws fixed in FF were unrelated to the IE security flaw. So make sure you grab the latest version of either of those as well. Mozilla says this will be the last update to the 2.x codebase of Firefox.

Even if you don’t use either FF or IE as your primary browser, if you have either installed, update them immediately.

Leave a Comment :, , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...