Compare 2 arrays with AS 3

The following function compares the values ​​of two arrays and returns another array with different values​​.

private function checkArrays(array1:Array,array2:Array):Array {
    var array3:Array=new Array();
    var length1:int=array1.length;
    var none:Boolean=false;

    for(var i:int=0;i < length1;i++) {
        var length2:int=array2.length;

        for(var j:int=0;j < length2;j++) {
            if(String(array1[i])==String(array2[j])) {
                none=false;
                break;
            }
            else {
                none=true;
            }
        }
        if(none) {
            array3.push(array1[i])
            none=false;
        }
    }
    return array3;
}


Getting Flash Working on Android, Jelly Bean

images

Some popular video providers have not transitioned to HTML5, so if you still want Flash on your phone/tablet, there are ways around it — just keep in mind that this is not recommended by Adobe and that the experience with the plugin. Also note that downloading the Flash Player apk file from unofficial sources could open the gates to malware on your phone or tablet, so it’s not recommended to get the file from third-party sources.

The best source to download a working official version of Flash player is from Adobe’s own site. Download the latest version (Flash Player 11.1.for Android 4.0 (11.1.115.36)) Once you downloaded the apk file, you need to transfer it to you device.  A great free application that will help is “App Installer” you can get this from the Google Play store. Make sure you download this app!

Using “App Installer” find the flash player apk file, open the player  It will most likely say unknown sources.  Click on settings and check the unknown sources box, click on the flash player again and install it.

Now that Flash Player is installed, go to your browser (Not Chrome), and change some settings. Go to advanced, and make sure “enable plugin is always on!”

I did this myself on my galaxy S III and my Galaxy Note 10.1 Tablet.

Have Fun!

41hR2NAaK2L

AS3 Drawing Pad Awesomeness

This is another project that I’ve been putting off. It really should have some kind of bitmap merging/drawing going on to allow for a greater number of shapes, but I think it would work just fine for anything a guest would want to spend time on. Just don’t try to recreate the Sistine Chapel ceiling and you’ll be fine 🙂

[kml_flashembed publishmethod=”static” fversion=”8.0.0″ movie=”http://johnbarrett.net/wp-content/uploads/2013/01/DrawingPad.swf” width=”400″ height=”300″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Jelly Bean Update for Samsung S III

It looks like Android Jelly Bean will finally be hitting one of the most prolific phones in the United States. Samsung has finally acknowledged that a Jelly Bean update is on its way to U.S. Galaxy S3s.

A Samsung update page lists the Jelly Bean update as “Coming Soon!” for AT&T, Sprint, Verizon, T-Mobile, and U.S. Cellular. These are the five carriers that offer the Samsung Galaxy S3 in the United States.

Leaked ROMS of the Jelly Bean update have been available for a while, but for those who wouldn’t like to void their phone, this is good news.

Official Android 4.1 Jelly Bean updates have started rolling out internationally around a  week ago. The first (and only country so far) to receive it has been Poland. More will follow, and it’s a good bet that Galaxy S3 owners worldwide will all have the Jelly Bean update by the end of the year.

For a real-time updated list check out YouMobile.

Android 4.1 Jelly Bean is not a complete overhaul to Android 4.0 Ice Cream Sandwich, but it offers some noticeable improvements. Jelly Bean will introduce a smoother interface without the stutters that often plague Ice Cream Sandwich, and a Siri-like voice assistant dubbed Google Now.

Samsung is also planning on updating its other popular phones such as the Galaxy S2 and the Galaxy Note. Samsung recently listed 16 devices, including a few tablets that will receive an Android 4.1 Jelly Bean update. Samsung’s Galaxy Note 2 will ship with Android 4.1 Jelly Bean right out of the box.

Flash keyboard Shortcuts

Want to cut your Flash development time in half?

If you answered yes, then you’ve come to the wrong place. On the other hand, if you’d like to moderately improve your efficiency and save yourself a little time, then it would be well worth your time to learn a few keyboard shortcuts that will save you many a mouse click. Below is a list of some of the keyboard shortcuts that I use most often. It may be helpful to print these out and thumbtack them to your wall.

Note: The following keyboard shortcuts are written for Mac users with PC shortcuts in parentheses.

  • The Help Menu – F1 – Who doesn’t need a little help from time to time? In addition to using this keyboard shortcut, getting acquainted with the Help documentation in Flash can greatly increase your productivity. Instead of thumbing through the indexes of all your Flash and Actionscript books, try searching the Help documentation first. You may be surprised at how much time this could save.
  • The Actions Panel – Opt+F9 (just F9 for PC) – This shortcut will serve to open and close your actions panel. Just click on the frame where you want to add your actions and hit Opt + F9 to open it up.
  • The Toolbar – Each tool on the toolbar (the tall, narrow panel on the left side of the screen with all the drawing tools on it) has a keyboard shortcut of its own. To see what these shortcuts are, simply hover over each of the tools until a tooltip pops up. The tooltip will show the name of the tool, followed by the keyboard shortcut in parenthesis. Even though it may slow things down at first, try to get used to using these shortcuts any time you switch between tools. Before you know it, these shortcuts will become secondhand. One toolbar shortcut you may find yourself using quite a bit is the “V” key, which turns on the Selection Tool.
  • Copy, Cut, and Paste – I almost decided not to include this one, considering these shortcuts are pretty much the same no matter what program you’re using; however, since they’re used so often, I thought I’d go ahead and include.
    • Copy – Cmd+C (Ctrl+C on PC) – Copies a selected object to the clipboard
    • Cut – Cmd+X (Ctrl+X) – Removes an object from the stage and copies it to the clipboard
    • Paste – Cmd+V (Ctrl+V) – Pastes an object from the clipboard onto the center of the viewing area
  • Paste in Place – Cmd+Shift+V (Ctrl+Shift+V) – The “paste in place” command pastes an object on the stage in the exact same location it was in when it was copied or cut. This can save you a lot of time since you don’t have to worry about positioning the object after pasting it.
  • Copy, Cut, and Paste Frames – Copying and pasting frames in the timeline requires a different set of commands than simply copying and pasting objects on the stage. The keyboard shortcuts for these commands are easy to remember. Simply add the Option key (Alt key for PC) to the normal copy, cut, and paste commands.
    • Copy Frames – Cmd+Opt+C (Ctrl+Alt+C)
    • Cut Frames – Cmd+Opt+X (Ctrl+Alt+X)
    • Paste Frames – Cmd+Opt+V (Ctrl+Alt+V)
  • Insert Frame – F5 – Simply click on a frame and hit F5 to insert more. To insert frames for all layers at once, click on the red, rectangular playhead for the desired frame at the top of the timeline and hit F5.
  • Delete Frame – Shift+F5
  • Insert Keyframe – F6 – This inserts a new keyframe that contains a copy of all the contents of the previous keyframe (if one exists).
  • Clear Keyframe – Shift+F6 – This doesn’t remove any frames from the timeline. It simply clears out the selected keyframe, replacing it with normal frames that serve as an extension of the previous keyframe.
  • Insert Blank Keyframe – F7 – If you need a new keyframe but don’t want any content in that keyframe, use the “insert blank keyframe” command.
  • Step to Next Frame – . – By hitting the period key while working on the stage, the playhead will advance to the next frame.
  • Step to Previous Frame – , – The comma key will move the playhead backwards one frame.
  • Test Movie – Cmd+Return (Ctrl+Enter) – This opens a new window with a preview of your compiled Flash file.
  • Group – Cmd+G (Ctrl+G) – This command groups objects together so that other objects on the stage cannot interfere with them.
  • Ungroup – Cmd+Shift+G (Ctrl+Shift+G) – Ungroups grouped objects. Simple enough.
  • Break Apart – Cmd+B (Ctrl+B) – Breaks an object, symbol, or text field down into a raw shape. If you’re dealing with a text field, then the first time you use the “break apart” command, Flash will simply break your text field into multiple text fields . . . one text field for each letter. If you want to break the individual letters down into raw, editable shapes, simply use the “break apart” command a second time. Just make sure you have everything spelled right before you do this. Once you break it down, you can no longer edit the text.
  • Distribute to Layers – Cmd+Shift+D (Ctrl+Shift+D) – If you select multiple objects on the stage and use the “distribute to layers” command, then each item selected will be removed from the current layer and placed in a properly-labeled new layer. If you select only a single object, this command will simply move this object to its own layer.
  • Select All – Cmd+A (Ctrl+A) – If you hit this shortcut and nothing happens, it might help to choose the selection tool (keyboard shortcut “V”), click on an empty area of the stage, and then try the command again. (Also, make sure all the layers that you want to select from are unlocked)
  • Deselect All – Esc – This shortcut deselects everything on the stage. If you’re typing using the Text tool and you hit “Esc” while still in type editing mode, Flash will exit type editing mode, but the text field will still be selected. Hitting “Esc” a second time will then deselect it.
  • Temporary Access to Tools on the Toolbar – The Selection Tool, Zoom Tool, and Hand Tool all have time-saving shortcuts that allow you temporary access to the tool. To gain temporary access to these tools, simply hold down the key(s) listed in the shortcut, perform whatever action you want to perform, and then, when you release the key(s), you will return to the Tool you were using to start with.
    • The Hand Tool – Space – To scroll (pan) around the stage without having to switch over to the hand tool, simply hold down the space key, click and drag the mouse, and then release the mouse button and the space bar when you’re done. If you don’t see the hand cursor when you initially hit the space bar, then you may need to click once on the stage and then try again.
    • Zooming In – Cmd+Space+Click (Ctrl+Space+Click) – While holding onto the shortcut keys, click once on the stage to zoom in, or click and drag over a specific area to zoom in on that area. When you release the keys, you will return to the tool you were initially using.
    • Zooming Out – Cmd+Opt+Space+Click – Simply press the shortcut keys and click once on the stage to zoom out.
    • Zoom to 100% – Cmd+1 (Ctrl+1)

This is by no means a comprehensive list of shortcuts, but these are some of the ones I use most often. It may seem like a lot to remember, but if you can take the time to practice and learn these, it will really serve you well in the long run. Once you become fluent with these shortcuts, you’ll find that your Flash development time is notably more productive.

Cross Domain Policy

Every Flash or Flex developer who has had to access remote resources has come across a crossdomain.xml policy file at some point.

What is a Cross Domain Policy File?

The security model known as the “same origin” policy, implemented by most modern web browsers, prevents some types of content from being accessed or modified if the file exists on another domain. It’s not a hard and fast rule; HTML pages will happily display images and HTML from pages on other domains. But for JavaScript the same origin policy prevents a document or script loaded from one origin from getting or setting properties of a document from another.

Flash includes a similar security policy which generally prevents a Flash application from accessing data that is hosted on a remote domain. However there are many circumstances where it is not only useful but expected that resources will be accessed remotely. An online photo album would find itself limited if external applications could not download its images. It would also be silly if a web service didn’t allow outside applications to interact with it.

For this reason it’s possible to create an XML file, called crossdomain.xml, that specifies how data on a domain can be accessed by a Flash application hosted on a remote domain. For the most part these policy files are quite simple, but there are a few details that it is useful to be aware of.

If you are hosting content that you want to be accessed by external Flash applications, you will need to create a crossdomain.xml file. Let’s start by taking a look at a basic example.

A Basic crossdomain.xml File

Here is a very simple crossdomain.xml file. When this file is hosted on the root of your domain it permits external Flash applications access to all the resources on your domain.

  1. <?xml version=”1.0″?>
  2. <cross-domain-policy>
  3. <allow-access-from domain=”*” />
  4. </cross-domain-policy>

The policy file contains a single <cross-domain-policy> tag. Inside this you can have zero or more<allow-access-from> tags. Each <allow-access-from> tag can be used to define a domain or IP address from which a Flash application can access the local resources. The attribute domain=”*” specifies that all domains have access. This is thanks to the asterisk wildcard, which is used here to match all domains and IP addresses.

For most situations this “allow all” policy file is sufficient. It grants Flash applications access to all pubic resources, while any security you have in place (like password protected pages) will still prevent Flash applications from accessing sensitive data.

(Note that you cannot put a crossdomain.xml file on your domain that will allow SWFs also on your domain to access remote files on another domain!)

Specified Domains

If you do not want to allow global access to your public resources, the domain attribute in the <allow-access-from> tag can be used to grant access to specific domains.

You can specify a domain in its entirety. The example below will give access to Flash applications hosted in the www.example.com domain.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<!--Generic policy file for flex app access, it should be made more restrictive -->
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="all"/>
  <allow-access-from domain="www.hawaiiflash.org" />
  <allow-access-from domain="hawaiiflash.org" />
</cross-domain-policy>