09.01.07
Posted in Flash, Flex, quicktip at 7:28 am by Curtis J. Morley
Flash / Flex Tutorial - How to Create a crossdomain.xml file.
This brief tutorial will teach you how to create a crossdomain.xml file so that you can access files and information from outside domains and load files and data within your Flash / Flex apps. It is as simple as 4 easy steps.
- Create an xml file named crossdomain.xml. (XML can be created with Dreamweaver or just simply MS Notepad. Just make sure that you give it the '.xml ' extension on the end.)
- Copy and paste one of the code examples below into the XML file:
- Save the file.
- FTP / upload the file to the root directory of your website. (you should be able to see the file in a browser by typing the url www.yourwebsite.com/crossdomain.xml).
XML Code 1:
This is a typical crossdomain.xml file. Notice that I included my domain as well as my domain without the 'www' in front.
<?xml version="1.0"?><!DOCTYPE cross-domain-policySYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.curtismorley.com" />
<allow-access-from domain="curtismorley.com" />
</cross-domain-policy>
XML Code 2:
The follwing Code will allow all domains. This effectively eliminates any security that Flash would have otherwise had. I suggest that you don't use this example unless you enjoy security holes.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
XML Code 3:
The block of code below will explicitly disallow any and all access from any outside domain. As well, any domain that is not spelled exactly how the host domain is spelled will be blocked. This is the tighest cross domain security that you can employee.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
</cross-domain-policy>
XML Code 4:
The code below illustrates different uses of the '*' wildcard symbol. This is the crossdomain.xml file from Amazon.com The wildcard allows for any variation before '.amazon.com'. Amazon does this because of the public services and APIs that it allows others to connect to.
<cross-domain-policy>
<allow-access-from domain="*.amazon.com"/>
<allow-access-from domain="amazon.com"/>
<allow-access-from domain="www.amazon.com"/>
<allow-access-from domain="pre-prod.amazon.com"/>
<allow-access-from domain="devo.amazon.com"/>
<allow-access-from domain="images.amazon.com"/>
<allow-access-from domain="anon.amazon.speedera.net"/>
<allow-access-from domain="*.amazon.ca"/>
<allow-access-from domain="*.amazon.de"/>
<allow-access-from domain="*.amazon.fr"/>
<allow-access-from domain="*.amazon.jp"/>
<allow-access-from domain="*.amazon.co.jp"/>
<allow-access-from domain="*.amazon.uk"/>
<allow-access-from domain="*.amazon.co.uk"/>
</cross-domain-policy>
Creating a cross domain policy file is just that easy.
And Happy Flashing.
P.S. I highly suggest that you read one or all of the following articles on cross domain policy files and the Flash Player security sandbox,
Crossdomain Article by Colin Moock
Adobe Crossdomain Technote (this one is required reading)
Flash Player 9 Security Whitepaper
Adobe LiveDocs on Flash Player Security
Permalink
08.25.07
Posted in errors, Flash, Flex, quicktip at 5:42 am by Curtis J. Morley
ActionScript Error #1093: Syntax error.
Update 2/25/2008
Description:
This is one of the least descriptive descriptions that Flash/Flex will provide you. It can be given for a number of reasons. Some that I have run into I have not found the reason for, but instead I just rewrite the entire line of code that it reports. One reason that I have found that is duplicate-able is copying code from the web and pasting it into Flash. Most especially code with quotes.
Fix 1:
Delete the line of rogue line of code and retype it from scratch.
Again I had this error and even after commenting the line of code out entirely I still received this error. Once more I deleted the code and retyped and it worked just fine. Below is the line of code commented out. Don't beat your head on this one. Just delete and retype. I believe that this error has something to do with the copy and paste functionality within the IDE.
Bad/Good Code 1: (this code actually works after being retyped)
/*//stage.removeEventListener(Event.ENTER_FRAME, moveCar);*/
Fix 2:
Delete the quotes from the code that you copied from the web and replace them with regular quotes.
Bad Code 2:
this.thePlayer.videoSource = "main_video.flv";
Good code 2:
this.thePlayer.videoSource = “main_video.flv”;
Fix 3:
Delete the #(pound symbol) before the color value.
Bad Code 3:
graphics.lineStyle(1, #FFFFFF);
Good code 3:
graphics.lineStyle(1, 0xFFFFFF);
Thanks to grildcheese who left a comment about Fix3 above.
Fix 4:
Do not use #include in ActionScript 3 instead use import.
Bad Code 4:
package
{
#include "myClass.as"
Bad Code 4:
package
{
import myClass;
I will continue to post reasons for AS3 error 1093 as I find them and hopefully it will help you out.
As Always, Happy Flashing
Permalink
08.22.07
Posted in errors, Flash, Flex, quicktip at 5:43 am by Curtis J. Morley
I added a few more examples and a little more definition to ActionScript 3 Error #1078. There are now three code examples instead of just one and more in depth explanations to this error. I hope this helps you solve AS3 Error #1078.
ActionScript 3 Error #1078
Permalink
08.21.07
Posted in errors, Flash, Flex, quicktip at 8:43 pm by Curtis J. Morley
ActionScript Error: 1086: Syntax error: expecting semicolon before mult
Description:
This is a very easy and straightforward error with a horrible description. It actually has nothing to do with a semicolon at all. All this error means is that you forgot a '.' in your import before the '*'.
Fix:
Add the Dot
Bad Code:
import flash.events*;
Good Code:
import flash.events.*;
Hopefully the confusing description for this ActionScript Error didn't cause you to pull your hair out.
As Always Happy Flashing
Flash Error #1086: Syntax error: expecting semicolon before dot.
Description:
Another reason for the Flex / Flash Error #1086 is because a function/method call is typed. It is very important to type a function but do not type the call to the function.
Fix:
Remove the typing at the end of the method call.
Bad Code:
resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail):void;
Good Code:
resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail);
Happy Flashing
Permalink
08.20.07
Posted in Computers, errors, Flash, Flex, quicktip at 11:01 pm by Curtis J. Morley
ActionScript Error #1053: Accessor types must match.
Description:
This is a great error that has absolutely no documentation. This is what Adobe has to say about it.

Notice how the right side of the image doesn't have any text at all. It is simply left blank. To understand this error you need to understand what an 'Accessor' is. An 'Accessor' is a 'Getter' that accompanies a 'Setter'. The reason it is called an 'Accessor' is because it accesses the variable set using a 'Setter'.
So what does that mean for you. This error means that the Getter(Accessor) is not set as the same Type as the Setter.
Fix:
Make sure that whatever you return in the 'Getter' is the same 'Type' as what is set in the 'Setter'.
Bad Code:
function get sClickable():String {
return _clickable.toString();
}
function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}
Good Code:
public function get sClickable():Boolean {
return _clickable;
}
public function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}
So now you know how to solve ActionScript Error #1053.
As Always Happy Flashing.
Permalink
08.11.07
Posted in errors, Flash, Flex, quicktip at 6:39 pm by Curtis J. Morley
Error #1119 is a tricky little fella and has a few reasons why it will appear. I have added new and valuable info to the original post.
http://curtismorley.com/2007/06/13/flash-cs3-flex-2-as3-error-1119/
Thanks and Happy Flashing
Permalink
07.09.07
Posted in errors, Flash, Flex, quicktip at 10:46 pm by Curtis J. Morley
ActionScript Error #5001: The name of package 'com.cjm' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file
Description:
This ActionScript error is a very common one especially if you haven't defined a good package and class structure. The simple answer is that you misspelled something in your package description or you saved the class in the wrong folder. (See example 1)
Another reason that you can get this error in Flash is because you have a Document Class and you have specified the classpath in the "Document class:" field and you have something different typed in your package. You might say well that is not possible. If your default classpath is defined in the AS3 setting then the file will compile and the class will work properly if you remove the classpath all together out of your package. This is not recommended because it is not good practice. Please review the example2 below.
Solution:
Check your paths in the package, class and 'Document Class'.
Example 1
Bad Code
package com.ckm
{
}
Good Code
package com.cjm
{
}
Example 2
Good Code - Bad "Document class:" definition
package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}

Good Code - Good "Document class:" definition
package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}

And those are two ways to resolve ActionScript Error #5001
As Always - Happy Flashing
Permalink
07.07.07
Posted in errors, Flash, Flash Remoting, quicktip at 12:02 am by Curtis J. Morley
ActionScript 3 Error #1017: The definition of base class ImportedClass was not found.
Description 1
You may get this error from importing a custom class that does not have the proper package path into a parent class. Another reason you will get this error is if you forget to import the Class that the subclass is extending(see example 2).
Bad Code 1
(subClass called ImportedClass)
package
{import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
Parent Class called ImportingClass
package com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
Good Code 1
(SubClass called ImportedClass)
package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
ImportingClasspackage com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
Bad Code 2
package com.cjm
{
//import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
Good Code 2
package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace("Message");}}}
Description 2
ActionScript Error #1017: The definition of base class MovieClip was not found.
This ActionScript Error is due to forgetting to import the MovieClip (or any other referenced class).
Bad Code 3
package com.cjm.sound
{
public class SoundControl extends MovieClip
Good Code 3
package com.cjm.sound
{
import flash.display.MovieClip;
public class SoundControl extends MovieClip
As always - Happy Flashing
Permalink
07.05.07
Posted in errors, Flash, Flex, Loops, quicktip at 1:31 am by Curtis J. Morley
Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Problem:
You have entered the realm of "Flash Infinite Loop" or at least a really long loop. This is very common when running loops, especially do...while loops. The timeout is now set to 15 seconds (see image below).

Fix:
Make sure that you are not executing a loop that will never break out. Those poor loops running in circles for all of us Flashers/Flexers.
*******************Warning*******************
The Bad Code below will send your Flex/Flash into and infinite loop and will potentially crash your Development Tool. DO NOT COPY and PASTE the BAD CODE EXAMPLES BELOW.
Bad Code:
var myLength:int = 2;
for (var i:int = 0; i < myLength ; i--);
trace(i);
}
Good Code:
var myLength:int = 2;
for (var i:int = 0; i < myLength ; i++);
trace(i);
}
The code examples above have the var i starting with a number that is smaller than the number it is trying to iterate to. This code basically says as long as i is smaller than myLength then loop and each time I loop make i even smaller.
Bad Code:
*********This code crashed my Flash multiple times.*******
var myArray:Array = ["joe", "bob","pam"];
var randNum:int = Math.round(Math.random()*myArray.length-1);
var curNum:int = 1;
do {
trace(randNum);
} while (randNum == curNum);
The key to using do...while loops in Flash is to make sure that the variable that you are validating against is changed inside the loop itself. Unless the variable that you are validating against changes within the loop itself it will loop forever. This example of a do...while loop is valid but will very likely put Flash into an infinite loop because the likelihood that the number will be 1 is very high, especially considering that the code is rounding and the number 1 is the middle digit of the three. This loop can execute quickly if Flash happens to choose another number or it can loop infinitely. The reason you might be doing this kind of loop is because you want to pull things out of an array, xml, or some other list and don't want to get duplicates. A better way to do this is to either use the splice() methods in Flash or Flex or if you don't want to affect the original array you can slice() out a duplicate without the curNum value and then the value will never be repeated because it no longer exists in the items that you are evaluating against. That way you know for sure the item that you don't want repeated is gone.
There are many other ways to run into an infinite loop. These are just a couple. Feel free to post any questions you have in the comments section and I will answer them promptly.
Thanks and Happy Flashing.
Permalink
« Previous Page « Previous Page Next entries »