Actionscript 3 (Flash CS6): Play a random movie clip when button pressed

The following code shows you how to play a random movie clip when a button is pressed in Flash CS6 Actionscript 3 (AS3). To do this, I started with 4 movie clips that will be called at random. So that means that there is a main timeline and 4 movie clips, each with a button in them, that are placed on the main timeline.

This code goes into the main time [CODE]

stop();

//this code makes each movie clip invisible so its not being played. I put each movie clip on the main timeline you just cannot see them until they are called
//easy1 easy2 easy3 and easy4 are instances. Be sure to give each of you movie clips an instance name.
easy1.visible = false;
easy2.visible = false;
easy3.visible = false;
easy4.visible = false;

//create an array with your instance names
var storeArray:Array = [easy1, easy2, easy3, easy4];

This is what the button does when pressed
function easyButton(pEvent:MouseEvent):void {
//random clip from array. Note that these are all variables here no instances or anything.
var myNumber = Math.floor(Math.random()*storeArray.length);
trace(“myNumber “+myNumber);
var activeCarton = storeArray[myNumber];
//now we make the movie clip that was previously playing invisible and the new one replaces it
easy1.visible = false;
easy2.visible = false;
easy3.visible = false;
easy4.visible = false;
activeCarton.visible = true;
}

[ENDCODE] Now, in the timeline with my button, I put the following code. Keep in mind my button is in my movie clip. If yours was in the main timeline you would just delete that MovieClip(root). from the code:

[CODE]

//easy1Button is the button instance name. easyButton is the function we created in the previous code.
easy1Button.addEventListener(MouseEvent.MOUSE_UP, MovieClip(root).easyButton);

[ENDCODE]

Has Adobe won the mobile war? I think so…

There is so much misinformation out there it is ridiculous. I hear so many rumors from non-developers about mobile development and the funny thing is, most of them have never developed an app. So why has Adobe won? Two software packages – Adobe Air and PhoneGap.

Each of these software packages allows you to create mobile apps on multiple devices. So I can develop one app and it will run on the iPhone, iPad, and Android based devices. Thus I no longer need to waste valuable time developing apps for both iOS and Android when I can develop one that deploys on both.

With Adobe Air, you develop your app in Flash and package it for each device. Wait, isnt there a rumor that Flash doesnt work on iPhone? Yes there is that rumor and it is only partially true. Flash does not run in the iOS browser BUT it will run as a stand alone app. So YES you can develop apps in Flash for Apple and they work very well.

With PhoneGap, also owned by Adobe, you can develop apps via HTML5 and then publish to Android and iOS devices. Again these work very well.

Additionally, with both of these software packages I can actually use hardware features of the phone and use them when not connected to the internet. Something you can do with all mobile apps but not the mobile web. The disadvantage to developing an app over a website is that Apple has to approve it (not a problem with Android). Otherwise Apps are much better than a mobile website.

Why would I use one over the other? Flash apps are designed for more sophisticated apps that require large amounts of data (database), high intensity graphics, lots of screens, animations, etc. PhoneGap apps are better for small simple apps. Both are great for development though. Additionally, Adobe is really starting to integrate phonegap into dreamweaver so I would not be surprised if we see these two software packages merged at some point (maybe CS7?).

I will be using both of these software packages in my courses next year, so if you are interested in learning more about them, please contact me.

Adobe Air – http://www.adobe.com/products/air.html

PhoneGap – http://phonegap.com/

Flash to HTML5: Buttons

In this clip I test Adobe Flash’s HTML5 conversion tool. I test motion tweens, masks, and buttons via Wallaby, which is the conversion tool. I test the HTML output file in Safari, Chrome, and Firefox. The motion tweens and masks work in both Safari and Chrome. Nothing works in Firefox. The buttons do not work in any browser. While Wallaby has potential, this is a big limitation. This means that it is currently only useful for animations but not interactivity.

Check out the demonstration:

 

Flash CS6 to HTML5

The following video demonstrates Adobe Flash’s CS6 to HTML5 conversion tool codenamed Wallaby. The tool converted my file in one second. It worked great in Safari but did not work in Firefox. I am not sure if Flash’s tool is not working or HTML5 is not working. I say this because of the compatibility issues I have with HTML5, especially in Firefox. Also, Adobe’s Wallaby tool was last updated on March 8th, which means that a new version is just around the corner. Overall, I am impressed it worked but need to test this with more advanced Flash files. I was not really surprised there was a compatibility issue as that is HTML5. Here is the video with the demonstration:

Flash CS6 and HTML5

Here is a recent post I made in a discussion forum on linked in. I thought it would be worthwhile to post onto my blog:

Flash is not dead right now and from the looks of it, it has the opportunity to become the best authoring tool for HTML5.

HTML5 is currently not ready for widespread use due to compatibility issues. For those that do not know, HTML5 has been around for several years now – it is NOT new and still NOT ready. How many years do you think its going to take to be ready? You might want to look at recent history when DHTML (HTML4, CSS2, and Javascript) were touted as the next big thing in the early 2000s. Compatibility killed that idea. HTML5 does have more promise though. But remember HTML5 is just a simple upgrade to HTML4, it does not do that much more. The real power of HTML5 comes from javascript. Javascript libraries that have been around for years. Why are they not used more often? No authoring tool for them. Its all hand written code. Additionally, while both Google and Apple are making their web browsers HTML5 friendly, they are not making their app markets HTML5 friendly anytime soon. In order to publish an HTML5 app you need to get a third party software package that will do the conversion.

Additionally, at this point, the ONLY potential authoring tool for HTML5 that has promise in the future is Flash! Flash CS6 can export swf to javascript. So, those saying Flash is dead might be very wrong. Flash might just be the next big thing because it will export to HTML5. We currently do NOT have a good authoring tool for HTML5 and if Flash takes that spot, it will not be dead but might be more popular than it currently is now. The only way Flash will die is if another authoring tool that becomes very popular replaces it.

Flash CS6 and HTML5

Wow, Flash has really done something great here…assuming this feature works as promised. Flash CS6 will be able to export into Javascript. This means that all flash content can be exported to js so that it is handled better via web browsers. This will also make flash content viewable on iPhone/iPad. Now, obviously I have not tested this feature out and in different browsers and such but this has potential. Flash is really keeping its #1 place as the best development tool in my opinion.

New Features: http://www.adobe.com/products/flash.html

CS6 Rumor: Cloud based purchasing

We will find out everything about CS6 today but here is the latest. There will be a cloud based service so that users can purchase the software at $50 a month instead of buying it forever. This means that you could essentially rent the software. This would actually be great for my students who only need it for a few months:

Source: http://www.engadget.com/2012/04/23/adobe-cs6-subscription-creative-cloud-photoshop-official/

How to view Flash on your iPad and iPhone

Have you wanted to view Flash on an iPhone or iPad? Well now it is possible (well it always has been with a few workarounds). Apps are coming out that display Flash content, so rest assured, Flash does work on these devices.

One such app, iSwifter, is a browser that displays Flash content. You can try the browser for free for 10 days and it costs 4.99 to purchase. I tested it out and it works pretty well. I tested video, motion, sound, and interactions in flash and they all worked. I think anyone interested in viewing Flash on the iPad/iPhone should definitely invest in this app. It’s cheap, and it works.

You can download iSwifter from iTunes here