I ran into an odd issue on a project I updated awhile ago. I updated an existing sql statement to include IFNULL for an exclusion check. It worked fine on my dev machine, but caused an issue on the production machine.
The version of MySQL on my dev machine was a little bit newer than production so the issue never came up. Here is the error the sql server returned:
#1305 - FUNCTION [DATABASE_NAME].ifnull does not exist
Here is a little bit of the sql that caused the error:
AND IFNULL ( `tbl_category_admin`.`admin_key_id` =5, true )
The problem was caused by the space between IFNULL and (. Changing it to IFNULL( solved the problem. If you run into an issue where MySQL returns an error saying a given function does not exist look for spaces between the function and the "(".
Google analytics code
Monday, December 7, 2009
Monday, November 30, 2009
Flex (Learning Flex 3 Book) : Removing IEventDispatcher error from the DataGrid
When I decided to learn Flex I started with Learning Flex 3. It's a great book and does an excellent job of introducing the MXML framework and Flex Builder IDE. I would recommend it to anyone.
One of the problems I have with the book is it doesn't teach you how to remove warnings from your code. A later code example produces the following error: warning: unable to bind to property 'contact' on class 'XML' (class is not an IEventDispatcher). It's not a big deal, but I like to write code that doesn't produce hidden errors.
Here is the code from the book:
The problem is the dataProvider property of DataGrid. It's unable to figure out how to parse the data, so it throws a warning. This can be resolved with casting. We can tell the dataProvider what it should be and it will remove the warning. Here is the code that will remove the warning.
contactsService.lastResult is an XML object. There are multiple children in the object. We can then cast the XML object as an XMLList to use contact child node.
Feel free to leave a comment if you have any questions.
One of the problems I have with the book is it doesn't teach you how to remove warnings from your code. A later code example produces the following error: warning: unable to bind to property 'contact' on class 'XML' (class is not an IEventDispatcher). It's not a big deal, but I like to write code that doesn't produce hidden errors.
Here is the code from the book:
<mx: Application xmlns: mx="http: //www.adobe. com/2006/mxml" xmlns: view="com.oreilly.view.*" layout="absolute" applicationComplete="contactsService.send()" > <mx:HTTPService id="contactsService" resultFormat="e4x" url="contacts.xml" /> <mx:DataGrid id="contactsDataGrid" dataProvider="{contactsService.lastResult.contact}" selectedIndex="0" left="10" top="10" bottom="10" width="300"> <mx: columns> <mx: DataGridColumn headerText="First" dataField="firstName"/> <mx: DataGridColumn headerText="Last" dataField="lastName"/> </mx:columns> </mx:DataGrid> <view: ContactViewer contact="{contactsDataGrid. selectedItem}" x="318" y="10"> </view: ContactViewer> </mx: Application>
The problem is the dataProvider property of DataGrid. It's unable to figure out how to parse the data, so it throws a warning. This can be resolved with casting. We can tell the dataProvider what it should be and it will remove the warning. Here is the code that will remove the warning.
dataProvider="{XMLList(XML(contactsService.lastResult).contact)}"
contactsService.lastResult is an XML object. There are multiple children in the object. We can then cast the XML object as an XMLList to use contact child node.
Feel free to leave a comment if you have any questions.
Labels:
cast,
casting,
class,
datagrid,
dataprovider,
error,
flex,
ieventdispatcher,
lastResult,
learning,
warning,
xml
Wednesday, November 18, 2009
Flex: TileList cell switching/redraw problem using an itemRenderer
While working with the TileList component I ran into a very odd issue. Images would move around while scrolling up and down. Also when I updated the dataProvider the TileList didn't display the new information. Here is an example so you can see what is going on. You can view the source the source by right-clicking and selecting "View Source".
After a lot of research, and a post on StackOverflow, I figured out what was going on. My broken example relies on a MXML completion method (init, creationComplete, etc..) to set the source of the image in the itemRenderer.
index.mxml
ImageTile_bad.mxml
TileList reuses cells inside the component. I'm not sure why, but can't keep track of where things should render and starts switching images around. I tried overridding the data method and it works, but I wanted to find a solution that doesn't require overriding a private method.
The answer is to use a setter inside the itemRenderer to assign the value to the component. Here is a snip-it of code to show you what I mean.
index.mxml
ImageTile.mxml
When TileList redraws the cell it will pass data into the img setter. This will make sure that the cell receives the correct information when it redraws. Also switching the dataProvider on the TileList works properly now. Here is a link to the working example that has available source code. Feel free to contact me if you have any questions.
After a lot of research, and a post on StackOverflow, I figured out what was going on. My broken example relies on a MXML completion method (init, creationComplete, etc..) to set the source of the image in the itemRenderer.
index.mxml
<mx:Component> <itemRenderers:ImageTile_bad /> </mx:Component>
ImageTile_bad.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> <mx:Script> <![CDATA[ /** * This is an example of how not to use an item render in a TileList * */ private function init() : void { this.source = data; this.name = data.toString().split("/").pop().split(".").shift(); } ]]> </mx:Script> </mx:Image>
TileList reuses cells inside the component. I'm not sure why, but can't keep track of where things should render and starts switching images around. I tried overridding the data method and it works, but I wanted to find a solution that doesn't require overriding a private method.
The answer is to use a setter inside the itemRenderer to assign the value to the component. Here is a snip-it of code to show you what I mean.
index.mxml
<mx:Component> <itemRenderers:ImageTile img="{data}"/> </mx:Component>
ImageTile.mxml
<mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ /** * This is an example of how to use an itemRenderer in a TileList * Create a setter that will always update the when the TileList redraws * */ public function set img(value:String) : void { //make sure there is something to work with. avoid error# 1010 if(!value) { return; } this.source = value; this.name = value.toString().split("/").pop().split(".").shift(); } ]]> </mx:Script> </mx:Image>
When TileList redraws the cell it will pass data into the img setter. This will make sure that the cell receives the correct information when it redraws. Also switching the dataProvider on the TileList works properly now. Here is a link to the working example that has available source code. Feel free to contact me if you have any questions.
Labels:
creationComplete,
data,
dataprovider,
duplicate,
flex,
init,
itemrenderer,
override,
random,
redraw,
refresh,
repeat,
switch,
tilelist
Thursday, November 12, 2009
Flash / ActionScript 3: Event Bubbling Example
Previously I wrote an article that showed an example of Event Bubbling with Flex. I wanted to write a similar example for ActionScript 3. The principle is the same, but it works just a little different.
Any class involved in bubbling must extend DisplayObjectContainer. Sprite is the most basic DisplayObjectContainer class and most examples I see use it, so that's what I will use. I gave a brief overview of how event bubbling works in the Flex example that I won't repeat here.
I'm creating three classes that include each other. The primary class includes Level1. Level1 includes Level2. Level2 includes Level3. Level3 triggers an event when it's added to the stage. The event from Level3 will bubble through Level2 and Level1 to the primary class without re-dispatching it.
event_bubbling_as.as
Any class involved in bubbling must extend DisplayObjectContainer. Sprite is the most basic DisplayObjectContainer class and most examples I see use it, so that's what I will use. I gave a brief overview of how event bubbling works in the Flex example that I won't repeat here.
I'm creating three classes that include each other. The primary class includes Level1. Level1 includes Level2. Level2 includes Level3. Level3 triggers an event when it's added to the stage. The event from Level3 will bubble through Level2 and Level1 to the primary class without re-dispatching it.
event_bubbling_as.as
package { import flash.display.Sprite; import flash.events.Event; import obj.Level1; import obj.Level3; public class event_bubbling_as extends Sprite { private var _level1:Level1 public function event_bubbling_as() { _level1 = new Level1; _level1.addEventListener(Level3.EVENT, onEvent); addChild(_level1); } private function onEvent(event:Event) : void { trace('caught event from level 3'); } } }Level1.as
package obj { import flash.display.Sprite; public class Level1 extends Sprite { private var _level2:Level2; public function Level1() { trace("in level 1"); _level2 = new Level2; addChild(_level2); } } }Level2.as
package obj { import flash.display.Sprite; public class Level2 extends Sprite { private var _level3:Level3; public function Level2() { trace("in level 2"); _level3 = new Level3; addChild(_level3); } } }Level3.as
package obj { import flash.display.Sprite; import flash.events.Event; public class Level3 extends Sprite { public static const EVENT:String = "level3"; public function Level3(){ trace("in level 3"); //trigger event when the object is added to the stage addEventListener(Event.ADDED_TO_STAGE, launchEvent); } public function launchEvent(event:Event) : void { var newEvent:Event = new Event(EVENT, true, true); dispatchEvent(newEvent); } } }You can download the Flex Project Archive example here. This can be directly imported into Flex. Run it in debug mode to see how each level is triggered.
Labels:
3,
actionscript,
actionscript3,
as,
as3,
bubbling,
capture,
display,
displayobjectcontainer,
event,
eventbubbling,
eventdispatcher,
eventlistener,
events,
flash,
listener,
sprite,
targeting
Sunday, November 1, 2009
Flex: Event Bubbling Example
A refactor it gave me a chance to update the way I handled events. This page on Adobe's site explains the event bubbling model. To give a brief overview there are three phases: Capture, Targeting and Bubbling. The Capture phase will pass through each branch of a DisplayObject tree until it reaches the last node. The Targeting phase will look for objects that have event listeners bound to them. The Bubbling phase ascends the DisplayObject tree from the last node to the first node and activates the event listeners. Only DisplayObjects have a Capture and Bubbling phase.
Here is some example code I made in MXML that shows how event bubbling works. There are four files. The Application file includes Layer1. Layer1 includes Layer2. Layer2 includes Layer3. When Layer3 is created it will throw an event. The first property of the event is the string that will trigger event listeners, the second allows the event to bubble through the DisplayObject tree. The third allows the event to be canceled at any of the DisplayObjects it passes through. The event will bubble through each DisplayObject and back to the Application without manually passing it forward.
UPDATE
If you're looking for an example of event bubbling in ActionScript please view this article.
index.mxml
Layer1.mxml
Layer2.mxml
Layer3.mxml
You can download the Flex Project Archive example here. This can be directly imported into Flex. Run it in debug mode to see how each level is triggered.
Here is some example code I made in MXML that shows how event bubbling works. There are four files. The Application file includes Layer1. Layer1 includes Layer2. Layer2 includes Layer3. When Layer3 is created it will throw an event. The first property of the event is the string that will trigger event listeners, the second allows the event to bubble through the DisplayObject tree. The third allows the event to be canceled at any of the DisplayObjects it passes through. The event will bubble through each DisplayObject and back to the Application without manually passing it forward.
UPDATE
If you're looking for an example of event bubbling in ActionScript please view this article.
index.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" styleName="plain"> <mx:Script> <![CDATA[ import obj.Level3; import obj.Level1; private var _level1:Level1; private function init() : void { trace("in the base"); _level1 = new Level1; //add eventListener _level1.addEventListener(Level3.EVENT,onEvent); addChild(_level1); } private function onEvent(event:Event) : void { trace("picked up event from Level3 "); } ]]> </mx:Script> </mx:Application>
Layer1.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"> <mx:Script> <![CDATA[ private var _level2:Level2; private function init() : void { trace("in level 1"); _level2 = new Level2; addChild(_level2); } ]]> </mx:Script> </mx:Canvas>
Layer2.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"> <mx:Script> <![CDATA[ private var _level3:Level3; private function init() : void { trace("in level 2"); _level3 = new Level3; addChild(_level3); } ]]> </mx:Script> </mx:Canvas>
Layer3.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"> <mx:Script> <![CDATA[ public static const EVENT:String = "level3"; private function init(): void { trace("in level 3"); var event:Event = new Event(EVENT,true,true); dispatchEvent(event); } ]]> </mx:Script> </mx:Canvas>
You can download the Flex Project Archive example here. This can be directly imported into Flex. Run it in debug mode to see how each level is triggered.
Labels:
bubbling,
capture,
display,
displayobject,
event,
eventbubbling,
events,
flex,
listener,
mxml,
object,
targeting
Thursday, October 29, 2009
Flex: Problems reusing the HTTPService class
UPDATE: This problem occurred because of a bug in the 3.4 SDK. This bug does not exist in 3.2 or lower. I've opened a bug with adobe on the issue.
UPDATE 2: The issue has been resolved in a new nightly build of the SDK. It should be fixed when 3.6 is release.
I ran into an issue using the HTTPService object that involved removing event listeners that were added inside MXML.
Here is a snippet of code in the project. This will open an xml file and load some data into a List.
This will open another xml file and populate the TileList with images.
When loadAlbum calls send() it will call populateList first and then goto populateTilelist. removeEventListener didn't work. I posted a question to StackOverflow with the problem and got some great answers.
To get around this problem I created a HTTPService wrapper that can be reused with no issues because it's an ActionScript Class. It's very light weight, doesn't include everything under the sun, but it gets the job done in a pinch. This is the 3rd revision of the class. It's been cleaned up and there are fewer methods now.
Using the class is really simple. Use getContent and pass it the file you want to load, the format it should be loaded in and the call back you want it to call after the file is retrieved. There are two extra properties I'm not using right now, but they will be helpful in the future. The fourth parameter accepts an Object of key/value pairs to be sent with the URL.The fifth parameter lets you capture the result of an error if one occurs. The call back should accept a FaultEvent object if you want to capture the error. If you let HTTPServiceWrapper handle the error an Alert window will pop up showing the error.
This cut quite a bit of bloat out of my app and is also very reusable which saves time in the long run. The final version of this code is hosted here. You can view source on it by right-clicking in the app and selecting "View Source". Please let me know if you have any questions about it.
UPDATE 2: The issue has been resolved in a new nightly build of the SDK. It should be fixed when 3.6 is release.
I ran into an issue using the HTTPService object that involved removing event listeners that were added inside MXML.
Here is a snippet of code in the project. This will open an xml file and load some data into a List.
//this will fetch all our content. private var _httpService:HTTPService = new HTTPService; private function init() : void { _httpService.url = "stub/data/albums.xml"; _httpService.resultFormat = "e4x"; //set up http call _httpService.addEventListener(ResultEvent.RESULT, populateList); _httpService.send(); } private function populateList(event:ResultEvent) : void { //set the data provider albumsComboBox.dataProvider = event.result.album; //remove listener _httpService.removeEventListener(ResultEvent.RESULT, populateList); }
This will open another xml file and populate the TileList with images.
private function loadAlbum(event:ListEvent) : void { _httpService.url = "stub/data/" + event.currentTarget.selectedItem.@images; _httpService.resultFormat = "e4x"; //set up http call _httpService.addEventListener(ResultEvent.RESULT, populateTilelist); _httpService.send(); } private function populateTilelist(event:ResultEvent) : void { //set the data provider imageGrid.dataProvider = event.result.photo; //remove listener _httpService.removeEventListener(ResultEvent.RESULT, populateTilelist); }
When loadAlbum calls send() it will call populateList first and then goto populateTilelist. removeEventListener didn't work. I posted a question to StackOverflow with the problem and got some great answers.
To get around this problem I created a HTTPService wrapper that can be reused with no issues because it's an ActionScript Class. It's very light weight, doesn't include everything under the sun, but it gets the job done in a pinch. This is the 3rd revision of the class. It's been cleaned up and there are fewer methods now.
package util { import mx.controls.Alert; import mx.rpc.AsyncResponder; import mx.rpc.AsyncToken; import mx.rpc.IResponder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.HTTPService; public class HTTPServiceWrapper { //reference for connections private var _httpService:HTTPService; private var _alertTitle:String = "HTTPService: An error occured"; // Holds all the tokens and callbacks private var _processingQueue : Object = {}; /** * Create the HTTPService * */ public function HTTPServiceWrapper() : void { //create the service _httpService = new HTTPService; } /** * Get content from URL * @param url * @param resultFormat * @param callBack * @param request * @param returnErrorEvent * */ public function getContent(url:String, resultFormat:String, callBack:Function, request:Object = null, returnErrorEvent:Boolean = false) : void { var asyncToken:AsyncToken; var internalIResponder:IResponder; //set the url and result format _httpService.url = url; _httpService.resultFormat = resultFormat; _httpService.request = null; //check for key/value pairs to be sent in the url if(request) { _httpService.request = request; } //send the request asyncToken = _httpService.send(); internalIResponder = new AsyncResponder(onGetContentHandler,onFault, asyncToken); asyncToken.addResponder(internalIResponder); //give token unique ID asyncToken = tokenID(asyncToken); _processingQueue[asyncToken.ID] = new QueueObject(callBack,returnErrorEvent); } /** * This is the handler event for getContent. The callBack should accept a ResultEvent * * @param event * @param token * */ private function onGetContentHandler(event:ResultEvent, token:AsyncToken) : void { var queueObject:QueueObject = _processingQueue[token.ID]; queueObject.callBack(event); } /** * This is the fault event for the class. The callBack should accept a null ArrayCollection and a FaultEvent if * you want to handle the error. * * @param event * @param token * */ private function onFault(event:FaultEvent, token:AsyncToken) : void { var queueObject:QueueObject = _processingQueue[token.ID]; //handle the fault if(queueObject.returnErrorEvent){ queueObject.callBack(null, event); } else { var displayMessage:String = event.fault.faultString; displayError(displayMessage); queueObject.callBack(null); } } /** * This will add a unique identifier to a token * @param token * @return * */ private function tokenID(token : AsyncToken) : AsyncToken { token.ID = Math.random(); return token; } /** * Displays the error on a fault event in the content service * @param event * */ private function displayError(displayMessage : String) : void { Alert.show(displayMessage, _alertTitle, Alert.OK); } } } class QueueObject{ public var callBack:Function; public var returnErrorEvent:Boolean; public function QueueObject(callBack:Function, returnErrorEvent:Boolean){ this.callBack = callBack; this.returnErrorEvent = returnErrorEvent; } }
Using the class is really simple. Use getContent and pass it the file you want to load, the format it should be loaded in and the call back you want it to call after the file is retrieved. There are two extra properties I'm not using right now, but they will be helpful in the future. The fourth parameter accepts an Object of key/value pairs to be sent with the URL.The fifth parameter lets you capture the result of an error if one occurs. The call back should accept a FaultEvent object if you want to capture the error. If you let HTTPServiceWrapper handle the error an Alert window will pop up showing the error.
//http wrapper private var _httpServiceWrapper:HTTPServiceWrapper = new HTTPServiceWrapper; /** * Runs when the application loads * */ private function init() : void { //get the list of albums _httpServiceWrapper.getContent("stub/data/albums.xml", "e4x", populateList); //set event listeners for app albumsComboBox.addEventListener(ListEvent.CHANGE, loadAlbum); } /** * This will populate the album list * */ private function populateList(event:ResultEvent) : void { //if the result is null don't set it if(!event) { return; } //set the data provider albumsComboBox.dataProvider = event.result.album; } /** * This will fetch the selected album * */ private function loadAlbum(event:ListEvent) : void { _httpServiceWrapper.getContent("stub/data/" + event.currentTarget.selectedItem.@images, "e4x", populateTilelist); }
This cut quite a bit of bloat out of my app and is also very reusable which saves time in the long run. The final version of this code is hosted here. You can view source on it by right-clicking in the app and selecting "View Source". Please let me know if you have any questions about it.
Flex: New Project Settings
When starting a new Flex project there are a few settings I like to use by default.
Changes to Flex Compiler
Flex Compiler options for a project can be found by right-clicking the project and selecting properties. Select Flex Compiler from the menu on the left. The following properties should be added to the Additional compiler arguments field.
When you're reading local xml files or image you might run into a sandbox security Error# 2140 or ReferenceError Error# 1069 using the HTTPService object. Use this switch to stop the error.
-use-network=false
The loading background color of a Flex app can be changed. Use this switch to change the property.
-default-background-color [HTML COLOR VALUE]
I typically use #FFFFFF.
Changes to the Application
I like to use a simple background for Flex apps. Add this property to the mx:Application to make the background white.
styleName="plain"
Changes to Flex Compiler
Flex Compiler options for a project can be found by right-clicking the project and selecting properties. Select Flex Compiler from the menu on the left. The following properties should be added to the Additional compiler arguments field.
When you're reading local xml files or image you might run into a sandbox security Error# 2140 or ReferenceError Error# 1069 using the HTTPService object. Use this switch to stop the error.
-use-network=false
The loading background color of a Flex app can be changed. Use this switch to change the property.
-default-background-color [HTML COLOR VALUE]
I typically use #FFFFFF.
Changes to the Application
I like to use a simple background for Flex apps. Add this property to the mx:Application to make the background white.
styleName="plain"
Labels:
1069,
2140,
application,
background,
color,
command,
error,
flex,
httpService,
images,
preferences,
project,
security,
stylename,
xml
Friday, October 23, 2009
Android: Motorola Droid
This phone has caught my eye. I've had an iPhone since launch but have become a bit frustrated with it. It's a beautiful phone, but a bit of a walled garden. Android has always been interesting to me, but now it seems to be catching up with the iPhone.
I've started a wish list of things I hope the Droid will do. I'm updating it with links to articles that verify the features as time goes along.
http://spreadsheets.google.com/pub?key=tlQ3UVqx9gnphVI6h1aKTig&output=html
I've started a wish list of things I hope the Droid will do. I'm updating it with links to articles that verify the features as time goes along.
http://spreadsheets.google.com/pub?key=tlQ3UVqx9gnphVI6h1aKTig&output=html
Tuesday, October 13, 2009
Flash / ActionScript 3 / Flex : Reading browser cookies
Part of an ActionScript 3 project I was working on required me to pull cookies from the users browser into Flash. I tried hunting around google to find a good method to achieve this, but found a lot of articles that wanted you to alter the embed code for flash. I wanted to find a way inside Flash to read the users cookies.
I wrote some code to do something similar in ActionScript 2 that used LoadVars. This class has been removed in ActionScript 3.
This is the ActionScript 3 code I came up with. It uses ExternalInterface to execute a bit of javascript that will pull the cookies directly into flash. It alters the cookie string to make it look like a URL and runs it through URLVariables.
Now you can access any cookie property inside flash. Here is a quick example of how to use the class. Assume BrowserCookies.as exists in the same folder as the example class.
I've uploaded a Flex Projext Export version of this example available here. Feel free to contact me if you have any questions.
I wrote some code to do something similar in ActionScript 2 that used LoadVars. This class has been removed in ActionScript 3.
This is the ActionScript 3 code I came up with. It uses ExternalInterface to execute a bit of javascript that will pull the cookies directly into flash. It alters the cookie string to make it look like a URL and runs it through URLVariables.
package { import flash.display.Sprite; import flash.external.ExternalInterface; import flash.net.URLVariables; public class BrowserCookies extends Sprite { //this will parse the cookie data private var _urlVariables:URLVariables; /** * Return all the cookie values in one object * @return URLVariables * */ public function get urlVariables() : URLVariables { return _urlVariables; } /** * Return one cookie value * @param value String * @return String * */ public function getCookieValue(value:String) : String { var returnValue:String = ""; if(_urlVariables && _urlVariables[value]) { returnValue = _urlVariables[value]; } return returnValue; } /** * This will connect to the browser and pull cookies into flash */ public function BrowserCookies() : void{ //this will hold the data returned from javascript var browserCookieString:String; //pull the data from javascript browserCookieString = ExternalInterface.call("function(){return document.cookie}"); //replace ; with & to make it look like a url browserCookieString = browserCookieString.replace(/;\s/g, "&"); //parse the cookie string into variables. you can now access cookie variables as properties of this object if(browserCookieString) { _urlVariables = new URLVariables(browserCookieString); } } } }
Now you can access any cookie property inside flash. Here is a quick example of how to use the class. Assume BrowserCookies.as exists in the same folder as the example class.
package { import flash.display.Sprite; import flash.text.TextField; public class Index extends Sprite{ public function Index(){ //this will pull all the cookies out of the browser var urlVars:BrowserCookies = new BrowserCookies; var textField:TextField = new TextField; textField.width = 200; textField.height = 200; textField.text = urlVars.getCookieValue("today"); addChild(textField); } } }
I've uploaded a Flex Projext Export version of this example available here. Feel free to contact me if you have any questions.
Labels:
3,
actionscript,
actionscript3,
as,
as3,
browser,
cookie,
cookies,
externalinterface,
flex,
javascript,
loadvars,
urlvariables
Flash / Actionscript 3: DataFormat doesn't exist
I was looking through the ActionScript 3.0 Cookbook today and started experimenting with the URLLoader class. The example on page 437 talks about setting the format for the incoming URL. When setting the dataFormat property of URLLoader it suggests using the constant called DataFormat. The only problem is this constant doesn't exist. It's a typo.
The real value is called URLLoaderDataFormat. You can read more about it here.
The real value is called URLLoaderDataFormat. You can read more about it here.
Labels:
3,
actionscript,
as,
as3,
cookbook,
dataformat,
flash,
typo,
urlloader
Subscribe to:
Posts (Atom)