Archive for Education

iPhone Apps Sync automatically removes your Jailbroken Apps

// April 4th, 2011 // Comments Off on iPhone Apps Sync automatically removes your Jailbroken Apps // iPhone

iPhone can’t turn on at all?

// April 4th, 2011 // No Comments » // iPhone

your iphone’s battery drained completely. there are a couple ways to get past this, but they aren’t always guaranteed to work.

first
attach the iphone to your computer using a separate cord. this will rule out it just being the charger itself that’s defective

no dice?

second:
try holding down the sleep/wake button for ten seconds, followed by holding down the home button for thirty seconds after releasing the sleep/wake button, this usually forces the iphone to wake up

no dice?
time for a reset!

third:
press and hold the sleep/wake button + Home button for thirty seconds at the same time. this should run a factory reset on your phone. Yeah, it’s a pain in the *** trying to get all of your old settings back, but it’s better than paying for a new phone AND getting your old settings back.

Still no dice?

fourth
try to replace the battery on your own. you’ll need a paperclip (remove the sim tray) a case opener tool (guitar picks work fine) and a #00 phillips screwdriver. flatheads occasionally work too. you can find further instructions easily if you look up Iphone takeapart or iphone battery replacement. doing this WILL void your warranty though. If you stil have a warranty and none of the above steps fixed it, definitely take it into apple.

if all else fails…
sell your iphone on ebay. depending on the model and the memory, you should be able to fetch a hundred bucks or so at least for it
Sell it on ebay

[FLASH] A Different Kind of Preloader – Loading the Spikes

// October 12th, 2007 // No Comments » // Flash

Sources: http://www.flashkit.com/tutorials/Tips_And_Techniques/A_Differ-Michael_-555/more2.php
Author: Michael Georges
Version: Macromedia Flash 5
Objectives: When an object is loaded once, there is no additional overhead to display it again. So, you preload your objects that cause spikes and your site should stream just fine! 
Tools & Techniques: Actionscript

A Different Kind of Preloader – Loading the Spikes

Most of the tutorials that talk about preloaders deal with the mechanics of building them. This tutorial is about the concept of preloaders and building one that is a little different.

If you have done any testing of your flash site using the Show Streaming tools and the bandwidth profiler, you know that the intention of the Flash creators was that we would and should design our sites to actually stream over the internet rather than loading it all up front and then playing it. We have gotten into a preloader frenzy without really thinking about how it effects the usability of the site.

Folks, IMHO a preloader should load no more than 150K worth of data…at the highest end…period. Any more than that and your dial up users are waiting longer than 40 seconds and it becomes a usability issue.

But, what if you were to design a site lean and mean – actually meant to stream over the internet? Using the bandwidth profiler, you can see where your site will stall on a 14.4 or 28.8 stream – it’s the spikes that go over the red line that count. Now, those spikes are usually objects – a movie clip that appears in that frame, text that displays, a bitmap, etc.

What if you were to preload just the spikes?

When an object is loaded once, there is no additional overhead to display it again. So, you preload your objects that cause spikes and your site should stream just fine!

Here is what I mean:

Say you have an interface that is 200K worth of data – remember, lean and mean – you look at it on the bandwidth profiler and see that it streams just fine except for four spots – two movie clips, the vector graphic that makes up your interface, and an image from photoshop:

  • MC#1 is 24K
  • MC#2 is 17K
  • Vector graphic is 12K
  • PS Image is 22K

So, about 75K worth of data that will cause your site to stall on a dialup connection. Our normal instinct would be to just preload all of the 200K. But, we are going to preload only that 75K worth of spike so our site will stream.

You create your preloader scene, AND, you create an additional scene called “Spikes” – that is what your preloader is going to check and see if loaded. You will drag instances of each of your four objects into your timeline in “Spikes”. Your preloader will check IF the last frame in Spikes is loaded and then will go to and play the first real scene in your movie. Spikes is never meant to be displayed.

Now realize that as you get better and better at designing smaller interfaces in Flash, you may not even need to do this, and, your whole design style can and will change. As your preloads get smaller, you may not need to design the traditional preloader at all – your objects may load behind a splash screen, or load as part of your intro.

I really think that this is how the really great sites do it – they rely on Flash’s vector graphics as much as possible – they stay away from large bitmaps, and they design their sites to stream and they preload only the spikes…

[FLASH] Controlling Browser Window via Flash Javascript buttons [via ‘get url’ statement]

// October 12th, 2007 // No Comments » // Flash

Sources: http://www.actionscripts.org/forums/showthread.php3?t=23342
Author: Cheeky_monkey
Version: Macromedia Flash 5
Objectives: Client wants Flash Demo on a CD with their own Branded window.
Tools & Techniques: Oval Tool, Rectangular Tool

Controlling Browser Window via Flash Javascript buttons

1. Set size of browser window

On (Release)
Get URL (“javascript:window.opener=self; window.resizeTo(width=780,height=420)”)
End On

2. Minimise browser window
(haven’t worked out) HELP !!

3. Maximise the browser Window.

On (Release)
Get URL (“javascript:window.moveTo(0,0);window.resizeTo(wi ndow.screen.availWidth,window.screen.availHeight); “)
End On

4. Close the browser window.
(cool JS which by-passes the MSIE security prompt of “are you sure you wich to close this window”)

On (Release)
Get URL (“javascript:window.opener=self; window.close()”)
End On

[FLASH] Drawing Geometrical shape

// October 10th, 2007 // No Comments » // Flash

Sources:http://www.webdevelopersnotes.com/tutorials/flash/online_flash_tutorial_drawing_geometrical_shapes_part_1.php3
Author: WebDevelopersNotes
Version: Macromedia Flash 5
Objectives: Learn how to draw geometrical shapes
Tools & Techniques: Oval Tool, Rectangular Tool

Drawing Geometrical shapes

Geometrical shapes such as rectangles, squares, circles or ovals are drawn using the Oval Tool  and the Rectangular Tool . Evidently, the oval tool is employed for making ovals and circles while the rectangular tool makes squares and rectangles.

Drawing an oval or a rectangle shape is very simple. Just select the appropriate tool and then left click on the stage. Keeping the mouse button depressed, drag to another location. There… you have your shape.

(Tip: Perfect circles and squares can be drawn by holding the SHIFT key when using the oval and rectangular tools, respectively.)

When the oval or rectangular tool is activated its corresponding modifiers are displayed below the toolbar. These modifiers let you control the various properties of the shape you are about to draw. Remember, each shape consists of an outline and a fill. Outline color, outline style, outline thickness and the fill color (or gradient) can be set using these modifiers.

The modifiers for the oval and rectangular tools are similar except for one addition to the rectangular tool modifier palette. Let’s take it step by step.

The Oval tool modifiers

The fill modifier lets you specify the fill color from the color palette.
Color gradients (discussed later) can also be used as fills. Flash comes with a set of basic gradients. Using these as foundations, you can create your own.
The other icons in the modifier palette control the outline style and thickness, and have been explained in the previous session, Using the Line Tool.

The Rectangular tool modifiers

 

Except for the last modifier (Round Rectangle Radius), the rest are identical to those found in the oval tool modifier palette.
The Round Rectangle Radius is employed to make rounded rectangles. Clicking on the modifier opens a pop-up window through which you can specify the radius in pixels.

Ovals and Circles with the Oval tool

Outline thickness set to 2 pixels and color to black. Solid line style was used for the outline. The fill color was set to a light blue shade.

 

 

 

Rectangles and Squares

Outline Color: Red

Outline Thickness: 2 pixels
Outline Style: Solid
Fill Color: Yellow
The rounded rectangle has 10 pixels as radius.

 

 

 

Moving Shapes
Once you have created a shape you can place it where ever you want. To move a shape (or any other object for that matter) from one place to another, you have to select it first using either theArrow or the Lasso tool.

Shapes/objects can be selected by

  • Clicking on it with the Arrow tool
  • dragging a rectangle around the shape using the arrow tool OR
  • drawing a loop with the lasso tool

Note: The lasso tool is commonly used for selecting odd shaped objects.

Rectangles and ovals consist of two parts, the fill and the outline. You can select these individually. Thus, to select only the fill, click inside the shape with the arrow tool. Oulines of circles and ovals can be selected by clicking on them. Selecting an outline of a rectangle or a square involves four clicks with the arrow tool, one for each side. (eight clicks in case of rounded rectangles).

Selecting a entire rectangle (outline and fill) using the arrow tool.

 

 

 

Selecting the outline of a circle and detaching it from the shape.

Sizing and rotating shapes
There are various ways to change the size and rotation of shapes in Flash. The simplest way to do this is to use the Arrow tool modifiers. When a shape is selected with the arrow tool, the modifiers are displayed below the toolbar. Here are two of them.

The scale modifier is employed for changing the size of the selected object. When it is activated, eight small square Handles are placed around the object. Dragging the corner handles increases or decreases the size of the object while dragging the central handles stretches the object in that direction.

The rotation modifier places eight small circular handles. The four in the corners, rotate the object while the central ones skew the object.
Flash makes it easy for you to work with these modifiers by changing the look of the mouse cursor depending upon the modifier you use.

 

(To resize or rotate odd shaped objects, select them using the lasso tool and then while the objects are still selected, click on the arrow tool to bring up the scale and rotate modifiers.)

[FLASH] Flash Forms

// October 7th, 2007 // No Comments » // Flash

Sources: http://www.tizag.com/flashTutorial/flashforms.php
Author: tizag.com
Version: Macromedia Flash 5
Objectives: Using Load Movie to load external movies as part of a Flash website.
Tools & Techniques: Load Movie, loadMovie, levels, buttons

Flash Forms

 

Flash is great for showing movies and entertaining animations, but did you also know that you can gather information from your users with the use of Flash? Built into Macromedia Flash is the capability to do everything you can do with HTML forms.

This lesson will create a Flash Form that can be processed by ASP, PHP, or anything else that you want to use to process Form Data. If you would like to learn more about processing Form Data with PHP or ASP see our PHP Form Data Processing lesson or our ASP Form Data Processing Lesson.

Flash Static Text Fields

Before we begin with the nitty gritty task of creating the form, let’s lay out some titles for the inputs we will soon have. In this example we will be making a form to collect a user’s name and home city. Using the Text Tool from the Tools window let’s make two Static Text Fields with a Font of _sans and a size of 12.

fformstaticproperties
Create two text input fields with the text “Name:” and “Homecity:”. Your text fields should look something like this:

fform1static

Now let’s make sure they are lined up properly. With the arrow tool drag a box around both text fields to select them, then choose from the menu Modify < Align < Right to get a clean lineup.

fform1static2

Creating Flash Input Fields

Now let’s gather some data! With the Text Tool selected, choose the following from the Properties window:
Input Text with a Font of _sans and a size of 12.

fformstaticproperties

Create two input boxes to the right of Name: and Home: that look something like this:


Now get them aligned by selecting both boxes with the arrow tool and going to the menu and choosing Modify < Align < Left

fform2inputalign

Creating Flash Input Variables

If we are going to send this data to another web page, we are going to need access to the contents of these input fields. Flash uses variable names as a way to access the values that are contained in input text fields. Variable names are assigned in the Properties window when you have the text input field selected.

fforminputvariableblank
Use the arrow tool to select the text input field to the right of Name: and set Var: field to “Name”.

Select Home’s input and name it “Home”.

 

Creating a Flash Submit Button

We’re almost done! We just need to create the Send button and tell Flash the URL of the form data processor and that’ll be it.

To expedite this part of the lesson we are going to use Macromedia Flash’s premade buttons. To access these buttons go to the Flash menu Windows < Common Libraries < Buttons and you should see this window popup.

Open the “buttons bar” directory and select the “bar blue” button.

Drag and drop this button to bottom right corner of your Stage like we have done.

The button currently reads “Enter” which is not appropriate for our form. To change the text that is displayed on the button, double click the button with the arrow tool to bring up the button edit mode.

Using the Text Tool from the Tools window select the text “Enter” contained within the button and replace it with “Submit”.

 

Exit out of button edit mode by choosing from the Flash menu Edit < Document (shortcut: Ctrl + E).

Adding Flash Action getURL

We are now going to add an action to our button, so when it is clicked it will send the data contained in the input fields to a web page that will process the data. Using the arrow tool select the button and open up the Actions window: Window < Actions. Navigate to the getURL action.

Make sure that Script Assist is turned on and then double click getURL to bring up the ActionScript wizard for getURL.

It is important to note at this time that this form will function exactly like an HTML Form, so we will configure it just like we would an HTML Form. If you need a refresher on how HTML Forms work check out our HTML Form Lesson. We will be using the POST method in this form, so your processor will need to get data using POST. Check out ASP Forms POST to learn how to create an ASP page to process POST data.

Enter in the following information to the fields and you’ll be done!

Note: You will need to replace the URL with the actual location of your Form Data processor. http://www.example.com/processer.php does not exist.

Test It Out!

Now that you have completed this long and arduous tutorial, go ahead and choose Control < Test Movie from the menu and check out your Flash Form.

 

[FLASH] Using Load Movie

// October 4th, 2007 // No Comments » // Flash

Sources: http://www.cbtcafe.com/flash/loadmovie/loadmovie.html
Author: cbtCafe
Version: Macromedia Flash 5
Objectives: Using Load Movie to load external movies as part of a Flash website.
Tools & Techniques: Load Movie, loadMovie, levels, buttons

Using Load Movie

This lesson will demonstrate how to load external Flash movies. A major reason to load external movies is file size. By loading only the movies you or your visitors want to view, you can keep your initial movie size considerably lower. For example, in this tutorial we created a sample Flash website with separate, external movies for the About, Product, and Contact sections.

If a viewer only wanted to view the info on Products, he/she can click the Products button and that info will load without having to wait for the other areas to load as well. This technique is great for larger, more content-rich movies.

We’ll assume you know how to create a basic Flash movie for this lesson.

Step 1: Getting Started

I created 5 movies for this example: 1 main movie and 4 additional content movies.

  1. Create one main movie to serve as the “container” or background movie
  2. This movie will always remain at Level 0 and we’ll load the other 4 movies on top of it at Level 1

LoadMovie_2

Step 2: Open the movie you want to use as the background or main movie

This will be the movie that you use to load the other movies on top of. In my example, it’s “loadmovie.swf”

LoadMovie_1

I don’t have any buttons on this movie, only graphics and some text. Instead of using a button to load the first movie, I’m going to apply a frame action that loads the first external movie when the movie begins.

Step 3: Create the Load Move action at Frame 1

  1. To load the first movie when the main movie is launched, create a frame action that loads the movie.
  2. Click in Frame 1 of the background movie and in the Basic Actions Panel, click Load Movie. The loadMovieNum action appears in the first line.
  3. In the URL field, type in the exact name of the first movie you want to load. In my example, I typed in: main.swf. This is the path to the movie so be sure to type the path correctly. I’m using relative paths here to keep things simple.
  4. For Level, choose any number greater than 0. Level O is where the background layer is stored so you want to load your other movies on top of it. You can load the other movies into Level 0 but it will replace your current background movie. There are times when that’s more appropriate, but in this example, we’ll just load the other movies in Level 1, above our main, background movie.

LoadMovie_3
!Be sure to include the “.swf” extension. Keep the Expression box unchecked.

The Framerate of the original movie is the framerate all other movies will play, regardless of their individual settings.

Step 4. Save and Publish your movie

Save the movie to a common folder with your other movies.

Step 5. Create loadMovie actions on your other movies

Our main movie, loadmovie.swf had the loadMovie action on the first frame. For the other movies, we’ll create button actions that load the appropriate movie when the viewer clicks on it.

  1. Open the main.fla movie. We won’t go through the other two .flas since the actions will be the same.
  2. Click on Frame 25. This is where all of our graphics are in their final position and you can easily access the buttons there.

LoadMovie_3

Step 8. Add the button actions

  1. Click once on the About button.
  2. Go to the Actions Panel and under Basic Actions, choose Load Movie.

LoadMovie_5

Step 9. Enter the URL and Level

Type in about.swf in the URL field and for Level, enter 1.

LoadMovie_6

Continue adding the actions for the other buttons (products.swf and contact.swf) in the same manner

You’ll also need to add the same button actions for the other three movies (about.fla, product.fla, and contact.swf).

Step 10. Save and Publish

  1. Save and Publish all the movies into the same folder
  2. Test your movies by double-clicking loadmovie.swf

———

Couple of notes on Loading movies:

1. When you load a movie, the movie that is loaded in the higher level retains it’s transparency. You can use this to your advantage by loading movies on top of your lower movies without having to replace the content underneath.

2. To do this, simply load the movie on a higher level. For example, you might have your initial background movie at Level 0 and another movie on Level 1. You can then load any other movies on any number above 1.

3. Loaded movies are loaded and positioned by their top-left corners. This means that if you load a movie that is smaller in stage size than the original movie, its top left corner will match the original and if you didn’t plan out the positioning ahead of time, it could be off center.

4. If you load another movie of a different size or frame rate into Level 0 to replace the original movie, the settings established by that original movie will still be the default. For example you couldn’t load a new movie with a larger stage size into Level 0 hoping to increase the stage size. It will still have the original stage size dimensions.

[FLASH] Full flash Banner

// October 4th, 2007 // No Comments » // Flash

Sources: http://www.flashvault.net/tutorial.asp?ID=100
Author: FlashVault.net
Version: Macromedia Flash 5
Objectives: Learn how to aligned picture with background, how to use Free Transform Tool (Q) and more.
Tools & Techniques: Free Transform Tool

Full flash Banner

In this tutorial you will see how to create full flash banner. To create this tutorial, you don’t have to use Action Script. You will also learn how to aligned picture with background, how to use Free Transform Tool (Q) and more.

Step 1

Create a new flash document, choose Modify > Document, and set Width to 430, and Height to 180px. Frame rate set to 22fps (Frames per Second).

Step 2

Find three picture and set their dimensions as background (430x180px), using the Photoshop or some other graphic program.

Step 3

Double click on layer1 to rename its name in picture1.

Step 4

Choose File > Import > Import to Stage (Ctrl+R), and Import the first picture. Then, using the Align Panel (Ctrl+F3), center it with background.

Step 5

Click on frame 80 of layer picture and press F5.

Step 6

Insert a new layer and name it line1. Select it, take the Rectangle Tool (R), Stroke color must be switched off, under Fill color choose any color and draw a “rectangle” 10x20px. Then, using the Align Panel, set it on the middle right position, like it is shown on the picture below.

Step 7

Click on frame 10 and press F6. Then, take the Free Transform Tool (Q), and do like it is shown on the picture below.


Step 8

Click on frame 20 and press F6. Then, take again the Free Transform Tool (Q), and do like the picture below shows.


Step 9

Go back on frame1, and after that on frame 10, open the Properties Panel (Ctrl+F3), and under Tween choose Shape

Step 10

Select line1 layer and convert it to a mask by right-clicking on the line1 layer and selecting Mask.

Step 11

Select the line1 layer, insert a new layer and name it picture2

Step 12

Click on frame 60 and press F6. Then, press Ctrl+R (Import to Stage) and Import another picture.

Step 13

Click on frame 160 of layer picture2 and press F5.

Step 14

Insert a new layer and name it line2. Then Repeat steps 6-10, but for this time, the animation (“rectangle”) will start from top left side. See the picture below.


We’re done for the first two pictures. Repeat this steps for every other picture, that you want to set on the banner.

Step 15

If you like to link the picture, first you must to convert it into a Movie Clip, select it, open the
Action Script Panel (F9), and paste this script:

on (release) {
getURL (“http://www.somewebsite.com”,”_blank“);
}

Only one thing that you need is preloader. Set the preloader on the first frame, and tha banner animation on the second frame. If you don’t know how to create a loader, click here.

We’re done!

Have a nice day!

[FLASH] How to Jump to a Random Frame Label

// September 27th, 2007 // No Comments » // Flash

Sources: http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label
Author: David Stiller

How to Jump to a Random Frame Label



This question comes up from time to time in the forums.  Typically, someone has built a Flash banner ad with a handful of entry points.  The ad is supposed to start at any one of these, but the choice should be random.  For example, a fruit stand ad is supposed to play the bit about the bananas first, then the apples, then the bananas again, then the oranges.  How can this be accomplished?  Well, this one’s pretty easy. 



An answer, short and sweet.


Add the following to frame 1 of your scripts layer.

function getRandomLabel():String {
var labels:Array = new Array(“a”, “b”, “c”);
var index:Number = Math.floor(Math.random() * labels.length);
return labels[index];
}
this.gotoAndStop(getRandomLabel());

Make sure to replace the “a”, “b”, and “c” with the names of actual frame labels in your movie.  (It doesn’t matter how many, but it won’t make much sense if you only put one.)


How it works


The first line declares a function that returns a string, which will provide the desired random frame label when needed.


Inside the function, we declare an array variable and assign it the value of an Array instance.  This array holds a list of our frame labels.  Next, we declare a number variable and assign it a random value based on the count of elements in the array.  The Array.length property returns this count.  The count is multiplied by Math.random(), a static method that returns a pseudo-random decimal value between zero and one.  Because the result needs to be an integer, we round the whole thing down with the Math.floor() method.  When this line is executed, index’s value will be an integer between zero and the number of items in the array.  Finally, we use the array access operator, [], to “pull” an element from the array.  In this case, labels[0] would be “a,” labels[1] would be “b,” and so on.  We’re simply randomizing the number that goes in between the square brackets.


Outside the function, a normal invocation of MovieClip.gotoAndStop() does its thing with a frame label as the parameter.  Once the custom getRandomLabel() function is declared, it can be referenced anywhere else in the timeline, so if you want to jump to a random label again after, say, frame 300, just paste that last part into a keyframe at that point.

this.gotoAndStop(getRandomLabel());

Variations


As is, the movie will immediately jump to one of your frame labels and stop — that’ll be the end of it.  If you want the playhead to jump to a frame and play, replace the reference to this.gotoAndStop() with this.gotoAndPlay(), leaving that getRandomLabel() function as a parameter, where it is.


To jump to a random frame (not frame label), the following variation will do.

function getRandomFrame():Number {
return Math.ceil(Math.random() * (this._totalframes – 1)) + 1;
}
trace(getRandomFrame());

Note the use of MovieClip._totalframes to retrieve the total number of frames in the timeline. Hardcode this number, if you like, but make sure to exclude 1 from the possible outcome. If the playhead goes to frame 1, the getRandomFrame() function is needlessly redefined.


How about visiting a series of random frame labels without repeats? For that, check out the aptly titled “How to Jump Randomly to Frame Labels without Repeats.”


FAQs

QUESTION 1:
Hi,


This was extremely helpful. I do have one question: How about if you want to pull from a random frame label at the beginning, and then play the other frames in order.


For example, let’s say it initially displays frame “three”. Then frame “four”, “five”, “one”, “two”, “three”, etc would follow.


If frame “two” was pulled initially, then “three”, “four”, “five”, “one”, etc would display.


Thanks for your help

ANSWER Q1:

Great question, Heather!


What you’re after is easy enough if we re-use that index variable. The way it’s written now, the variables index and labels are scoped to the function getRandomLabel(), which means they disappear as soon as getRandomLabel() has run its course. To scope those variables to the main timeline, so that we can re-use them for the full duration of the timeline, they need to be declared there, instead.

var labels:Array = new Array(“a”, “b”, “c”);
var index:Number = Math.floor(Math.random() * labels.length);

So at this point, we have no function: just two variables. As discussed above, the value of index at this point is either 0, 1, or 2. Let’s say it happens to be 1. We can add a third line to at least get the timeline rolling.

this.gotoAndPlay(labels[index]);

Make sense so far? We’re telling the main timeline, represented by this, to perform the MovieClip.gotoAndPlay() method, and we’re telling it to go to whatever frame is represented by labels[index] — which is to say labels[1], since index is currently 1 — which happens to be the string “b”.


In this hypothetical scenario, there are three labels, “a”, “b”, and “c”. The playhead will jump to b at this point and play until it hits another frame with ActionScript telling it to do something else. Each of your labels sits at the beginning of a span of frames — say a span of 100 frames each. On the 100th frame after “a”, “b”, or “c”, you could make that frame a keyframe and use the following ActionScript:

index++;
this.gotoAndPlay(labels[index];

In line 1, index increments to whatever it is plus 1, so in our scenario, it’s now 2. In the next line, this.gotoAndPlay() is sent to labels[2], which happens to be “c”.


So let’s follow along and see where this breaks. At frame label 3, the playhead plays through until 100 frames after that, at which point it sees the same two lines we just looked at. The value of index increments to 3, and the playhead is sent to the frame label stored in labels[3]. But wait! There are only three elements in the labels array: 0, 1, and 2. There is no 3.


Easy enough to remedy. Change those two lines to this:

index++;
if (index > labels.length) {
index = 0;
}
this.gotoAndPlay(labels[index]);

You follow? index is incremented: if it started at 0, it’s now 1; if 1, it’s now 2; if 2, it’s now 3 — and the if statement changes it back to 0. The Array.length property comes in handy, here, because we don’t even have to keep track of how many elements are in the array.


Now, we’re done to one more problem to solve. The way it is at this point, the banner will loop forever. Maybe that’s not so bad, actually. index starts at a random number and then just loops around the array until the user closes the browser or navigates elsewhere.


If you want the frame labels to only be played once, I suggest a third variable to keep track of how many times we’ve incremented index.


Here’s a recap:

// in frame 1
var labels:Array = new Array(“a”, “b”, “c”);
var index:Number = Math.floor(Math.random() * labels.length);
var counter:Number = 1;
this.gotoAndPlay(labels[[index]);

// in the last frame of each
// labeled frame span
counter++;
if (counter < labels.length) {
index++;
if (index > labels.length) {
index = 0;
}
this.gotoAndPlay(labels[index]);
} else {
stop();
}

Note that counter starts at one, because we normally start counting at one; index, on the other hand, starts at zero because arrays start at zero.

QUESTION 2:
What if I start at a main page, then with the next button, It jumps to 1 of 10 choices randomly, where would the code go?

ANSWER Q2:

All you need here is to assign the “trigger” line (the one that starts this.gotoAndPlay(…)) to the event handler of a button. Check out the original code sample … it sets up a custom function named getRandomLabel(), which you would leave as is. Then a single line uses this function, which you’ll do, too, but inside a button.


Of course, you’ll want to stop the timeline completely, so that the button causes it to start again.

function getRandomLabel():String {
var labels:Array = new Array(“a”, “b”, “c”);
var index:Number = Math.floor(Math.random() * labels.length);
return labels[index];
}
this.stop();
buttonInstance.onRelease = function() {
this._parent.gotoAndStop(getRandomLabel());
}

In the above sample, your button would have the instance name “buttonInstance” (or pick whatever you like; just make sure you use the actual instance name). So, first is the function declaration, followed by the MovieClip.stop() method, invoked against the main timeline.


Then, a function literal, assigned to the Button.onRelease event of your button instance. Note how the path to gotoAndStop() has changed from this to this._parent. The reason for this is because gotoAndStop() is a MovieClip method, and without the _parent, the method would be invoked against whatever this points to — which is the button, in this case (the Button class features no such method). Make sense?


[FLASH] Setting your flash headers/swfs to play only once an hour

// September 27th, 2007 // No Comments » // Flash

Sources: http://www.laflash.org/forum/archive/index.php/t-2521.html
Author: David Stiller

Setting your flash headers/swfs to play only once an hour



I’m popping this code into my hybrid flash/html pages in order to stop my flash header animations from playing every time someone visits the page or any other pages with the same swf. which can be very irritating to site visitors after a while, plus distract from the main content. It plays the anim and then maintains state for an hour (starting at the time the swf was first viewed), upon which it’ll play the anim/action again. Make sure the function is invoked on the second frame and/or after the preloader.

I didn’t write the original code (lazy mario) but i have tweaked it out quite a bit and added comments for “easy” modding.

Just thought it might be useful to people doing this kind of work.

[CODE]

//sets the header animation to play only once every hour.
//dependent on the users computer time.
//placed on a frame after initial preloader

Now = new Date();

//to set the anim to pay only once per minute add Now.getMinutes()
//in front of the getHours method
//to play only once per day remove the getHours method
//note – getMonth starts on zero for January, minutes are 0-59,
//getYear is getFullYear method minus 1900, thus 2001 is 101
headerTimeSet = Now.getHours() + “/” + Now.getDate() + “/” + Now.getMonth() + “/” + Now.getYear();
headerCookie = SharedObject.getLocal(“HourTime”);

//demos if the object is working – create corresponding text fields
//this.savedDate_txt.text = headerCookie.data.headerTimeSet;

if(headerCookie.data.headerTimeSet == headerTimeSet) {
this.content_mc.anim_mc.gotoAndStop(“end_lbl”); //action taken based on cookie
} else {
this.content_mc.anim_mc.play(); //default action
}

headerCookie.data.headerTimeSet = headerTimeSet;
headerCookie.flush();

//demos if the object is working – create corresponding text fields
//this.dater_txt.text = headerTimeSet;