If you are creating a Silverlight document in a MAC be aware that if you create a ZIP file from the Finder context menu "Create Archive of..." every time you try to access the files inside the ZIP file with Silverlight it will fail. Why? Not sure but I would assume something to do with the way MACs compress files compared of how PCs do. One way to get around this issue is by creating your ZIP files with "DropZip", you might be able to create ZIP files with a different program that will run fine with Silverlight.
Silverlight error AG_E_RUNTIME_METHOD 2207
I am doing some testing with Silverlight (I know right!) and I kept getting error #2207 without really getting a detailed description. Well the issue -in MY case- was hat i was trying to download a file cross-domains, and with most plugins it was a no-no. So I just needed to change the source to local file.
-
Good:
downloader.open("GET", "image-4.jpg");
Bad
downloader.open("GET", "http://www.helmutgranda.com/images/image-4.jpg");
Adobe Air SQLError: ‘Error #3119: Database file is currently locked.’, details:’null’, operation:’execute’
For the longest time I was having issues with this Adobe Air Error and its description, the main issue is that the "details" for this error are "null". We do get the description that the database is locked but no details on file name where the error occur or line number.
If you do a search in the Adobe documentation you will get a pretty blank line after the error:
3119 Database file is currently locked.
To solve the issue once and for all what the error means is that you have a connection open to make changes to the database and you have opened a new connection to make more changes to the database. So there are 2 solutions
1. Use the first connection to make your second updates
2. Close the first connection and then you can use the new connection
Adobe Air CreateDirectory common error
If you need to create a directory from Air and you dont know how, mostlikely you will use the Adobe Air Documentation and use something as the following:
-
var directory = air.File.documentsDirectory;
directory = directory.resolvePath("AIR Test");
air.File.createDirectory(directory);
air.trace(directory.exists); // true
it all looks nice and makes sense but in the real world it wont work, you would get an error like this:
Type Error : Value undefined ( result of expression air.File.createDirectory ) is not object.
# of your code error.
The problem with this approach is that the createDirectory method doesnt take any parameters, if you try to pass values directly to the method you will get this error:
Argument Error : Error #1063: Argument count mismatch on flash.filesystem::File/createDirectory(). Expected 0, got 1.
Once i was able to get this error I realized that the docs were wrong, or at least on this specific section. So looking at a different sample I figured out this works:
[js]
var directory = air.File.documentsDirectory;
directory = directory.resolvePath("Air Test");
directory.createDirectory();//no parameters necessary, Air knows where we need the new directory.
[/js/]
By first "asking" Air if the directory exists then Air knows where to create the new Directory rather than passing the property directly to the method.
This applies to Adobe Air SDK 3.0 and using Javascript
Tags: Air, Adobe, Javascript, SDK
WebkitErrorDomain error 203
This error is produced in Safari for MAC and you can't view it unless you are looking at the Activity window AND you are trying to load the same file at the same time.
For example note the following:
-
loadFile1();
loadFile1();
function loadFile1() {
load("file1.swf")
}
I know this is too ovious to go un noticed, but if you have a large project you are working on there might be the possibility that you might be trying to load the same file twice and thus Safari tries to load the file twice and the error is produced.
This is what "i think" its going through Safari's little mind.
Load file1.swf
...loading
Load file1.swf
...loading .... Wait?! its the same file
STOP loading the file and trow and error!
Throw Error WebkitErrorDomain error 203
Load file1.swf
The benefit of always cleaning after yourself (AS Analogy)
When we were kids we had the pleasure of having mom, dad or an older sibling cleaning after ourselves. So if we left any dirty clothes on the floor or any dirty dishes on the table after eating any older mature adult would come up and clean up the mess.
As we grew old hopefully we were thought to clean after ourselves and also we were thought the benefits of doing so. Such as having a nice clean apartment to show off to your friends, or being able to find a wife because girls like to come to your place since it is always clean rather than knowing that if they visit you they wont know where to sit wether on top of pizza boxes or your dirty laundry on the couch. And some other benefits that your parents through rationale or fear put in your head and you have in there until today.
Now you entered the world of Actionscript programming either by choice of by accident, if you entered this magnificent world of Actionscript by choice and your teachers thought you well you were probably thought to clean after yourself just as you did at home, now if you arrived to Actionscript programming by accident you might have not known the benefits of doing a little bit of clean up after you were done working with certain items (properties). Specially if the project you are working on is small.
Not only that but if you have been working with AS1 (Actionscript 1) or AS2 (Actionscript 2) you would have flash doing all the cleaning for you. Take a look at the following example in AS2
-
// AS2
var myShirt = this.attachMovie ("Shirt", "myShirt", this.getNextHighestDepth() );
myShirt._x = 100 ;
trace(myShirt._x); // 100
myShirt.removeMovieClip();
trace(myShirt._x); // undefined
var myShirt = this.attachMovie ("Shirt", "myShirt", this.getNextHighestDepth() );
trace(myShirt._x); // 0
What a beauty! if I remove my object from the stage the _x property of the object returns as expected "undefined". So by now we have once again being spoiled by our wonderful programming parent Actionscript. Who does the cleaning for us after removing an item from the stage. Now eventually Actionscript grew up and became more like an adult that wants you to be responsible for your items and not having to clean up after yourself all the time. This is not only good but it helps you to keep track of what you are doing and how to handle different items.
Going back to the home-parent analogy we can think of this as when we were kids we didn't know neither cared of how our shirts and pants were cleaned. All we knew is that we were able to walk in our closet and find a new clean shirt or pants if we needed. Now with Actionscript you were able to do the same in AS1 and AS2. if you used an object and deleted it from the stage it would magically get washed, ironed and back into our closed for a later use.
Now lets see what happens with AS3, so lets try a very similar sample as the one above:
-
// AS3
var myShirt : Sprite ;
myShirt = new Shirt;
myShirt.x = 100 ;
addChild(myShirt);
trace(myShirt.x ); // 100
removeChild(myShirt);
trace(myShirt.x); // 100
So when I remove an item from the stage (Display List), the it stays in memory and Flash still knows its there, as you can tell on our second trace statement we were able to get the "x" property from our object even though we removed it with removeChild. So how do we "clean" after ourselves in AS3? Well we tell flash that we wont use the objects anymore by setting them to null or undefined, it just depends of what kind of object or property you are working with.
So to fix our issue we do the following:
-
var myShirt : Sprite ;
myShirt = new Shirt;
myShirt.x = 100 ;
addChild(myShirt);
trace(myShirt.x ); // 100
removeChild(myShirt);
trace(myShirt.x); // 100
myShirt = null ;
trace(myShirt.x); // see below
// we would get a beautiful error as follows in the third trace:
//TypeError: Error #1009: Cannot access a property or method of a null object reference.
// at ___fla::MainTimeline/frame1()
Success we were able to remove the object from the stage and also cleaned up after yourself. You might be thinking, how lame! I dont need to keep track of my objects since there are only 3 of them. That is fine but when you are writing an application and you have 1000 objects or better yet you add Sprites, MovieClips, Sound and Video to your application (or swf movie ) then you would be glad you learned early in the game to clean up. Remember AS3 is maturing and is not going away so this is the new standard and you must adapt to what daddy Flash is telling you to do ( or is it mommy Flash? )
Disclaimer: I have been meaning to post something about "cleaning up after yourself" for quite a while and finally decided to push this analogy live. But by no means is the perfect analogy and specially for those programmers with 100 years of experience but it is mainly to explain the basics of adding and deleting objects from the stage for those who have difficulty understanding the concept.
Documenting your classes with ASDoc in a MAC
After following different tutorials of how to run ASDoc on your computer and failing I finally was able to figure out a way to have it running with almost no issues at all, so I thought I would share my steps here for those of you still struggling with he situation.
1. First and most important install ANT on your computer.
(a) Download ANT and you can follow the command line instructions if you have Admin rights on your computer but if you don't have admin rights then you can follow these steps.
(i) After you download ANT and you have UNZIP the files open /user/local/ with a text editor that allows you to browse hidden or locked files (I used TextMate by creating a new project).
(ii) After you open the folder with your text editor, if you have the choice do a file.open source (in my case with TextMate I just right click the folder and did a "Reveal in Finder").
(iii) Dump your Unzipped files in the /user/local/ folder and now you should have something like /user/local/apache-ant.
(iv) Set a Permanent aliases for ant (another tutorial for those who do not know how to do this)
2. Download the Free Flex SDK ( At the time of this writing I used Flex3SDK Beta).
3. Place the FLEX SDK anywhere in your machine (in my case I used Applications/FLEX).
4. This step is option since you can set a permanent alias for FLEX or in my case since for some reason my aliases didn't work properly for FLEX so I just declared where the asdoc was located in my build.xml
Thats it, now to test this just run a build.xml and if everything is installed properly you should be able to have beautiful documents created by ASDoc.
Here is a Build.xml sample:
-
< ?xml version="1.0" encoding="utf-8"?>
<project name="ASDoc build" default="asdoc">
<!-- defines all values for the ASDoc compiler -->
<property file="asdoc.properties"/>
<!-- main target: cleans and compiles ASDocs -->
<target name="asdoc" depends="clean, log, create-docs"/>
<!-- deletes and recreates the asdoc directory -->
<target name="clean">
<delete dir="${output.dir}"/>
<mkdir dir="${output.dir}"/>
</target>
<!-- runs the asdoc.exe compiler on the source -->
<target name="create-docs">
<exec executable="/Applications/Flex/FlexSDK/bin/asdoc" failonerror="true">
<arg line="-doc-sources 'com/'"/>
<arg line="-main-title 'CLASS FOR TESTING'"/>
<arg line="-window-title 'Clipboard Test'"/>
<arg line="-output 'documents'"/>
</exec>
</target>
<!-- writes asdoc output to log file: log.txt -->
<target name="log">
<record name="${output.dir}/asdoc-log.txt" action="start" append="true"/>
</target>
</project>
Stop sound of loaded SWFs in AS3
Until now I didn't have any issue when removing an item from the display list until the item had sound in it. This has to do with an application I am working on which loads several SWFs and they have to be turned "on" and "off". When the SWF has to be turned off the sound has to go with it. So having the item be removed from the DisplayList was the first "answer", but of course if every listener has to be removed from any item that is being removed from the DisplayList the sound object is not an exception. But how do you do that? Again the first logic was to add a new Sound object to the loaded SWF and then control the sound in that way but that didn't fly. Looking in the docs with more detail we find the SoundTransform and here is a description "The SoundTransform class contains properties for volume and panning. The following objects contain a soundTransform property, the value of which is a SoundTransform object: Microphone, NetStream, SimpleButton, SoundChannel, SoundMixer, and Sprite"
So with that knowledge in mind now we can control the sound of the loaded SWF's and here is a sample of what I was working with.
-
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import flash.display.Loader;
import flash.utils.Timer;
import flash.media.SoundTransform;
public class SoundStopTest extends Sprite {
var loader1:Loader;
var loader2:Loader;
var mc1 : MovieClip;
var mc2 : MovieClip;
var holder:Sprite;
var mySoundTransform:SoundTransform
public function SoundStopTest() {
holder = new Sprite;
var url1:URLRequest=new URLRequest("scene6_portofino.swf");
var url2:URLRequest = new URLRequest("scene6_royalpacific.swf");
loader1=new Loader();
loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader1.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader1.load(url1);
loader2 = new Loader();
loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler2);
loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader2.load(url2);
holder.addChild(loader1);
holder.addChild(loader2);
addChild(holder);
var myTimer = new Timer(2500, 1)
myTimer.addEventListener("timer", theEvent)
myTimer.start();
var myTimer2 = new Timer(2500, 1)
myTimer2.addEventListener("timer", theEvent2)
myTimer2.start();
}
private function completeHandler (e:Event ) {
mc1 = MovieClip(loader1.content);
mc1.gotoAndPlay(2);
}
private function completeHandler2 (e:Event ) {
mc2 = MovieClip(loader2.content);
mc2.gotoAndPlay(2);
}
private function theEvent(e:TimerEvent) {
mySoundTransform = new SoundTransform();
mute();
}
private function theEvent2(e:TimerEvent) {
// holder.removeChild(loader1); Uncomment if you want control of one item instead of all
// holder.removeChild(loader2); Uncomment if you want control of one item instead of all
removeChild(holder);
}
function mute():void {
mySoundTransform.volume = 0;
// mc1.soundTransform = mySoundTransform; Uncomment if you want control of one item instead of all
// mc2.soundTransform = mySoundTransform; Uncomment if you want control of one item instead of all
holder.soundTransform = mySoundTransform;
}
private function ioErrorHandler(event:IOErrorEvent):void { }
}
}
One thing that you will notice is that I muted two movies at once by adding two movies into one item and then controlling the volume of that single item. The reason why am I doing it this way is because I need control of one movie at the time as also control of all movies together.
Another thing you will notice is a Timer Event, that was just added to enhance my testing but doesn't have to be used in this way.
Error #1063 When loading XML
If you get the following error when loading XML and trying to get the node attribute: ArgumentError: Error #1063: Argument count mismatch. It could be that you typed attributes instead of attribute.
Comments