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








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




KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 01-01-2007, 07:58 PM


View Complete Forum Thread with Replies

Sponsored Links:

Simple Random Script. I'm Missing The Loop Part. Please Help.
Hi guys, I'm trying to achieve a random music effect in my game. When you go to the keyframe, i want the script to choose a random number from 1 to 3. If the number is 1, it tells the Movieclip, Music1 to go to Frame 2 (Which has the music loop).

Here is my code


Code:
m = Math.Round(Math.Random(3)+1);
if (m == 1) {
tellTarget ("_root.music") {
gotoAndStop (2);
}
} else if (m == 2) {
tellTarget ("_root.music2") {
gotoAndStop (2);
}
} else if (m == 3) {
tellTarget ("_root.music3") {
gotoAndStop (2);
}
}
Now as I recall, you need to incorporate a loop into that somehow, I looked at the tutorials and they weren't much help. This isn't working correctly so I need some help. Thanks.

View Replies !    View Related
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 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(nodes[i].attributes.url);
}
playSong();
}

xml.load("songs.xml");

//Play the MP3 File
function 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 music
function pauseIt():Void
{
pos=s.position;
s.stop();
}

//Pause the 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.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 Button
next.onRollOver=function()
{
this.gotoAndStop("nextOver");
}

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

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

View Replies !    View Related
Missing Tutorial
Hi guys. About two weeks ago, I came across a tutorial at kirupa that had to do with rotating text around a red can ( I think a coca cola can), I can't seem to find it. Please can you help me out? Thanks
Have a nice day!

View Replies !    View Related
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

View Replies !    View Related
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/

View Replies !    View Related
Tutorial Missing Step
The "Scrolling Dynamically Loaded Text" tutorial was helpful, but there is a step missing -- inbetween the first section marked vi and the second one marked vi, you need to configure the component -- you need to name the target text field scroller and make sure the horizontal is set to False.....

View Replies !    View Related
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.

View Replies !    View Related
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"];
}

View Replies !    View Related
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::

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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();
}

View Replies !    View Related
Type-writer Tutorial....missing?
I tried searching for that type-writer effect tutorial on flashkit but it seems like they took it off or something. Can someone tell me how to do the effect or point me towards the tutorial?

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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!!!

View Replies !    View Related
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!!!

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
Missing Fonts (but Not Missing)
Hi,
I'm working with MX on Mac.
I got some PC FLAs that shows the "missing fonts" error message when opened.

I searched the whole FLAs for textfields using the "missing" fonts, but there are none!
Using the movie explorer I also can't find textfields or anything using the missing fonts!

Whats going on? Are the FLAs corrupt?

View Replies !    View Related
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!

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
What Am I Missing Here?
I have a .swf that's about 52k. Not long enough even at 56k for a preloader, but long enough that I want SOMETHING on the screen for that couple of seconds.

So I created a .swf called "FirstScreen.swf" - it has 2 layers. One contains text that simply puts the word "Initializing" in the middle of the screen. Layer 2 is called "Load", And in Frame 2 of the "Load" layer (I've tried it in Frame 1 as well with no better results), is the following code:

loadMovieNum("HBInterface.swf", 1);

I've checked, and HBInterface.swf is the right title, it's in the same directory as "FirstScreen.swf". So why when I open "FirstScreen.swf" on my local server, I get the "Initializing" screen and that's all that ever happens?

I'm tearing my hair out over this one, someone please help!

Thanks
Neil

View Replies !    View Related
Almost There, Am I Missing Something
This code almost seems to work.



On the initial mc (called: mc_b) I have:

onClipEvent (load) {
mc_a.prototype.floatTo = function (speed, endx, endy) { var dist_x, dist_y, vel_x, vel_y;speed = "."+speed;dist_x = Math.round(endx-_x);dist_y = Math.round(endy-_y);vel_x = dist_x*speed;vel_y = dist_y*speed;_x += vel_x;_y += vel_y;};
}

Then on the button inside the mc (mc_b) I have:

on (release) {

i ++;

if (i == 1){

_root.mc_a.floatTo (6, 232.0, 148.8);

} else if (i == 2){

_root.mc_a.floatTo (6, -200.0, 148.8);

i = 0;

}

}


I am trying to have mc_b move mc_a in and out of the window, though something here doesn't work???

?????

thank you, thank you

View Replies !    View Related
I Must Be Missing Something....
To my knowledge, this should work fine.....

Create a blank MC in the main timeline.

Give it an instance name of "mcMusic".

Import a MP3, goto it's properties and give it a LINKAGE name of "songMusic".

In main timeline, frame 1, add this code:

myMusic = new Sound(mcMusic);
myMusic.attachSound(songMusic);
myMusic.start(0,2);

Run the movie.

To my knowledge, you SHOULD get the mp3 sound to loop twice... but nothing happens...

Any thoughts?

View Replies !    View Related
Please Help, I Must Be Missing Something Here
Okay here the thing. I need to generate a path randomly by selecting a movieClip name from an array and then placing it in a variable so I can use it in my gotoAndPlay statement. It doesn't seem to work the way I have it set up. What am I doing wrong?

bkgArray = new Array("Pink", "Blue", "DBlue", "Orange", "Grey");

setInterval( randBkg, 3000 );

function randBkg(){
getIt = random(4);
nm = bkgArray[getIt];
bkgName = "bkg" + nm; // this would be the movieClip name
labName = nm + "Play"; // this would be the frame label within the movieClip
bkgName.gotoAndPlay("labName");
}

Thanks in advance.

View Replies !    View Related
XML Missing ?
hi,
has anyone ever experienced this problem...
if the xml document is local i can get the declaration and the content - but when live on https, i can only get the declaration..?

(i'm building the movie for use on a local browser)

View Replies !    View Related
Am I Missing Something?
Ok, I'm trying to allocate more memory to flash in Windows XP...I've right clicked on the MX icon, but the memory tab does not show up. How am I supposed to add more memory to MX...I'm used to using Macs, and this problem was easily resolved w/ the 'Get Info' command

Please advise...thanks

View Replies !    View Related
I'm Sure I'm Missing Something...
I'm also sure that I've looked everywhere on this site and I still can't find the answer...

I'm a designer and in my flash only website, I'd like to showcase the best of my work. I want to have each of my pieces scroll through the frame as you rollover a button. I did this without any real trouble- the problem comes in when, all I want to do is make the damn thing go backwards.

How do I make the movie play backwards?

Thank you so much in advance for your help and your time.

View Replies !    View Related
What Am I Missing?
Note following code:

on (press) {
fileExists = new LoadVars();
fileExists._parent = this;
fileExists.onLoad = function(success) {
if (!success) {
_root.flags[i] = 1;
setProperty(eval(block), _visible, true);
}
};

file = "tc01nav.swf";
i = 1;
block = "_root.iblockmenu1";
fileExists.load(file);

//play();
}

Okay, what keeps me from calling this for another file? For example:

Placing this code directly before the //play line...
file = "tc02nav.swf";
i = 2;
block = "_root.iblockmenu2";
fileExists.load(file);

Doesn't buy me anything. Actually things get trunced and I get wierd results...

Am I missing something obvious. Don't quite understand this kind of function call. Use to the function(passin) return(passout) variety.

Any guidance, much appreciated...thanks.

View Replies !    View Related
What Am I Missing?
I am trying to put a short password entry at the beginning of my FLA.
I have placed an "input text" field on the timeline and made it a password (so only *s will appear as you type). I named it "password".

Next I created a button for the user to click after they have entered their password. The idea is that when the user clicks the button, the action script will look to see if it matches a pre-determined password and if so, move them forward. If not, it should display a message in a different dynamic text field named "value".

Here is my code:

on (release){if (_root.password.value eq "Pass"){gotoAndPlay("Start");}else{_root.check.val ue="Incorrect Password. Please try again.";}}

It doesn't work. Suggestions, Ideas, Directions?????
I'm using MX 2004 Pro. and will try to attach the file.

View Replies !    View Related
What Am I Missing ?
i have a movie clip that i'm trying to use as a button
which seems fine when i want to go somewhere in the same scene so long as a put _root. infront of the goto command
trouble is i want it to go to another scene and it just wont go i've tried it with and without the _root. bit in and neither way works
hers what i've put in :

onClipEvent (mouseDown) {
gotoAndPlay("quality", 1);
}

what am i missing ?

View Replies !    View Related
Hmm... I Am Missing Something...
Well, I just started Flash a week ago and I learned how to create a button, but I do not know how to use the button as a link. It is just a button that can be clicked right now. I would like to make it link to another page on my site. How do I go about this? As well, how do I use the Hit frame? What is the action and all?

P.S. I would also like to know how to make the button stay a certain color after clicked signifying that you are viewing that page. Furthermore, how can I have my flash image have a transparent bg?

Thanks in advanced.

View Replies !    View Related
What Is Missing?
Okay.....I followed the tutorial from here on how to make a spaceship move. When I went to try and add firing to it, it won't work. What is wrong with this code?

THIS IS FOR THE SPACESHIP
code:
onClipEvent(load){

moveSpeed=10;
_root.laser._visible=false;
laserCounter++;

}


onClipEvent (enterFrame) {

if (Key.isDown(Key.CONTROL)) {
laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;

}

if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}

if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}

}



THIS IS FOR THE LASER
code:
onClipEvent (load) {

laserMoveSpeed=20;
this._y=_root.spaceship._y;
this._x=_root.spaceship._x+80;

}
onClipEvent (enterFrame) {

this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}

}


Thanks for all the help!

View Replies !    View Related
What Am I Missing?
ARG, this should work? What the heck am I overlooking??


Code:

function createLink() {
var Message:String = "Click Here: <a href=http://Apple.com>Apple.com</a>";
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "Monaco";
my_fmt.size = 10;
my_fmt.color = 0x000000;
//
this.createTextField("Message_txt", 999, 12, 13, 319, 319);
Message_txt.embedFonts = true;
Message_txt.antiAliasType = "normal";
Message_txt.gridFitType = "pixel";
Message_txt.sharpness = 400;
Message_txt.html = true;
Message_txt.selectable = true;
Message_txt.wordWrap = true;
Message_txt.multiline = true;
Message_txt.border = true;
Message_txt.setNewTextFormat(my_fmt);
Message_txt.htmlText = Message;
}
onMouseDown = createLink;
thnx

View Replies !    View Related
Ok, What Am I Missing?
This is on a key frame, main time line and when the "up_bn" button is release I want my mc "EZ_vessals" to increased by 25. What do I need to add to this script to make it work? Thanks!


up_bn.onRelease = function(){
EZ_vessals._xscale = EZ_vessals._xscale +25;
EZ_vessals._yscale = EZ_vessals._yscale +25;
}

View Replies !    View Related
Am I Missing Something?
I had finished writing the following code for a movieclip to follow the mouse.

code:
onClipEvent(load) {
this._y = ypos;
this._x = xpos;
}

onClipEvent (enterFrame) {
if (Boolean(follow)) {
ypos = _root._ymouse;
xpos = _root._xmouse;
this._y += (ypos-this._y)/7;
this._x += (xpos-this._x)/7;
}
_root.follow=true;
}


The movieclip is in the root timeline. so when I want it to stop it from following the mouse, i presumed the I would have to enter _root.follow = false;

But nothing happens when the false command is executed. any suggestions?

thanks in advance

View Replies !    View Related
What Am I Missing Here?
Having problems with this FLA file:

Problem File

I thought what I was trying to do was simple but I struggle with Flash to be frank. Simply put, I want the user to rollover the '01' in the top left corner which will subsequently play the 01_Movie on the right.

Can anybody point me in the right direction here?

Thanks in advance.

View Replies !    View Related
What Am I Missing Here?
var request:URLRequest = new URLRequest();


function postdata(event:MouseEvent):void {
request.data=txt1.text;
request.url="process.php";
request.method=URLRequestMethod.GET;

trace(txt1.text);
}


trace result shows what ever you type in the text field but the data never goes through php any ideas??

View Replies !    View Related
I Must Be Missing Something? Help
Ok so I am a newbie and have cobbled together some code to import xml and use it to lay out information and it amazingly was working. I decided to make the Function named "bigaction" out of a section and now I get the error:

Error #1010: A term is undefined and has no properties.

....and my while loop goes round once.

if I comment out the line below, the rest works:

this[thumbcounter].text=myXML.productname[i];



I think I must be missing something and its probably an easy fix. Please Help. Any ideas appreciated. Thanks in advance.

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

Here is the full code:


// BASIC MENU DISPLAY

stop ();

var productfamily:String="hello.xml";

family1.addEventListener (MouseEvent.CLICK, buttonClick_1);

family2.addEventListener (MouseEvent.CLICK, buttonClick_2);

family3.addEventListener (MouseEvent.CLICK, buttonClick_3);

trace(productfamily);



//************************************************** ******
// Button functions


function buttonClick_1 (myevent:MouseEvent):void{

//productfamily="fam1.xml";

bigaction("fam1.xml",0);

}

function buttonClick_2 (myevent:MouseEvent):void{

//productfamily="fam2.xml";

bigaction("fam2.xml",0);

}

function buttonClick_3 (myevent:MouseEvent):void{

//productfamily="fam3.xml";

bigaction("fam3.xml",0);

}

//************************************************** *********************
// big function to bring in XML and lay it out


function bigaction(productfamily:String,i:int) {



//************************************************** ******************



//load data from XML document

var myURLLoader:URLLoader = new URLLoader();
var myURLRequest:URLRequest = new URLRequest(productfamily);
myURLLoader.load(myURLRequest);
myURLLoader.addEventListener(Event.COMPLETE, dataOK);

function dataOK(myevent:Event):void {

var myXML:XML=new XML(myURLLoader.data);

//put XML data into familyone array

var productcount = myXML.productcount[0];


var pc:int = productcount; // internal product count from xml data



// XML is now loaded



// display stuff*******************************************

//Display Family Title
family_title.text = myXML.familyname[0];


//This lays out thumbnails

//var i=0;
var zzz:int;
var thumbcounter:String;

var thumbx:Array = new Array();

thumbx[0] = 820;
thumbx[1] = 931;
thumbx[2] = 820;
thumbx[3] = 931;
thumbx[4] = 820;
thumbx[5] = 931;
thumbx[6] = 820;
thumbx[7] = 931;
thumbx[8] = 820;
thumbx[9] = 931;

var thumby:Array = new Array();

thumby[0] = 25;
thumby[1] = 25;
thumby[2] = 125;
thumby[3] = 125;
thumby[4] = 225;
thumby[5] = 225;
thumby[6] = 325;
thumby[7] = 325;
thumby[8] = 425;
thumby[9] = 425;


while (i<(pc)) {

zzz = i;
zzz.toString();
trace(zzz);
thumbcounter =("thumbtext_"+zzz);
trace(thumbcounter);

trace (myXML.productname[i]);

//PROBLEM LINE BELOW
this[thumbcounter].text=myXML.productname[i];

// load and position thumbnail images
var myrequest:URLRequest=new URLRequest (myXML.productthumbimage[i]);
var myloader:Loader=new Loader();

myloader.load(myrequest);
addChild(myloader);
myloader.x=thumbx[i];
myloader.y=thumby[i];
trace(thumbx[i]);
trace(thumby[i]);
trace(i);
trace(pc);

i+=1;
}

}

}

stop ();

View Replies !    View Related
What's Missing Here?
OK...so a friend of mine is trying to put a slideshow I made for him on to their website, here:

http://www.covenantnaples.com

notice how it just sits and says "loading..." which means that the movie has initialized, but it's just not loading the pictures...

HOWEVER, if I navigate directly to the swf file here:

http://www.covenantnaples.com/slides...eSlideshow.swf

it works just fine.

Anyone know why this could be? How can it work in one spot and not in the other, when technically, they're both the same spot as far the the source file is concerned?

View Replies !    View Related
SWF Is Missing In IE When Used Under Dd Tag
Here is the link;

http://www.creamediadesign.org/new_site/reviews_on_tv.html

When you click on video a small window opens with an embedded flash in it, but I can not see the swf movie at all in IE...

Any suggestions?[





























Edited: 01/25/2007 at 05:17:12 AM by Blanktruth

View Replies !    View Related
What Am I Missing Here?
Hey guys, im just messing around with creating dynamic TextFields, but i cant get this to work.

I know it's something simple im missing here, but i cant figure it out.
This works if i create the Text fields on stage, but if i try to create them at runtime it doesnt work.








Attach Code

this.createTextField("mouse_y",this,10,20);
this.createTextField("mouse_x",this,10,40);
this.createTextField("mouse_actions",this,10,50);

/*
trace("y= "+mouse_y);
trace("x= "+mouse_x);
trace("actions= "+mouse_actions);
*/

onEnterFrame = function(){
mouse_y.text="y_pos: "+this._ymouse;
mouse_x.text="x_pos: "+this._xmouse;
this.onMouseDown = function(){
mouse_actions.text="You have just pressed your mouse button";
}
this.onMouseUp = function(){
mouse_actions.text="";
}
}

View Replies !    View Related
I've Got To Be Missing Something
I'm new to flash and just trying to make a url link. followed instructions and I keep getting an error" '{' expected " in line 5. It's there!!! It seems right to me. Am I missing something. it seems simple.

1.var link:URLRequest = new URLRequest("

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved