Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Mp3 Tutorial Part 2



are the fla files from the tutorials available for download or even just the action scripts files?I did the mp3 part 2 tutorial but for some reason my finish product dosn't work the way it's supost to. If I had a copy of the finish action script to compare that would help I think. The rollover dosn't work right and the music don't stay pause among other things. This is what my action script looks like//setup sound objectvar s:Sound = new Sound();s.onSoundComplete = playSong;s.setVolume(75);//Array of songsvar sa:Array=new Array();// Currently playing songvar cps:Number = -1;//Position of musicvar pos:Number;//Load the songs XMLvar xml:XML = new XML();xml.ignoreWhite = true;xml.onLoad = function(){var nodes:Array = this.firstChild.childNodes;for(var i=0;i<nodes.length;i++){sa.push(nodes[i].attributes.url);}playSong();}xml.load("songs.xml");//Play the MP3 Filefunction playSong():Void{s=new Sound();if(cps==sa.lenght - 1){cps=0;s.loadSound(sa[cps],true);}else{s.loadSound(sa[++cps],true);}playPause.gotoAndStop("pause");}//Pause the musicfunction pauseIt():Void{pos=s.position;s.stop();}//Pause the musicfunction unPauseIt():Void{s.start(pos/1000);}//Music Controls//Play/Pause ToggleplayPause.onRollOver = function(){if(this._currentframe== 1) this.gotoAndStop("pauseOver");else this.gotoAndStop("playOver");}playPause.onRollOver = playPause.onReleaseOutside = function(){if(this._currentframe==10) this.gotoAndStop("pause");else this.gotoAndStop("play");}playPause.onRelease = function(){if(this._currentframe==10){this.gotoAndStop("playOver");this._parent.pauseIt();}else{this.gotoAndStop("pauseOver");this._parent.unPauseIt();}}//Next Buttonnext.onRollOver=function(){this.gotoAndStop("nextOver");}next.onRollOut = next.onReleaseOutside=function(){this.gotoAndStop("next");}next.onRelease = function(){this._parent.playSong();}



General Flash
Posted on: Thu Feb 15, 2007 4:49 am


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Swish Tutorial Part Two
in need help with the second tutorial for swish(using actions in swish)that's on this site. i can't click on squeeze to jump to frame 0 scene 1. i'm on step 4.

http://www.flashkit.com/tutorials/3r...h-66/index.php

Using A Tutorial Missing At Part?
Hello,

I'm currently using this tutorial on adding thumbnails to a photo gallery
http://www.kirupa.com/developer/mx2004/thumbnails.htm

on the first page you can see the swf with the gallery. when the images load up. you can click on big/main image in the gallery. if you download this tutorials files that functionally is not in the downloaded files. does anyone know how i can do this? thanks

Pathfinding Part 1 Tutorial
Actionscript 3.0 pathfinding tutorial. This tutorial will teach you how 2D arrays work, why you would want to use them, and how to use them. If you have comments or questions, please post them on the blog. Enjoy!
http://flashdevz.wordpress.com/2008/08/2 7/as3-pathfinding-part-1-understanding-2 d-arrays/

Anyone Done The News Ticker Tutorial? Part 2
hi all, posted a question up yesterday regarding news tickers. was lucky enough to get it answered - thanks guys.

however.......i have a new prob. my .fla file loads the first news caption, but fails to fade out, and then fade in the next news caption and so on.

iv posted the .fla and .xml files; can anyone spare a mintue and take a look? its obviously actionscript, but i cant c the error anywhere.

Part Of Kirupa Tutorial Not Explained
I am trying a tutorial in kirupa which is faboulas ,
http://www.kirupa.com/developer/flash5/randomcolor.htm
but this part of code is not explained , Iam not being able to understand this part can anybody help?
onClipEvent (load) {
myNum = _name;
}
onClipEvent (enterFrame) {
_root["r"+myNum+"Diff"] = _root["r"+myNum+"New"]-_root["r"+myNum+"Old"];
_root["r"+myNum+"Change"] = _root["r"+myNum+"Diff"]/10;
_root["g"+myNum+"Diff"] = _root["g"+myNum+"New"]-_root["g"+myNum+"Old"];
_root["g"+myNum+"Change"] = _root["g"+myNum+"Diff"]/10;
_root["b"+myNum+"Diff"] = _root["b"+myNum+"New"]-_root["b"+myNum+"Old"];
_root["b"+myNum+"Change"] = _root["b"+myNum+"Diff"]/10;
swatchColor = new Color(this);
swatchColor.setRGB(_root["r"+myNum+"Change"]<< 16 | _root["g"+myNum+"Change"] << 8 |
_root["b"+myNum+"Change"]);
_root["r"+myNum+"Old"] -= _root["r"+myNum+"New"]-_root["r"+myNum+"Change"];
_root["g"+myNum+"Old"] -= _root["g"+myNum+"New"]-_root["g"+myNum+"Change"];
_root["b"+myNum+"Old"] -= _root["b"+myNum+"New"]-_root["b"+myNum+"Change"];
}

Game Engine Tutorial Part 1:
Hiya all, I've started writing up a tut on creating a basic game engine for all those struggling - so here it is...!

Creating a basic game engine using classes in AS2.0/3.0:

This tutorial is for AS2.0 but can be adapted to 3.0 with a little shuffling and a couple of changes!

I've been using the Kirupa forums for a while now and one of the things I see the most is people following tutorials for simple games. While these tutorials are great for learning the basics of AS and enable a simple game to be created quickly and easily they are usually inflexible, convoluted and contain bad coding habits. One of my pet hates is the 'string to variable name' thing that Flash allows you to do so readily.

This tutorial covers getting a more flexible game engine working in Flash which will allow you to do more! It takes a little longer to get the 'basics' working but it's worth it!
First of all I'll just do a little crash course on classes. I see a lot of people using the procedural approach to programming getting their code up and running fine, but then stumbling when it comes to changing something fundamental or adding more functionality because their code is disorganised.

We will aim to organise things as best as possible!

First of all, what is a class?

1. Classes, a crash course

A class is basically a collection of methods (functions) and properties (variables) which form an 'object'.

A class can be instantiated, which means a 'copy' of that object will be created in memory for you to manipulate. You can have as many instances of the same class as you want, and the properties of each instance will be unique to that instance.

For example, imagine you have 2 apples - they are both apples, but one may be slightly redder, one may be slightly bigger or sweeter. This is akin to having 2 instances of the same class but with different properties.

app.GIF

Properties can be either public or private...

Public properties can be accessed from anywhere
Private properties can only be accessed from inside the class

I wont go into detail on private/publics as there's no good reason I would use private variables in a game project (as it's all my code and I know what I should/shouldn't be accessing/altering)

A class is defined in AS as follows:


Code:
class myClass {
// Constructor
function myClass() {
}
}
Simple. A class file must be saved with the same name as the class and placed into the same directory as the .FLA file to be included in the project. This class filename would be "myClass.as".

Notice the definition of one method myClass(). This method is called the 'constructor' and it must be named the same as the class. This function will be called every time a new instance of myClass is created. This is useful for initialising your objects upon creation.

Now to add to myClass - let's add some properties and another method.


Code:
class myClass {

var number1:Number;
var number2:Number;
// Constructor
function myClass() {
number1 = 5;
number2 = 10;
}
function ShowNumber() {
trace(number1 + number2);
}
}
I've added 2 properties called number1 and number2. I've also added a function called ShowNumber().

Now when we create a new myClass object the 2 variables number1 and number2 will be set to 5 and 10 respectively.

If we call the objects ShowNumber() method, it will output the sum of these numbers to the Flash console window.

To create the object and call the method we use the following code


Code:
var instanceOfMyClass:myClass = new myClass();
instanceOfMyClass.ShowNumber();
Now this is a great way to organise your code, but we aren't finished yet!

Classes can do much more!

Your myClass now can be added to, but what happens when you want an object which does most of the stuff that myClass does, but maybe a little differently here and there, or completely differently in places?

You could add arguments to the functions and base the function code on a switch statement or if statements like so: (taking the ShowNumber function as an example)


Code:
function ShowNumber(method:Number) {
if(method == 0) {
trace(number1 + number2);
} else {
trace(number1 / number2);
}
}
That will work yes...but you could just create a new class

'But why copy all that code?' you ask...

Well, classes have a feature called 'inheritance' which allows you to base a new class upon an existing class, and then override or add to it's methods!

So you could do the following


Code:
class myOtherClass extends myClass {
// Constructor
function myOtherClass() {
super();
}
}
Now if you instatiate this class - what do you notice? Yes you can call the ShowNumber method on this new class. All the properties and methods of the parent class are available. Notice the call to super() - this basically means I'm calling the constructor on the parent class - to access anything on the parent class from a subclass you just use the 'super' keyword. This means I don't have to write the same initialisation code as the parents constructor can do it for me.

Now it's possible to modify the ShowNumber() function to suit the new class


Code:
class myOtherClass extends myClass {
// Constructor
function myOtherClass() {
super();
}
function ShowNumber() {
trace(number1 / number2);
}
}
Now your myOtherClass objects will have a different ShowNumber function from your myClass objects. You can even run the ShowNumber function from the parent but modify the properties before you call it like so:


Code:
class myOtherClass extends myClass {
// Constructor
function myOtherClass() {
super();
}
function ShowNumber() {
number1 = 20;
super.ShowNumber();
}
}
So as you can see, there's a lot of scope for intricate layering of objects. The basic idea in this tutorial is to give all your objects the most 'basic' functions and then build upon these by extending them with more specific levels of functionality.

A quick example in one of my games is as follows

BaseObject -> BaseSoldier -> EnemySoldier -> SoldierAK

The base object handles rendering, physics etc. The BaseSoldier handles the movement, control and some behavioural aspects. The EnemySoldier handles behaviour of an Enemy object (i.e. fires at good guys, can be hit by good guys etc) and finally the SoldierAK describes how a Soldier with an AK-47 rifle fires his gun and what he fires.
This means that I can have a number of different types of soldier running about with minimal code needed to add a new one. I can simply create a new SoldierXXX (XXX being the weapon) class and define how that soldier fires this new weapon. His movement, physics and rendering are handled by the parent classes.

2. Creating the game objects

Now we know how to create a class and what they can be useful for, we can start to create our game engine. First of all we need to think about what needs to happen every Flash 'frame' to keep our game in motion.

We need some way of controlling multiple objects that may be on screen simultaneously, keeping track of their animations and updating their positions/collisions/behaviour etc!
Seems like a lot to look after in one go...this is why creating a 'Base' class can be a good idea. Basically we will be creating a generic 'Base' class that the game engine will take care of for us. This class will be responsible for the basics in showing an object on the screen - pretty much everything that will interact with the game world will be derived from this Base class.

We will also need an Array to hold the list of objects so that we can keep track of them.
First of all let's define our base object

Create a new .as file called BaseObject.as in your project directory (you did make one right?!)

Add the following code


Code:
class BaseObject {
// Ok so here are some useful vars
var parent:BaseObject = null; // Holds information on the 'parent' object - this allows you to create heirarchys of objects and means you can have objects which are 'attached' to others. Useful for multipart objects like tanks with turrets etc
var oList:ObjectList = null; // This is a reference to an instance of a class we are going to create next - the ObjectList. This will be the class responsible for handling our list of objects
var clip:MovieClip = null; // The movieclip to use for display purposes - you could use bitmap rendering, but for the sake of simplicity I'll use this for the tut
var _x:Number = 0; // x/y position of the object
var _y:Number = 0;
var velx:Number = 0; // Velocity of object
var vely:Number = 0;

// Initialise the object
function BaseObject(_oList:ObjectList, clipName:String, _parent:BaseObject) {
oList = _oList;
parent = _parent;
SetMovie(clipName);
oList.push(this); // Add this to the object list
}

// Attaches the movieclip which will represent this object - attaches to _root if parent is not specified
function SetMovie(clipName:String) {
if(parent == null) {
clip = oList.root.attachMovie(clipName, clipName + oList.root.getNextHighestDepth(), oList.root.getNextHighestDepth());
} else {
clip = parent.clip.attachMovie(clipName, clipName + parent.clip.getNextHighestDepth(), parent.clip.getNextHighestDepth());
}
clip.stop(); // Stop the animations from playing
Render(); // Call render to set the MC to the correct place/size/etc on screen - should cut any flickering
}

// Behaviour function, does nothing on base
function Behaviour() {
// No behaviour for the base
}

// Physics, set the x/y position += the velocity
function Physics() {
_x += velx;
_y += vely;
}

// Put the MC in the correct place on screen
function Render() {
clip._x = _x;
clip._y = _y;
}

// Function to remove this object from the game
function Remove() {
oList.RemoveObject(this);
}

// Clean up, remove movie clips etc
function CleanUp() {
clip.removeMovieClip();
}
}
So now we have our basics for our game object - let's create the ObjectList class and see how these two fit together


Code:
class ObjectList extends Array {
// The object list is just an 'array' with some extra functionality
var rList:Array; // This will hold a list of objects to remove from the game, the reason we use this list will become apparent (or maybe not, but I'll tell you anyway!)
var root:MovieClip; // Just holds a reference to the _root so that you dont need to use _root in your game in case you want to put a preloader on it

// Init etc..!
function ObjectList(_rootRef:MovieClip) {
root = _rootRef;
rList = new Array();
}

// Simply pushes the object onto the removal list
function RemoveObject(obj:BaseObject) {
rList.push(obj);
}

// Gets the array index for the specified object
function GetIndex(o:BaseObject):Number {
var i:Number;
for (i = 0; i < this.length; i++) {
if(this[i] == o) {
return i;
}
}
}

// This runs through the list of objects which are set to be removed and gets rid of them by running their cleanup() function to remove the movieclips from the game and then splicing them out of the array
function CleanUp() {
var SpliceIndex:Number;

for(var i = 0; i < rList.length; i++) {
SpliceIndex = GetIndex(rList[i]);
this[SpliceIndex].CleanUp();
this.splice(SpliceIndex, 1);
}
// EDIT: Added this to clear out the rList array or it just grew and grew and things got slow :(
rList = new Array();
}

// Loop through all game objects and run their update functions
function MainLoop() {
for(var i = 0; i < this.length; i++) {
this[i].Behaviour();
this[i].Physics();
this[i].Render();
}
CleanUp(); // Remove any items that are marked for deletion
}
}
So now you have these two classes, you should be able to start up Flash and get the basics of your engine on screen...

So...open Flash and go make a cuppa while it starts

Now create a new Flash project and set the framerate to 30 (or 31 if you are old skool )

Create a new movieclip symbol - anything will do, draw a circle maybe or some lines...save it and add it to the library with a linkage identifier of 'TestObject'

On your main timeline let's add the following code:

EDIT: Fixed missing reference to root in ObjectList below


Code:
var oList:ObjectList = new ObjectList(this);
var test:BaseObject = new BaseObject(oList, "TestObject", null);
test._x = 200;
test._y = 200;

onEnterFrame = function() {
oList.MainLoop();
}
Now you should see your symbol appear on the screen in the specified place (200, 200).
Your game engine is now up and running!

3. Animation

Now we have our base object - let's add a bit more to baseobject to allow animation. You could just use the movieclips in flash and call gotoAndPlay() on clips, but we really need to link the animations to an object and we also want a bit more control. At the moment the movieclip that BaseObject is using for display purposes will just run in a constant animation loop. We can add our own custom animation system using classes so that we have a lot more control over which animations get played, and the speed at which they play. Our animation will be based on keyframes - you will be creating all your frames of animation for an object in one movieclip - no nested animations should be in there (unless you want a subclip that just loops over and over which can be useful). I use this animation system because it's a little more flexible and extensible than the regular flash animation system. With this system you can extend it to add your own event system which is very useful.

A good thing about this is that you can use any movieclip symbol to represent any object in the game.

So let's create our animation class:


Code:
class Animation {
// Vars
var animName:String;
var frames:Array;
var delays:Array;
var animTag:String;

// Constructor
function Animation(newName:String) {
animName = newName;
}

// Add frames to this animation
function addFrames(frms:Array) {
frames = frms;
}

// Add delays to this animation
function addDelays(dels:Array) {
delays = dels;
}

// Tag this animation - will come back to this later! :)
function tag(tag:String) {
animTag = tag;
}

// returns the next frame for the animation
function getNextFrame(currentFrame:Number):Number {
// if the current frame is greater than the array length then we need to check the last frame

if(currentFrame + 1 == frames.length) {
return 0;
} else {
return currentFrame + 1;
}
}

// Some getters!
function getFrame(currentFrame:Number):Number {
return frames[currentFrame];
}

function getDelay(currentFrame:Number):Number {
return delays[currentFrame] - 1;
}
}
Ok so we have an animation class now which is basically just an object which stores a list of frames and a list of corresponding delays for those frames. Now that we have this class we can use it to decide which frames our game objects should show.

We now need to add some bits to the BaseObject class to make sure it can utilise the animation class..

Add the following code


Code:
// variables
var anims:Array; // An array of animation objects
var currentFrame:Number; // Holds the index of the current animation frame
var currentDelay:Number; // Holds the amount of time left before we get the next frame
// in the constructor add
anims = new Array(); // to initialise the anims array
// Add the new 'animate' function - this function just uses the animation class to find out which

// frame we should be displaying from the movieclip
function Animate() {
// Check if we need to get the next frame, if not just decrement the delay
if(currentAnim != null) {
if (currentDelay == 0) {
currentFrame = currentAnim.getNextFrame(currentFrame);
currentDelay = currentAnim.getDelay(currentFrame);
clip.gotoAndStop(currentAnim.getFrame(currentFrame));
trace(currentAnim.getFrame(currentFrame));

// If the delay is negative then quit this animation
if(currentDelay < 0) {
StopAnimation();
}
} else {
currentDelay -= 1;
}
}
}

// Add this function - it just stops the animation thats currently playing
function StopAnimation() {
currentFrame = 0;
currentDelay = 0;
currentAnim = null;
}
// Add this setanimation function
function SetAnimation(searchName:String) {
// Find animation by name in anim list does nothing if it can't find one
var i:Number;

for(i = 0; i < anims.length; i++) {
if (anims[i].animName == searchName) {
currentAnim = anims[i];
}
}
currentDelay = 0;
currentFrame = 0;
}
// Add this randomanimation function
function RandomAnimation(searchTag:String) {
// Find animation by tag in anim list and choose a random one
var i:Number = 0;
var targetAnims:Array;
targetAnims = new Array();
for(i = 0; i < anims.length; i++) {
if (anims[i].animTag == searchTag) {
targetAnims.push(anims[i]);
}
}
currentAnim = targetAnims[random(targetAnims.length)];
currentDelay = 0;
currentFrame = 0;
}
// Add this code to the Physics() function
Animate();
Now we have several new functions and some bits and pieces which will allow our objects to be animated. We have added this code to the BaseObject class because most likely all game objects will require animation so it's a pretty fundamental process that needs to go in at the lowest level. The Animate() function chooses the next frame for the movieclip based on the animations you have added to the object.

So now we will add some extra frames to our library symbol - open it up and add a few more keyframes - in the keyframes move the object about a bit or change it - animate it in your own personal style if you like. I'm going to draw a pentagon shape and rotate it by 14 degrees in each frame (it will look like it's completely rotating 360 degreed when these 5 frames play in order)

Now that the symbol has some frames let's create a new class extending the base class and give it some animations so we can see the code in action.

To add an animation use the following code


Code:
var anim:Animation = new Animation("AnimName"); // Create a new animation object called "AnimName"
anim.tag("Tag1"); // Tag this animation - optional, I'll explain what this is for in a second!
anim.addFrames(new Array(1,2,3,4,5)); // Add the frames - this animation will use frames 1 - 5 in the movieclip
anim.addDelays(new Array(1,1,1,1,1)); // Add the frame delays - this will change frame every
someObject.anims.push(anim); // Add the animation to an object
So if we create a new class we can add some animations directly to this new class instead of modifying the base


Code:
class animatedClass extends BaseObject {
function animatedClass(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);

var anim:Animation = new Animation("Test1");
anim.addFrames(new Array(1,2,3,4,5));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
var anim:Animation = new Animation("Test2");
anim.addFrames(new Array(5,4,3,2,1));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
}
function Behaviour() {
super.Behaviour();
if(Key.isDown(Key.UP)) {
SetAnimation("Test1");
} else if(Key.isDown(Key.DOWN)) {
SetAnimation("Test2");
}
}
}
Remember to save this as animatedClass.as in your source directory and that's it! I've added some extra code in the Behaviour function for this class - this is just a quick hack to enable you to mess with the animations.

Change the instantiation code in the root timeline to


Code:
var test:animatedClass = new animatedClass(oList, "TestObject", null);
Run the file and press the up or down arrow to change the animation.

See how flexible classes can be now?

Now have a play about with the frame delays - there are 2 options

A delay of > 0 gives the current animation frame a delay of the specified number of 'Flash' frames (or physics frames if you seperate the physics/rendering which we will do later!)
A delay of <= 0 means the current animation will end and currentAnim will be set to NULL on the base

You are probably wondering what the tag() function does: the tag function is a way of 'grouping' animations under 'tags'. When you create an animation you can give it a tag using the tag function - tagging multiple animations with the same tag forms a group. Now you can play a random animation from that group of animations by using the RandomAnimation() function on the BaseObject. Imagine a set of death animations for a soldier - maybe falling over backwards, clutching his chest when he gets shot, etc - you might want to play a random one of these animations when a soldier dies - with the tags you can do that.

4. Adding a player class

Next we will add a class which can handle keyboard input. Create a new class called PlayerInput and give it the following code:


Code:
class PlayerInput extends BaseObject {
function PlayerInput(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
}
function Behaviour() {
if(Key.isDown(Key.UP)) {
MoveUp();
} else if(Key.isDown(Key.DOWN)) {
MoveDown();
} else {
UpDownReleased();
}
if(Key.isDown(Key.LEFT)) {
MoveLeft();
} else if(Key.isDown(Key.RIGHT)) {
MoveRight();
} else {
LeftRightReleased();
}
}
function UpDownReleased() {
vely = 0;
}
function MoveUp() {
vely = -5;
}
function MoveDown() {
vely = 5;
}
function LeftRightReleased() {
velx = 0;
}
function MoveLeft() {
velx = -5;
}
function MoveRight() {
velx = 5;
}
}
This is your player class. Save it as PlayerInput.as in your source dir. (You could use interfaces for the movement but I don't really find it advantageous in the situation)

Change the instantiation code on the root to


Code:
var test:PlayerInput = new PlayerInput(oList, "TestObject", null);
So now you have a static object which moves about. How about we put some animations on this object while it moves! Let's create another class to extend this one


Code:
class AnimatedPlayer extends PlayerInput {
function AnimatedPlayer(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
var anim:Animation = new Animation("Test1");
anim.addFrames(new Array(1,2,3,4,5));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
var anim:Animation = new Animation("Test2");
anim.addFrames(new Array(5,4,3,2,1));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
}

function LeftRightReleased() {
super.LeftRightReleased();
StopAnimation();
}
function MoveLeft() {
super.MoveLeft();
if(currentAnim.animName != "Test2") {
SetAnimation("Test2");
}
}
function MoveRight() {
super.MoveRight();
if(currentAnim.animName != "Test1") {
SetAnimation("Test1");
}
}
}
Save this as AnimatedPlayer.as and make the change in the root timeline to the instantiation code again...


Code:
var test:AnimatedPlayer = new AnimatedPlayer(oList, "TestObject", null);
So now you have an object that animates when you move left and right. See how the classes are built up in layers, this adds a lot of flexibility and means you can concentrate on writing behavioural code rather than copying/pasting code or rewriting code which is already in your project.

The code in BaseObject handles all the physics, animation and rendering, the PlayerInput class handles player input and the AnimatedPlayer class handles behaviour.

Now looking at the structur of the classes can you see any obvious flaws?

I'd say that the PlayerInput class is probably a bad place to put any behavioural code such as the actual movement code. We should be using PlayerInput only for handling key presses and mouse movement/presses - the classes that are built on top of this should really handle all the behaviour.

Let's rename our AnimatedPlayer class to just Player and move the code for movement from the PlayerInput class into the Player class.

Your Player class should now look like this


Code:
// FIX: Error here, this class definition was still named AnimatedPlayer when it should be just Player
class Player extends PlayerInput {
function AnimatedPlayer(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
var anim:Animation = new Animation("Test1");
anim.addFrames(new Array(1,2,3,4,5));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
var anim:Animation = new Animation("Test2");
anim.addFrames(new Array(5,4,3,2,1));
anim.addDelays(new Array(1,1,1,1,1));
anims.push(anim);
}

function UpDownReleased() {
vely = 0;
}
function MoveUp() {
vely = -5;
}
function MoveDown() {
vely = 5;
}
function LeftRightReleased() {
velx = 0;
StopAnimation();
}
function MoveLeft() {
velx = -5;
if(currentAnim.animName != "Test2") {
SetAnimation("Test2");
}
}
function MoveRight() {
velx = 5;
if(currentAnim.animName != "Test1") {
SetAnimation("Test1");
}
}
}
and PlayerInput should now be


Code:
class PlayerInput extends BaseObject {
function PlayerInput(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
}
function Behaviour() {
if(Key.isDown(Key.UP)) {
MoveUp();
} else if(Key.isDown(Key.DOWN)) {
MoveDown();
} else {
UpDownReleased();
}
if(Key.isDown(Key.LEFT)) {
MoveLeft();
} else if(Key.isDown(Key.RIGHT)) {
MoveRight();
} else {
LeftRightReleased();
}
}
function UpDownReleased() {
}
function MoveUp() {
}
function MoveDown() {
}
function LeftRightReleased() {
}
function MoveLeft() {
}
function MoveRight() {
}
}
Now your code is a little more structured - you can add handling code in PlayerInput and more behavioural code in Player. Also remember if you decide to make any changes to the MoveXXX() functions in PlayerInput and you also want the Player class or any other classes to follow this behaviour you need to add a call to the parent classes function in your child class...

So for instance in Player:


Code:
function MoveUp() {
super.MoveUp(); // Add this to tell the class to also run the code that's in the parent classes MoveUp() function
vely = -5;
}
5. Shooting

So now that we have a moveable player class and some animation, let's start crafting it all into a little exercise and create a space invaders clone.

First of all we need to add the handling of the 'shooting' button into the PlayerInput class

Change the behaviour code and add a ButtonPressed function in PlayerInput:


Code:
function Behaviour() {
if(Key.isDown(Key.UP)) {
MoveUp();
} else if(Key.isDown(Key.DOWN)) {
MoveDown();
} else {
UpDownReleased();
}
if(Key.isDown(Key.LEFT)) {
MoveLeft();
} else if(Key.isDown(Key.RIGHT)) {
MoveRight();
} else {
LeftRightReleased();
}

if(Key.isDown(Key.SPACE)) {
ButtonPressed();
}
}
function ButtonPressed() {
}
Now we need to create an object that can be 'shot' at something else.

Let's start by creating a Projectile class which we will use for shooting about the place


Code:
class Projectile extends BaseObject {
var power:Number;
var LifeTimer:Number;
var owner:BaseObject;
function Projectile(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
LifeTimer = 50;
}
function Behaviour() {
super.Behaviour();
if(LifeTimer > 0) {
LifeTimer--;
} else {
Remove();
}
}
}
This bullet code contains some behaviour which removes it after 50 frames.
Ok so how do we go about shooting it or making it collide? We'll take care of the shooting part first.

First create a small movieclip in the library which will serve as your bullet. Export for actionscript in the library and call it 'Bullet'

Now add this code to Player


Code:
var FireTime:Number;
function Behaviour() {
super.Behaviour(); // Remember to add this or all our button handling code wont be run
// Decrement our 'firetime' counter so we can fire again when it reaches 0
if(FireTime > 0) {
FireTime--;
}
}
function ButtonPressed() {
// Are we allowed to fire?
if(FireTime == 0) {
// Create a new projectile, set it to our position, set its velocity
var p:Projectile = new Projectile(oList, "Bullet", null);
p.isEnemy = false;
p.vely = -8;
p._x = _x;
p._y = _y;
p.owner = this;
// Give us a delay of 5 frames before we can fire again
FireTime = 5;
}
}
When you press the button in game you should get a steady stream of bullets
Now onto the collision...one of the easiest ways to do this is to set up a simple bounding box or use sphere collision. Let's use sphere collision for this basic example as it's very simple and requires less variables/setup than box collision.

First of all we need to put a variable somewhere which holds the 'size' of each of our objects. I reckon we should put this on the BaseObject class as most if not all objects in the game will have some sort of size.

Add the size variable and the collision variable to BaseObject

This size variable will be the radius of your collision circle (not the diameter!)


Code:
var size:Number;
var collision:Boolean = true; // Default this to true, most objects in game will have collision
Now in your constructor function for Projectile set the size of the object (or you could do it on the firing code to make bullets with different collision box sizes depending on who fired them - i.e. big for good guys, small for bad guys to give you a chance!)


Code:
function Projectile(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
LifeTimer = 50;
size = 5;
}
So we've got a 'size' on our projectiles. Let's make them collide with other things - for now we will put the code directly in the Projectile class

Add the CheckCollision function and modify Behaviour accordingly


Code:
function CheckCollision() {
// Loop through the object list and find all objects which we could collide with
for(var i = 0; i < oList.length; i++) {
// Don't collide with myself!
if(oList[i] <> this) {

// Don't let friendly bullets collide with friendlies or enemy bullets collide with enemies
if(oList[i] != owner) {

// Check to see if we were close enough to hit the object
// Use the formula x*x + y*y - R*R
var dx:Number, dy:Number, r:Number;
dx = _x - oList[i]._x;
dy = _y - oList[i]._y;
r = size + oList[i].size;

// This formula returns a value - if the value is zero or less than zero the two circles are overlapping

if(dx * dx + dy * dy - oList[i].size * oList[i].size <= 0) {
// This is where we'd do some damage to the object we hit but we haven't got that far yet, so for now lets just remove the bullet
Remove();
return;
}
}
}
}
}

function Behaviour() {
super.Behaviour();
if(LifeTimer > 0) {
LifeTimer--;
} else {
Remove();
}
CheckCollision();
}
Now these bullets should collide with objects and disappear. Let's give them something to collide against

Modify the code on the root timeline to


Code:
var oList:ObjectList = new ObjectList(this);
var test:Player = new Player(oList, "TestObject", null);
var test2:BaseObject = new BaseObject(oList, "TestObject", null);
test2.size = 30;
test2._x = 200;
test2._y = 10;
test._x = 200;
test._y = 200;
onEnterFrame = function() {
oList.MainLoop();
}
Now you have a solid object which should be absorbing the bullets you are firing at it!

Note that bullets can also collide with themselves at the moment so I'd probably not make them too big (size 50 will make them collide with each other and disappear!)

Why not add a few simple particle effects to the bullets...create a new library object called 'Spark' and make it a little yellow circle (or be imaginative!) make sure you link it with the 'spark' name

Create a new class called Particle


Code:
class Particle extends BaseObject {
var LifeTimer:Number;
function Particle(_oList:ObjectList, clipName:String, _parent:BaseObject) {
super(_oList, clipName, _parent);
LifeTimer = 50;
collision = false;
}

function Behaviour() {
super.Behaviour();
if(LifeTimer > 0) {
LifeTimer--;
} else {
Remove();
}
}
}
Now add the Kill() function to Projectile and change the call to Remove() in the collision code to Kill() instead


Code:
function Kill() {
// Create 10 particles and set them to random directions. Also set the lifetimer to a random small value
for(var i = 0; i < 10; i++) {
var p:Particle = new Particle(oList, "Spark", null);
p._x = _x;
p._y = _y;
p.velx = Math.random() * 10 - Math.random() * 10;
p.vely = Math.random() * 10 - Math.random() * 10;
p.LifeTimer = 10 + random(5);
}
// Make sure we remove this object
Remove();
}
There you go, lovely particles flying about the place!

Right - that's got you started. I will be doing a second part to finish off this tutorial soon

::Charleh::

Mp3 Tutorial, Part 2 - Problems With Buttons
I hope someone can help me here. I havent done very much flash and therefore if it goes wrong, I have no idea where to start to try and fix it!

I am having a problem with the second part of the tutorial, in that the buttons dont work. The pointer changes on mouseover so it knows its a button, but the mouse over effect doesnt happen and nothing happens when its clicked. Could it be my flash thats the problem?? I ask this as the same happened on another flash project I was working on. But the difference with that one was the object wasnt a movie clip but a button. It was a straight forward (or so I thought) getURL funtion but the same thing happens - the pointer changes but nothing happens when its clicked.

My only problem is with the buttons - at the stage Im at in the tutorial, the player is fine and a big thanks for the great video tutorial

Many, many thanks to anyone who can offer any help of how I can get this sorted. Im pulling my hair out here - lol.

Tutorial - Video Basics Part 2
First of all I would like to say that Lee's tutorial section is wonderful. Thank you Lee.

I am working with this tutorial and can not seem to get the play and rewind buttons to work. I tried searching the forums, but could not come up with any answers. I watched Lee's video about 10 times to make sure I was doing exactly what he did, but I must be missing something. What are some common errors that beginner's make? I have been at this for 5 hours and have yet to find the answer.

thank you for any help. I have attached a link to the FLA.

http://www.yousendit.com/download/aHlUY ... eE41VEE9PQ

Flash Mp3Player Part 2 TUTORIAL ...
I dont have much experience with AS, just a very basic understanding of how some of it works. With regard to this tutorial, the AS is setup so the first song starts playing automatically, but I'd like to have it so the user has to press the PLay button for the music to start.
My attempts at editing the AS to achieve this end up compromising the Pause/PauseIt functions from working, or no music at all. It's the principle/logic that I seem to be struggling with here.

I tried to work the 'playSong' function into the playPause=onRelease section, as well as some other things I'd rather not mention.
Any help would be greatly appreciated.


Code:

//Setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);

//Array of songs
var sa:Array = new Array();

//Currently playing song
var cps:Number = -1;

//Position of music
var pos:Number;

//Load the songs
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad= function()
{
   var nodes:Array = this.firstChild.childNodes;
   for(var i=0; i<nodes.length;i++)
   {
      sa.push(nodes[i].attributes.url);
   }
   playSong();
}

xml.load("songs.xml");

//PLay the mp3 file
function playSong():Void
{
   s=new Sound();
   if(cps == sa.length -1)
   {
      cps = 0;
      s.loadSound(sa[cps], true);
   }
   else
   {
      s.loadSound(sa[++cps], true);
   }
   playPause.gotoAndStop("pause");
}

//Pauses Music
function pauseIt():Void
{
   pos=s.position;
   s.stop();
}

//unPauses Music
function unpauseIt():Void
{
   s.start(pos/1000);
}

//Music Controls

//Play/Pause toggle
playPause.onRollOver=function()
{
   if(this._currentframe==1)this.gotoAndStop("pauseOver");
   else this.gotoAndStop("playOver");
}

playPause.onRollOut=playPause.onReleaseOutside=function()
{
   if(this._currentframe==10)this.gotoAndStop("pause");
   else this.gotoAndStop("play");
}

playPause.onRelease=function()
{
   if(this._currentframe==10)
   {
      this.gotoAndStop("playOver");
      this._parent.pauseIt();
   }
   else
   {
      this.gotoAndStop("pauseOver");
      this._parent.unpauseIt();
   }
}

//Next Button
next.onRollOver=function()
{
   this.gotoAndStop("nextOver");
}
next.onRollOut=next.onReleaseOutside=function()
{
   this.gotoAndStop("next");
}
next.onRelease=function()
{
   this._parent.playSong();
}

Video Scrub Tutorial Question PART II
I've narrowed down the issue I was having previously about the video scrub problem.

To recap, I successfully learned how to make the video scrubber using the tutorial on this website (video basics part 4 & 5). But when I reload (loadMovie) the swf that has the flv and the scrubber from a parent swf, the scrubber stops working.

What I've found out is that it doesn't work when you run the swfs from the html file or the browser!? When I first open the swfs with a browser, the flv starts to play and the scrubber works. But when I click on the button in the parent swf that loads the swf with the flv and scrubber, the scrubber fails to work.

here is the fla files that i've been working on. Please check out the files. you can open the html in your browser and see what i'm talking about.
http://www.saihara.com/stuff1.zip

thanks

Part II Of My Tutorial: Making Nice Glowing Effect
Hi,

I've wrote the next tutorial and I hope it can help you.
http://www.bestcatalog.net/tutorial_...sh_part2_1.htm

Making Nice Glowing Effect and learning basic Flash techniques and ActionScript.
In this tutorial, you will learn how to work with rulers and guides, use oval tool to create effects for different parts of the image, adjust vector curves, use shape tween with radial gradient fills, create motion tween in combination with advanced color style for movie clips, use instance name and arrays to randomize the animation.

Your comments are welcome!
http://www.bestcatalog.net/tutorial_...sh_part2_1.htm

Thanks,
Eugene

Flash Mp3Player Tutorial - Part 3 Actionscript Error
Hi,

First of all thanks to nebutch & yarcub for their halp on my last problem.

I have followed the video tutorial to get the song information to display through the dynamic text area but when I play the swf file I keep getting the same error. All I have done is added a year attribute to the xml file so that the year of the track may be displayed aswell. Can somebody please point out where I am going wrong again.

(ps; I am a newbie to all this coding!)

The error that comes up is below;

----------------------------------------------------------------------------------------------

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 2: ActionScript 2.0 class scripts may only define class or interface constructs.
{

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 3: Attribute used outside class.
public var earl:String;

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 4: Attribute used outside class.
public var artist:String;

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 5: Attribute used outside class.
public var track:String;

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 6: Attribute used outside class.
public var year:String;

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 8: Attribute used outside class.
public function Song(e:String, a:String, t:String, y:String)

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Player
ot working gotolearn.comSong.as: Line 15: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Total ActionScript Errors: 7 Reported Errors: 7

Error opening URL "file:///D|/OFSYSTEMS/OFSYSTEMS%20WEB%20DESIGN/mp3Player/not%20working%20gotolearn.com/undefined"

---------------------------------------------------------------------------------


below is the actionscript for mp3Player.as:


// Setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);

//Array of songs
var sa:Array = new Array();

//currently playing song
var cps:Number = -1;

//Position of music
var pos:Number;

//Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.track, nodes[i].attributes.year));
}
playSong();
}

xml.load("songs.xml");

//Play the mp3 player file
function playSong():Void
{
s = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
mute.gotoAndStop('on');
if(cps == sa.length - 1)
{
cps = 0;
s.loadSound(sa[cps].earl, true);
}
else
{
s.loadSound(sa[++cps].earl, true);
}
playPause.gotoAndStop('pause');
}

//Pauses the music
function pauselt():Void
{
pos = s.position;
s.stop();
}

//unPauses the music
function unPauselt():Void
{
s.start(pos/1000)
}

//Music Controls

//Play/Pause Toggle
playPause.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop('pauseOver');
else this.gotoAndStop('playOver');
}

playPause.onRollOut = playPause.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop('pause');
else this.gotoAndStop('play');
}

playPause.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop('playOver');
this._parent.pauselt();
}
else
{
this.gotoAndStop('pauseOver');
this._parent.unPauselt();
}
}

//Next Button
next.onRollOver = function()
{
this.gotoAndStop('nextOver');
}

next.onRollOut = next.onReleaseOutside = function()
{
this.gotoAndStop('next');
}

next.onRelease = function()
{
this._parent.playSong();
}

//Mute Button
mute.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop('onOver');
else this.gotoAndStop('offOver');
}

mute.onRollOut = mute.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop('on');
else this.gotoAndStop('off');
}

mute.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop('offOver');
s.setVolume(0);
}
else
{
this.gotoAndStop('onOver');
s.setVolume(75);
}
}


---------------------------------------------------------------------------------------------------

Below is the actionscript for Song.as


classSong
{
public var earl:String;
public var artist:String;
public var track:String;
public var year:String;

public function Song(e:String, a:String, t:String, y:String)
{
earl = e;
artist = a;
track = t;
year = y;
}
}



Again your assistance is needed!!!

Flash Mp3Player Tutorial - Part 1 Actionscript Error
Hi,

I have followed the video tutorial to create a flash mp3 player but when I play the swf file I keep getting the same error with the .as file. Can somebody please point out where I am going wrong

The error that comes up is below;

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Playermp3Player.as: Line 19: Unexpected '}' encountered
}

**Error** D:OFSYSTEMSOFSYSTEMS WEB DESIGNmp3Playermp3Player.as: Line 23: Unexpected '}' encountered
}

Total ActionScript Errors: 2 Reported Errors: 2

Below is the script I have entered for the .as file

// Setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);

//Array of songs
var sa:Array = new Array();

//currently playing song
var cps:Number = -1;

//Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
}
sa.push(nodes[i].attributes.url);
}
playSong();
}

xml.load("songs.xml");

//Play the mp3 player file
function playSong():Void
{
if(cps == sa.length - 1)
{
cps = 0;
s.loadSound(sa[cps], true;
}
else
{
s.loadSound(sa[++cps], true);
}
}


Your assistance is needed!!!

Newbie: Video Basic Part 2 Tutorial: Buttons Don't Work.
Specs:
Mac OSX 10.4.7 (Intel)
Flash Professional 8
File: http://www.sugapablo.net/~sugapablo/fla ... test2.html
Browser(s): Mozilla 2.0 and Safari


Trying out Flash for the first time, and I tried to get a simple movie
going.

I created a quick .mov movie, converted it to .flv using the Flash
VideoEncoder, imported it, placed a couple custom buttons on it, and
uploaded it to my server.

The video plays fine. The control bar and buttons I created are there,
and they change colors exactly how I told it to.

But the buttons (rewind and play) don't work.

I was following an online tutorial (video
basics parts 1 & 2) and followed it exactly, but mine just doesn't work.

Any clue why based on the video and the action script (below)? (Which should be identical to the tutorial.):


Code:

var nc:NetConnection = new NetConnection();
nc.connect(null); //not using communications server

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.play("family_album.flv");

rewindButton.onRelease = function() {
   ns.seek(0);
}

playButton.onRelease = function() {
   ns.pause();
}



Yes, I did give the button objects instance names identical to those in
the script.

Embedded Video Object In Video Basics - Part 1 Tutorial
I am a total newbie at Flash, so please bear with me. In Lee's Video Basics - Part 1 tutorial, one of the first steps is to create a Embedded Video object in the library. Flash Professional MX 2004 is being used in the tutorial and I am using Flash Professional 8, so maybe that is the reason I'm having a problem. The tutorial shows that by clicking "New Video" in the library panel, the embedded video object is automatically added to the library. When I click "New Video", I get a Video Properties dialogue box that defaults to "Video (ActionScript-controlled)". When I check the Embedded option, the OK button becomes disabled...only Cancel and Import are enabled. Clicking the Import button gives me an open dialogue box for a *.flv file. I'm not sure what to do here. Am I supposed to select the .flv file that I am going to use? I was under the impression that the tutorial was creating a generic object that I would be able to reuse whereas selecting a .flv file would make it specific to what I'm working on now. Can someone that is using Flash Professional 8 clarify what I should do?

Thanks,

Pat

Loop One Part Of A Movie For Ever And Stop Another Part
does anybody know how to make a bit of my flash movie loop continously but another bit of it stops

Just Found This Out....1 Part Heads Up / 2nd Part A Question..
old i know you won't care but maybe some will take this into consideration..i just found out that aol's new browser 7.0 and ie 6 are not compatible..buttons that call javascripted buttons (pop ups, etc), are not working..I guess bill gates and the new timewarner/aol guru are having tissies..aol will have to go back and build a patch for aol 7.0, the only other option for them i guess would be switch to netscape as there default browser..but bill probably, somehow, owns that one too..

anyways just thought you guys would like to know that for anyone who clicks on your sites with aol7.0 your javascript isn't working..

craziness.............

now for the question..i know this is the wrong forum but i'm gona ask you guys to explain this to me..it's a javascript that preloads images..will someone break it down and explain this to me..benefits of it of course i know..just not understanding exactly how it works..

<!-- ImageReady Preload Script (blank.bmp) -->
<SCRIPT LANGUAGE="JavaScript">
<!--

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments].src = changeImages.arguments[i+1];
        }
    }
}

var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        source_01_over = newImage("images/home_01-over.gif");
        source_02_over = newImage("images/pics_01-over.gif");
        source_03_over = newImage("images/3d_01-over.gif");
        source_04_over = newImage("images/why_01-over.gif");
        source_05_over = newImage("images/links_01-over.gif");
        preloadFlag = true;
    }
}

// -->
</SCRIPT>
<!-- End Preload Script -->



carlsatterwhite@orlandomediasolutions.com

Play 1st Part, Preload 2nd Part, Play 2nd Part: Possible?
I've recently started with Flash development and I was wondering if the following was possible using only one Flash file?

- The first part is shown and the user can click a button here to continue.
- When he clicks the button, a preloader part is shown and the rest of the file is loaded.
- When it's done, the rest is shown.

I already have the parts seperated in movieclips and unchecked the "export in first frame" option on the movieclips for the second part, but that doesn't help.

If this isn't possible, how should I go about it then? Should I use a second .swf which I load with a loadMovie statement?

Trigger A Button In Work Part Of The Movie From Another Part Of The Movie
i did know how to do this but since forgot

i have my bav bar mc with all the button to load relevent sections
THe code for the buttons are on a keyframe

ActionScript Code:
b1.onRelease = function() {
    _root.win1._alpha = 0;
    _root.win1.loadMovie("blog.swf");
    _root.win1._x = 0;
    _root.win1._y = 25;
    ov1.gotoAndStop(15);
    b1.enabled = false;
    //
};
In the past i was abe to trigger this from elsewhere in my movie but i have since forgot how to do it. i did scan the help files but couldnt find anything of any relevenace.

Thanks for any help.
Paul

How Did They Do That Part II
2 Questions:

1. How do you get those transition fades on the blurred images like on:

http://www.yigal-azrouel.com/flashpage.htm

I kinda have a poorman's version where I measure the offset of the center of the blur image, and then push the offset number into the _alpha setting of the blurred image. So if the x position is 23 pixels away from the center the blurred image...the _alpha of the blurred image is 23%

BUT YIGAL's is so much smoother and seems to work in a range or something.

2. Is there a way to make a negative integer into a positive?

Cause my poorman's idea works in the postive offset, but if you move left of the center, then the offset equals -23 and my _alpha gets thrown off.

THANKS!

Part Two
You can also tell the parent MC to stop (play, move, go to location x or y, change dimensions/colour etc.) Let’s say you have an MC called “bouncing ball”. Let’s also say that your “All buttons” MC is placed inside the “Bouncing ball” MC.

{
<Bouncing Ball>
<all buttons>
}

You could tell the ball to stop with this code
on (release) {
with (_parent) {
stop();
}
}
That is because, in this case “Bouncing ball” is the parent MC of “All buttons”.

Those are two of the basics; _root and _parent. You will notice that when you use the target tool it will demonstrate clearly the use of finding an MC from the root or in relation to the MC or button doing the telling. Click on a button. Chose variables/with. Place your cursor in the object window. Click the “insert target path button” (the cross hairs) from here you can target any MC—so long as you have named it! Note that Flash will put in the path for you eg:
an absolute path: _root.mc1.mcA
a relative path: mc1.mcA (this depends on the location of mcA and it’s relation to the location of the button doing the call)

Now that you understand the purpose to directing your tell with either _root or _parent you can take it a step further and tell from any location. Let’s take your example. Using the RED button in “all buttons” we want to tell the MC “bouncing ball” to stop. With the GREEN button we want to tell MC “bouncing Square” to stop. Both “all buttons and “bouncing ball” are on the root but “bouncing Square” is inside “Bouncing ball”.

The code on the RED button is:

on (release) {
with (_root.bouncingBall) {
stop();
}
}


The code on the GREEN button is:

on (release) {
with (_root.bouncingBall.bouncingSquare) {
stop();
}
}

If you want to get really fancy you can replace the (_root.bouncingBall.bouncingSquare) with a variable.

Place a dynamic text on the root. Name is variableName. On the BLUE button within “all buttons” code:

on (release) {
with (_root:variableName) {
stop();
}
}

*note that there is now a : (column) to show that we are telling a variable not an MC. Run the swf and click the BLUE button. Nothing happens. Now put _root.bouncingBall.bouncingSquare into the dynamic text field and click the BLUE button once more. Notice how “Bouncing Square” stops moving

Now OPEN your mind and think of all the possibilities this leads to.

How Was This Done? ( Part 2 )
http://www.intentionallies.co.jp/content_normal.html

How come when you resize the window the objects don't scale/distort? The object move along with the window's size, where as, the logo and text stand still.

Second Part
Hi again

Mad Dog was nice enough to help with my first question and of course I need help with something else...

Here again is the site I am trying to duplicate.
www.niketraining.ca

I want to know if I can do a rollover inside a rollover...

When a rollover is executed for my drop down menu, I want 3 dift pictures(links) to fade in and when you roll your mouse over each one I want it to go from black and white to colour. I know how to do that type of movie clip but what I dont know is how it to execute within its parent rollover.

Here are the files.
swf
http://www.megaupload.com/?d=ICW5WPO1

fla
http://www.megaupload.com/?d=VKGQC9Q7

Thanks a ton for any assistance.

Where Dit Part 1 & 2 Go?
I'm new to Flash so I thought let's follow the Flash 101 cursus. I started with part 1 and after a few days I couldnt find part 1 and 2 anymore. Does someone know where they are or have them on his/here pc?

VoS

To The Tutorial Writing Staff: XML Portfolio Tutorial
Hi guys!

I'm a basic actionscript user which knows the basics of xml and actionscript. I've been seaching for a tutorial for a long time now how to make a portfolio which is dynamic and loads info from an external .xml file.

Since i couldn't find any tutorial like this i've tryed to make my own script out from this xml file:


Code:
<portfolio thumburl="thumbs/" imgurl="images/">
<project hdline="my first project" client="none" date="2007-01-02" category="website" weburl="http://website.com">
<image url="image1.jpg"/>
<image url="image2.jpg"/>
<image url="image3.jpg"/>
<description><![CDATA[This describes my first project]]></description>
</project>
</portfolio>
I have hade in mind that you should see a bunch of thumbnails first in a table format (like 6 cols and 3 rows) on each page, then you should be able to select page with next and prev buttons. When you press on a thumnail a box with the bigger image shuld pop-up and you should be able to read the other information in the xml file (such as client, date etc etc).

I've tryed to make this but it's to advanced. And my version is very buggy, aswell.

Here is what i've done sofar:
www.vmgcomputers.com/xml/portfolio3.swf

I don't know if this helps but here is a "multiple loader" i found:
http://www.johnnyslack.com/content/d...der_jslack.zip


I think there are many guys who are looking for a tutorial about this so please consider to make one, all professionals out there!

Using % As Part Of A Variable Value
I am using an external file with values for text fields in my movie, but some of the values are statistics, that is I need to pull the precent sign from the text file, but evertime I put it in it just wont appear during the movie.

Is there a way around this? I cant have the % sign in movie sparately because the length of the text may change, and the sign would have to move accordingly, and also theres about 20 of these, so fancy scripting might be tedious to maintain.

There's gotta be a simple way to do this!

Can anyone please help?

Thanks

Simon H

Dunno What To Do.... Part 2.. Lol
Well now for those of you that didnt read my last post i have made a picture come on to the screen with a laser engraving it... now i have a picture of the front of the building, with and without the door open. Both of which are Jpg's inserted into flash. Now how do i get the door to open gradually and zoom in through it? (Zoom bit i can do....i think! lol) But i tried tweening one onto the other.. didnt work and then i tried breaking the images apart but the break apart didnt work properly... HELP!

Simon

Swf Won't Load - Part 2
Okay, got all the swf's loading with "loadmovie" but by using level1 and level2 on the respective movies, the base movie remains visable....should I be using level0...AND how does "unloadmovie" figure in all of this...
Thanks - David

2 Part Question
part 1

how do i set a variable based on a movieclips property like alpha or _x?

part 2

how do i say: if that variable=10 goto frame 20?

_________________

if this is not enough information please let me know..

thanks in advanced.

Brian

Loop At Certain Part
hi guys,
need some help with this question.
let say i have a mp3 that i just import into flash 5.

mp3 track = |----------------------|-----|
labelling = 1----------------------2-----3

at first i want to play the whole song from 1 to 3.
when it reach 3, i just want it to loop from 2 to 3 continuosly.

is that possible?

thanks and regards,
yin howe

(part 2 To The Post Below)
IM using swish 2.0 which is similar to flash 5....so tell me how to do it on flash 5.0 if u wanna...i might be able to "translate" it to swish 2.0.

2 Part Question
I have a get flash button. when i put in my code it ask me to put in a object. not sure what they mean by that.

Here is my other question, when i test my movie, if buttons and actions are enabled, they should work, right?as in load the browswer and such..

And i cant get my mailto button to work


Code:
_root.onRelease = function() {
getURL("http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English", "_blank");
};



Code:
_root.onRelease = function() {
getURL("MAILTO:********@****.NET", "_blank");
};

[Edited by Gedion on 08-30-2002 at 12:27 AM]

What Is The Code Part 2
aperently i didn't make it clear what i was asking, don't get upset, i do that alot. i have them all in one fla. what they are exactly is headers for each page. what i want to do is make it to where when page x is loaded, it has header x at the top of it, or if someone clicks the link for page y and page y loads, header y will be at the top. i know how to put flash into a html, but i need to know if there is a way to make it to where when the link for page x is clicked, the html in page x tells it to load only scene x of the fla. ie.. 1 link loads scene 1, 2nd link opens scene 2, etc...i hope i made this somewhat more clear. i'm sure not though

Actions, Part 2
Okay, I got it almost working now, except this:

-----------------------------------------------------------------
var h = d.getHours();
if (h<6) {
display = "Goedenacht, het is nu";
} else if (h<12) {
display = "Goedemorgen, het is nu";
} else if (h<18) {
display = "Goedemiddag, het is nu";
} else if (h<24) {
display = "Goedenavond, het is nu";
}
var greeting = (" "+"display"+"");
---------------------------------------------------------

I guess it's obvious what I'm trying to do here, but when I create a dynamic text field, it just says "display", where it should be "Goedenacht, het is nu" (or one of the other depending on what time it is)

Can anybody say what I'm doing wrong here?

Pong Part 1
Wassup Flashkitters

Ok I have a couple of questions

1. Would someone pleez send me the actionscript for a bouncy ball movement (like in pong)
2. Teach me how to make it bounce when it hits either paddle or the top or bottem thx y'all

Two Part Question
Alright. I've got two questions for you guys

#1:
I can't seem to figure out how I can get a button to do a certain action the first time it's clicked, then a new action the second time it is clicked. I'm thinking the actions would be something like:

if (frame > 20) {
mc.gotoAndPlay.21)

But** it's just not working for some reason.


#2:
Ok, I need a sound clip to start playing as soon as I enter a scene. You'd think as long as I put the sound on the first frame it would do that, but there is a pause (about 1 second).

I have NO clue how to get either of things to work (after much tampering, mind you), so any help would be greatly aprecciated.

2 Part Question
Cheers all,

1) I would like my viewers to beable to email me with a form. Anyone have anyideas on this one I have tryed a few things and just not working.

2) I am wondering could I do a log in type thing with flash with a User name and password. Beable to clock the amount of time they spent on the site.

Any ideas if I can do this with flash and if so how I would go about doing it. Any tutorials out there? If this cant be done in flash anyone know how to go about doing this using anything elce?

Thanks for your time all have a great day

Ecards Part 2
to all freelancers:

what's the going rate for the creation of an ecard?

signed
curious george

How To Load Part Of The .swf
This is my first attempt at using flash. Probably a mistake to do my portfolio? But its made me learn, (at least the very basics).
I have a sort of preloader that tells a rough account of whats loaded, as i have nt worked out the more complicated versions.
But now ive sorta finished the .swf is 548k, while I have a preloader dont think its interesting enough to wait that long. So the question is, do i redo the preloader, or can I load part of the .swf, and have parts of the .swf load on a button click? (and if so, how do I do it please?) I' m using flash 4 and a well thumbed tut book, and cannot stress enough my basic knowledge. thanks, any comments will be welcome. (I have a list of other things that need sorting on the site, another time.) www.sparkcc.co.uk

Why Isn't This Working Part II
on (release) {
_root.gotoAndStop(167);

massage_menu.swf.unloadMovie("_root.skinMenu");
skin_menu.swf.unloadMovie("_root.skinMenu");
}


I have a Empty MC that I am loading a .swf into it named "skinMenu"

Shouldn't the code unload the MC??

One Inside The Other? Part 2
For some reason I can not post a reply so I have to start a new thread.

This is my reply:

Here is the fla:

www.destreedesign.com/website.fla

Here is the swf I need inserted:

www.destreedesign.com/movie15.swf




This is what we were talking about:

You can just drag a movieclip from the library and place it in a nother movieclips timeline. But if you wonder about loading external swf files into a existing one heres the basics.

There are two ways of loading external files into Flash. Either you can load swf files into _levels or into movieclip targets.

_levels only exist in the Flash player. They are like layers but for swf files The Flash player is like a overhead projector where the plastic films you put on top of each other are like the swf files in the player. There are 16000 available levels

//To load a external swf into a _level from a button. The number 1 being the level to load into.

on(release){
loadMovieNum("myExternalFile.swf",1);
}

Movieclip targets are what it sounds like. A empty movieclip placed on the stage just for the purpose of loading a swf file into it. The advantage is that you can place it anywhere, manually ( as opposed to swf's in _levels) and also can control what othe objects shoeld be on top or beneath.

Usually you give the movieclip an instance name of container.

//To load a external swf into a target movieclip from a button ( both being on the main timeline ).

on(release){
container.loadMovie("myExternalFile.swf");
}

Multi-part Help Please
Ok, I'm experimenting with making a menu like what is in the attached file (azienda.fla).
Where, when you click on the image, it enlarges,as well as clears the other images off the screen, then when you click again, it goes back to the small version. I guess this was created in an older version of flash, and partly in another language (Italian?). First off, when making my own version on a new .fla, I've been copying and pasting from (azienda) to my new file. Then replacing the picture. I was hoping I could get some help as to how to do this myself, rather than snaking it off of someone else's file.
The other thing is, in (azienda.fla), the movie clip that has the tween in it that makes the picture enlarge, on the last frame, I want to add a scrollbar, like the one I attached-(scrollbar.fla). But when I do this, it disables the function to close movie (make it small again and go back to the main scene). How can I add this scrollbar to the enlarged picture in the last frame of that movie, still use the close button, then dissapear when I click on the picture again?
Lots of questions, I know.

Scale Only Part Of An Swf
I'm curious as to how the effect of the middle flash horizontal bar being able to be scaled down only when content is being cropped out.

www.bulgari.com

How do they do that?

Hmm Part Deux.
Yeah...

Anyways. I made some graphic in Photoshop and imported them into flash. it seems when I try to overlap in an animation it is all white around and ugly. How can I fix this?

New Window Part 2
Ok, i think of might of described my troubles in the worst possible way, what I need is a pop up window that will pop up when you click a button. this window will have a picture in it, once you finished looking at the picture you can close it down without closing the maion movie. I'm sure there's some action script routine for it but can't remember it for the lif of me.

Please help, as i need to get this website finished ASAP

Many thanks

Getting A MC From Another Part Of Scene One.
I need some help bad. Alright heres the deal. I have one of the sliders that is mouse senstive. So when you move to the right it goes left ect. I want it so when you click on one of the buttons in the slider, a mc comes up but I can't embed it in the slider because then the mc will move with the slider so I need it to be on another stage. How the heck do I code the button to call for the mc on sene 1 (main stage) I need help guys..

Graphics Part?
Hi, Im really new to flash, like really new, and I am wondering if you make your graphics in like photoshop first then import them into flash and add stuff to them? Im wondering cause im a photoshop god and would like to be able to import my psds or jpgs into flash and add cool effects to them

Thanks

Go To Random Part Of Mc
Hi

I am building a website. One section of the site has a gallery of images which fade in and out using tweening one after the other in a movie clip on the main stage. When someone enters the gallery section of the site I would like them to be taken to a random image within the gallery every different time that section is entered.

Basically how do i jump to a random frame label within a movie clip from a button on the main stage?

Thanks
Lex

Swf-Swf Communication Part 2
I am able to get data to pass to another .swf file. Problem is, I am only able to send a text string across the connection.

I need to read in the connection and run a function called arrowForwardOnRelease.

Here is the code thus far

Flash File (Sender)
======================================
//assign a function to the button's event method
userMessage.text = "arrowonrelease"

buttonInstance.onRelease = function()
{
//create the LocalConnection
outgoing_lc = new LocalConnection();

//send the contents of the text field
//using the send() method
outgoing_lc.send("lc_name", "methodToExecute", userMessage.text);
};


Flash File (Reciever)
======================================
//create LocalConnection
incoming_lc = new LocalConnection();

//define function to execute when a connection is made
incoming_lc.methodToExecute = function (param)
{
sentMessage.text = param;
}

//make the connection
incoming_lc.connect("lc_name");


This sends the text over the connection no problem, and the reciever recieves it and outputs it, thing is I need it to then be read in and trigger a function.

Someone suggested using the eval function to do this, but I am not exactly sure how. Any help is much appreciated.

Files thus far are attached.

Thank you

--J

Copyright © 2005-08 www.BigResource.com, All rights reserved