as3 – DanDev.com http://www.dandev.com Tidbits about software development Sat, 26 Oct 2013 00:24:13 +0000 en-US hourly 1 Add a click event to a BitmapImage in Adobe Flex/AIR http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/ http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/#respond Wed, 05 Oct 2011 04:00:29 +0000 http://www.dandev.com/?p=215 You may have noticed MouseEvent.Click is not an event available to be set on the BitmapImage Spark primitive(in the current Flex SDK). But, there is a simple workaround for this. […]

The post Add a click event to a BitmapImage in Adobe Flex/AIR appeared first on DanDev.com.

]]>
You may have noticed MouseEvent.Click is not an event available to be set on the BitmapImage Spark primitive(in the current Flex SDK). But, there is a simple workaround for this. All you have to do is place it inside of a Graphic primitive wrapper. In MXML it would look like this:



	
	
		
	
	
		
	
	
	
		
			
		
	
	

Flex Builder Project

In AS3 it looks like this:



	
	
		
	
	
		
	
	
	
	
	

Flex Builder Project

The post Add a click event to a BitmapImage in Adobe Flex/AIR appeared first on DanDev.com.

]]>
http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/feed/ 0
Flex Tip: Accessing your AS functions/properties from imported classes http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/ http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/#comments Mon, 25 May 2009 22:54:10 +0000 http://www.dandev.com/?p=151 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 […]

The post Flex Tip: Accessing your AS functions/properties from imported classes appeared first on DanDev.com.

]]>
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()
        {
            // Flex 4
            import mx.core.FlexGlobals; // make "FlexGlobals" available in the current scope
            trace(FlexGlobals.topLevelApplication.myVar); // outputs the value of myVar in the main application

            // Flex 3
            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.

The post Flex Tip: Accessing your AS functions/properties from imported classes appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/feed/ 1
Flex/AIR Tips: Keyboard Codes http://www.dandev.com/2009/03/flex-tips-keyboard-codes/ http://www.dandev.com/2009/03/flex-tips-keyboard-codes/#respond Tue, 10 Mar 2009 09:40:22 +0000 http://www.dandev.com/?p=132 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 […]

The post Flex/AIR Tips: Keyboard Codes appeared first on DanDev.com.

]]>
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

The post Flex/AIR Tips: Keyboard Codes appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/03/flex-tips-keyboard-codes/feed/ 0
Flex: getType() schmettype http://www.dandev.com/2009/03/flex-gettype-schmettype/ http://www.dandev.com/2009/03/flex-gettype-schmettype/#comments Sun, 08 Mar 2009 00:31:54 +0000 http://www.dandev.com/?p=112 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 […]

The post Flex: getType() schmettype appeared first on DanDev.com.

]]>
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. 🙂

The post Flex: getType() schmettype appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/03/flex-gettype-schmettype/feed/ 9