Tag Archive for 'AS3'

ActionScript. Constructor parameters when extending MovieClip class, Flash AS2 vs. AS3

Constructor is a method which is called when an object of a class is instanced.
Like in any programming language, in actionscript constructor must have the same name the class has.

Constructor, as a function, may take any number of parameters.
Which is very handy to pass to initialize the objects.
I would recommend using constructor parameters over calling any additional initializing methods.

Here is a good example of using constructors in ActionScript:

var myPoint:Point = new Point(0,0);

And I can give you a lot of such examples.

However, this article is about a particular case, passing parameters to a constructor of your class, which is inherited from (extends) MovieClip.

Tutorial, ActionScript 3, Using Shared Objects to show the time of page browsing.

Here is my first tutorial at FlashDaWeb.
I will show how SharedObject might be used.

For illustration, I came up with an idea to show users the time they spend browsing a particular page.

Here is an example.

Open this demo page and see the timer, then close it and open again anytime you want. Notice, time will not start again from 0:0, it will continue counting from the very values you previously closed it. Quite nice, isn’t it? :)

This movie requires Flash Player 8

In your hands.

The above functionality was implemented with Adobe Flash CS3, ActionScript 3 and SharedObject.

 

You may download the sources .fla and .as files

Download: tutorial_sharedobject_sample.zip  tutorial_sharedobject_sample.zip (11.2 KB, 750 Downloads)

ActionScript 3, SharedObject crashing Flash CS IDE

Recently I met a problem when using SharedObjects caused Flash CS IDE simply to crash with an error.

I looked through the web and found not that much about the problem, however it still continued to cease working.

I my code I was creating several different SharedObjects, and connected them to different local data.

You see, here is the sample actionscript code from Flash Help Content: