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




Defining Variables



I know this is kind of a dumb question, but I need help anyway. I'm trying to call a global variable from a movie clip. In my main timeline I have declared a variable called "scene". In my movie clip I want to check the value of "scene".
Here is the main timeline code:

scene = "vehiclereg";

Here is the movieclip code:

if (scene == "vehiclereg") {
nextFrame ();
} else {
prevFrame ();
}

I've messed around with trying _root.scene and other scope stuff, but I can't get it to work. The movie clip just sits there. Well, any help would be appreciated.

Thanks!



FlashKit > Flash Help > Flash ActionScript
Posted on: 02-11-2002, 10:00 PM


View Complete Forum Thread with Replies

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

Help W/ Defining Variables
im kind of new with this flash stuff and this is was made as more of a learning thing for me and im kind of having a problem w/ getting a variable from a mc to my main variables, is there something that i have to do w/ _root, if you want to see what im talking about because i usualy confuse everybody, go to www.dark-studios.com/crosshairgame.swf

when you click on the target, it adds 1 to the variable hit, and after adding 1, it says to refresh the dynamic text telling you how many hits you have, and its there where im having problems, please tell me what im doing wrong

A Little Help Defining My Variables?
I have created a couple hundred SWFs that I am trying to access through a bookmark (via a cookie). I have the main swf file successfully reading the cookie, and going to the map page if there is no cookie, but I am having trouble getting the enter button (below) to read the cookie string to load the bookmarked swf. I know I have something screwed up in my "else" statement, but can't figure it out.

on (press) {
getURL ("javascript:document.PR101.SetVariable('_level0.t xtReadCookie',(document.cookie) ? document.cookie : '');");
}
on (release) {
if (_level0.txtReadCookie eq "") {
loadMovieNum ("map.swf", 0);
} else {
var pageToLoad = "_level0.txtReadCookie";
// pageToLoad = bkmk();
loadMovieNum = ("pageToLoad" + ".swf", 0);
}
}

Defining Variables In A Component
i'm using the scroll menu smart clip from macromedia extentions. and i was wondering if there is a way to give each item in the list it's own variable? I'm using it to create an order form with 2 different types of products, soda and beer. right now i have it to hwere when someone selects an item from the menu, puts in an ammount, and presses add, it the item and the ammount in a list for review. I want it to where it sends beer to one list and soda to another. is this possible? and if so, how? please understand that i'm somewhat a noob to actionscript and i'm learning quickly, but if you can break it down for me, i would appreciate it. thanx in advance


Shaggy

Defining Variables From An XML File.....
Hi There,

I am currently stating each and every variable I retrieve via an xml document, like the following:

_root.questionT = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
_root.answerA= xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
_root.answerB = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
_root.answerC = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;

Is there anyway to automate this so it simply reads in the name of the surrounding text?

<frontText>Welcome to our website</frontText>

So it would know that this variable was frontText without me specifying it? Is that possible?

Help Defining Dynamic Variables And MCs In AS3
I'm a designer having some difficulty making the switch to AS3 from Flash 8 so any help would be appreciated!

I'm getting undefined property errors in my code. Could someone explain how I could convert this code to be AS3 compliant? It works fine in Flash 8.


Code:
for (var i:Number=1; i<=6; i++) {
this["posX"+i] = this["pic"+i]._x;
}


In the example I'm cycling through a FOR loop to create 6 variables (posX1, posX2, etc.) whose value is equal to the _x position of 6 MCs on the stage named pic1, pic2, pic3 etc.)

so...

this["posX"+i] is a dynamic variable.
this["pic"+i] is a MC instance.

If it helps to know, the MCs are physically on the stage with instance names. They are not being created with AS. The code is on the timeline, so I'd prefer not to use an external .as class. Thanks!

Defining Variables From Within A Loop
is this possible?
in a subclass i need to define a bunch of variables like:

public var pos0:Point = new Point();
public var pos1:Point = new Point();

and so on.

the amount of vars is determined by a constant from an external source

what is the correct syntax to define those vars in a loop?
here is some bogus code

Code:
for (var i =0;i<POSITIONS;i++){
public var "pos"+i:Point = new Point();
};
this surely does not work...
any help ?

thanks!

Defining Variables In HTML
DEFINING VARIABLES IN HTML

Hi All,

I'm working for the first time using named anchors, due to a client request. Ok, the named anchors really work fine but...depending on a certain variable, my location_mc will display the proper frame, but the anchor just send the user to the correct frame, but w/ undefined variable...

I tryed to use query string but no succes...Can anyone here point me in the right direction?

Defining Variables Dynamically?
Is there a way to pass a variable to a movie clip dynamically ? Otherwise, I'll have to declare each variable separately inside every movie clip... It's not much of a work but it would really be great if I could simply pass that variable to every movie clip with the help of a loop.

Any feedback is appreciated.

Defining Global Variables
Hi everyone:


I'm trying to better understand the AS 3.0 and how it's done by professionals. I'm coming from the C/C++ world and the AS language and the Adobe Flash development environment seems very abridged.

I have several external classes in .AS files that I'm planning to use in my project and I'm wondering is there any way to define global variables that will be available throughout all of the AS files in the project?

Defining And Using Class Variables
OK I am using Colin Moock' Flash 5 Actionscript book but even so ... in Flash 6 I'm not getting access to variables defined in the class constructor when trying to access from methods added using MyClass.prototype.newMethod = function () {...}; When I change them to instance variables ie this.variable then all works fine .... but what I really want in this case is one variable global to the class ... not one peculiar to each instance ... tried various wrinkles like using MyClass.variable ... but cannot understand why values are inaccessible / undefined as class variables but working fine as instance variables. OK maybe I should step up to MX 2004 to better OO Actionscript implementation ... can't afford to right now, though, and Studio MX is such a powerful set of tools!
Thanks in anticipation for any insight here!

[fmx] Issues With Defining And Using Variables
Hi,

I posted a problem recently and I think I was asking too much too soon, I apoligise for that one. I want to try again with my problem. Basically I am making an interactive circuit builder in flash mx for 8-10 year olds (does anyone remember crocodile clips?).

The file I am referring to is located at :

http://www.learningcircuits.co.uk/project/circuit.fla

it is 400k in size, which was too big for on here.

I am having major problems with my code and I want to try to tackle each problem at a time.

The problem is that I have a set of four components; a motor, bulb, buzzer and switch. When a component is dragged off the list and into the circuit it need to check for power and then function accordingly, i.e. on or off. I have achieved this however i need it so when the component is removed from the circuit it then goes off again.

I do not think I have gone the best way to go about this but if you could be kind enough to see the attachment for what I have done it would really be appreciated.

For reference draggable components are called DragBulb, DragMotor, DragBuzzer and DragSwitch

All batteries add the same amount of power regardless of their size.

The code which (should) turn the component on and off is within the movie clip instance...i.e. the DragBulb MC on the stage has two frames and on each frame is code. The first frame is a graphic of the bulb off and the second frame is a MC of the bulb on, same goes for all the components...I did it this way so I can state the variable 'Component'Power (i.e. BulbPower, MotorPower etc..) to go to different frames depending on the amount of current in the circuit from the varibing amount of batteries...if anyone with more actionscript knowledge (all of you probably) thinks there would be a better way to do this?

Many thanks for your time and help, I appreciate it very much!

Matt.

[MX] - Defining Variables In A For Loop
Greets,
Here's what I've got:

var cColor1:Color = new Color(mcBut1.mcFill);
var cColor2:Color = new Color(mcBut2.mcFill);
var cColor3:Color = new Color(mcBut3.mcFill);
var cColor4:Color = new Color(mcBut4.mcFill);
var cColor5:Color = new Color(mcBut5.mcFill);

What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?

Something like:

for (var i:Number = 1; i < 6, i++) {
var cColor+i = new Color(eval("mcBut"+i).mcFill);
}

...but which actually works. There has got to be a way!

Thanks all in advance,

Steve

Defining Variables In A Function
Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:


ActionScript Code:
//define the functionfunction attachVid(nc, ns, curVid, vidFile) {//I want the nc on the left side of this variable assignment to change to "video1", the name coming from the command calling the funtion    var nc = new NetConnection();    nc.connect(null);//I want the ns on the left side of this variable assignment to change to "videoStream1", the name coming from the command calling the funtion    var ns = new NetStream(nc);//The curVid part of the will be replaced with _root.my_mc1 (instance name of an embedded video object sitting on the stage), the name coming from the command calling the function    curVid.attachVideo(ns);    ns.connect();    //the vidFile part of this snippet is changed to "millersgap_med001.flv", the FLV name coming from the function call    ns.play(vidFile);}//call the functionattachVid("video1", "videoStream1", _root.my_mc1, "millersgap_med001.flv");


I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working. Does anyone see any problems with my code?

MovieClipLoader And Defining Variables
Basic concept... using the MovieClipLoader function to load in several images into various actionscript defined movieclips. These movie clips, with images loaded into them, are going to have onRelease functions associated with them which will load in a larger version of the image already loaded. As you can picture, there are a series of thumbnails, and each thumbnail needs to be clickable and load a larger version of itself into an empty clip. However, I can't seem to define variables inside of the MovieClipLoader object as it's not technically a movie clip?

How might I know which larger file to load when one of the thumbnails is clicked? All the files are named all sorts of things, aren't in any particular order (user defined from a drag-n-drog UI)... I thought I was on the right track, until I realized I couldn't define variables within the empty clip holding the thumbnails... bummer.

Thanks.

[fmx] Issues With Defining And Using Variables
Hi,

I posted a problem recently and I think I was asking too much too soon, I apoligise for that one. I want to try again with my problem. Basically I am making an interactive circuit builder in flash mx for 8-10 year olds (does anyone remember crocodile clips?).

The file I am referring to is located at :

http://www.learningcircuits.co.uk/project/circuit.fla

it is 400k in size, which was too big for on here.

I am having major problems with my code and I want to try to tackle each problem at a time.

The problem is that I have a set of four components; a motor, bulb, buzzer and switch. When a component is dragged off the list and into the circuit it need to check for power and then function accordingly, i.e. on or off. I have achieved this however i need it so when the component is removed from the circuit it then goes off again.

I do not think I have gone the best way to go about this but if you could be kind enough to see the attachment for what I have done it would really be appreciated.

For reference draggable components are called DragBulb, DragMotor, DragBuzzer and DragSwitch

All batteries add the same amount of power regardless of their size.

The code which (should) turn the component on and off is within the movie clip instance...i.e. the DragBulb MC on the stage has two frames and on each frame is code. The first frame is a graphic of the bulb off and the second frame is a MC of the bulb on, same goes for all the components...I did it this way so I can state the variable 'Component'Power (i.e. BulbPower, MotorPower etc..) to go to different frames depending on the amount of current in the circuit from the varibing amount of batteries...if anyone with more actionscript knowledge (all of you probably) thinks there would be a better way to do this?

Many thanks for your time and help, I appreciate it very much!

Matt.

[MX] - Defining Variables In A For Loop
Greets,
Here's what I've got:

var cColor1:Color = new Color(mcBut1.mcFill);
var cColor2:Color = new Color(mcBut2.mcFill);
var cColor3:Color = new Color(mcBut3.mcFill);
var cColor4:Color = new Color(mcBut4.mcFill);
var cColor5:Color = new Color(mcBut5.mcFill);

What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?

Something like:

for (var i:Number = 1; i < 6, i++) {
var cColor+i = new Color(eval("mcBut"+i).mcFill);
}

...but which actually works. There has got to be a way!

Thanks all in advance,

Steve

Defining Variables In A Function
Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:


ActionScript Code:
//define the functionfunction attachVid(nc, ns, curVid, vidFile) {//I want the nc on the left side of this variable assignment to change to "video1", the name coming from the command calling the funtion    var nc = new NetConnection();    nc.connect(null);//I want the ns on the left side of this variable assignment to change to "videoStream1", the name coming from the command calling the funtion    var ns = new NetStream(nc);//The curVid part of the will be replaced with _root.my_mc1 (instance name of an embedded video object sitting on the stage), the name coming from the command calling the function    curVid.attachVideo(ns);    ns.connect();    //the vidFile part of this snippet is changed to "millersgap_med001.flv", the FLV name coming from the function call    ns.play(vidFile);}//call the functionattachVid("video1", "videoStream1", _root.my_mc1, "millersgap_med001.flv");


I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working. Does anyone see any problems with my code?

Can Defining Lots Of Variables Be A Problem Of...
I don't know but the on-line store I was working on is slowing down (almost frizing) after I use it for about 1 minute. and no flash animations.

Defining Global Variables - Summary
Three ways to define a truly global variable--

1. Object.prototype.myVar = value
pros:
- you can access it from any timeline with just "myVar"

cons:
- all classes inherit from Object, so Array, MovieClip, etc. will show myVar as a property
- myVar will show up in FOR..IN loops in every object


2. MovieClip.prototype.myVar = value
pros:
- you can access it from any timeline with just "myVar"
- it affects only movieclips, not all objects (like #1)

cons:
- it's still modifying the MovieClip prototype, could conflict with something


3. Object.myVar = value
pros:
- it doesn't change the prototypes of any classes
- myVar doesn't show up in FOR..IN loops in object instances, except for Object itself -- you can use for (var p in Object) {trace(p);} to see it
- this approach can provide a protected namespace for classes and such
- Branden Hall likes it! (he's using it a lot in his upcoming ACK - Actionscript Component Kit)
- the Object object will never inherit from anything else (an advanced concern, important for ACK)

cons:
- you access it with Object.myVar - a bit more typing (but you're not that lazy, are ya?)
- myVar doesn't show up in the debugger or List Variables (this could be a pro as well)


Many thanks for Branden Hall and Samuel Wan on the Flashcoders list for explaining the third method. I know I'll be using it with my custom classes.

Defining Variables Problem (photoalbum)
Hello,
I'm trying to make a dynamic photoalbum with flashMX.
I'm getting the variables picfilename1, picfilename2, .. from PHP.
The problem is that in the 'loadmovie'-part, Flash tries to load the file "picfilename1" or "picfilename2" instead of "car.jpg" or "carandbike.jpg".
Something is wrong with the -"picfilename" add i- sentence but I don't know what. Some HELP?

picfilename1 = "car1.jpg";
picfilename2 = "carandbike.jpg";

for (i=0; i<10; i++) {
createEmptyMovieClip(("picHolder" add i), (i+1);
picfilename1 = "car.jpg";
loadMovie("picfilename" add i, "picHolder" add i, "POST");
}

Thanx in advance

[help] Defining Multiple Variables In An 'if' Statement
OK, so I'm trying to get an 'if' statement that says, on a mouse rollover, check to see if variable a, b, c, and d = a value. That's all I need. I just need to see how you nest multiple variables using an 'if' statement.


Code:
on(rollOver) {
if...
}

Defining Variables By Dynamic Text
I wanted to see if anyone had thoughts on this:
It's pretty basic to define a dynamic text by a variable, but what about the other way around?

I'm creating a SWF widget for kids who've most likely barely touched Flash (let alone AS), and want them to create a variable out of their name.

I'd like, though, to avoid having them futzing about in the actionscript editing window (since this project isn't a flash tutorial), so I've placed a line of dynamic text on the stage that says "Enter your name here" and gave it the instance name "myName".

Then in the actionscript, I've placed:
code: _global.nameX = myName.text;
In theory, all they have to do is open flash, change the name, and publish to create a SWF that generates their name as the "_global.nameX" variable.

This doesn't seem to work, though.
I know, I know, I might as well tell the kids to enter their name in the actionscript, but I thought this'd be a novel approach to user-friendliness.

Thoughts?
gyz

Defining Variables For Button Actions
Hi everybody.
I was going to ask this in another forum, but unfortunately it's offline today. I am new to AS3 and am currently trying to convert my AS2 Play&Pause button into AS3

This is what I have:


Code:
// Pause & Play
fmcontroller.btn_pause.addEventListener(MouseEvent.CLICK, onMouseClick2);
function onMouseClick2(e:MouseEvent):void
{fmcontroller.btn_pause.gotoAndStop(2)
video1.stop()
video2.stop() }


The button is a 2-frames-movieclip called btn_pause inside fmcontroller.
When the button is pressed the first time, it jumps to frame 2, which is a play symbol and stops some animations.
Here is what I want to do:

I want to define a variable "x" and use ( if & else )
=> so that the videos only stop when x = "stop"
and play when x = "play"

I though I could use another ( if & else ) to check and change the status of the variable. => At the last line buttons actions.

Would be graet if somebody could help me with this.
Tanx you and best regards
Martin.

Quick Question On Defining Variables
ok i can't beleive i'm asking this but i can't get it to work, what i want is

ActionScript Code:
_root.mybutton.onRelease = function(){
for(var  i=0; i<4; i++){
_root["somevariable"+i].something = true;
_root["somevariable"+i].somethingelse = true;
}
}
what should i do, i know you can do this with movies clips, why not variables?

Smartclips - Defining Variables With Clip Perameters
Can anyone help with this problem...???

Overview
I am creating a databased driven press release movie. You are first presented with a summary list. I have fixed the number of records to be displayed on the screen at any one time to 5. Each row is a seperate movie clip containing 3 dynamic input fields and a button to display the detail.

e.g.
Row1 (instance name)
ID1 Title1 Date1 Summary1 (dynamic input field vars)

Row2 (instance name)
ID2 Title2 Date2 Summary2 (dynamic input field vars)

Problem
I want to modulise this movie to make it easy to bolt onto future projects. I was hoping to be able to create each Row MC from a SmartClip. The idea is you drop say 5 of these SmartClip Rows onto the stage and set the Dynamic Input Field variable names within the SmartClip from the clip perameters.

Any ideas, i am new to smartclips and cant find a worthy resource.

Thanxs in advance,
Kris e' boy...

Javascript And Flash (defining Variables Properly)
OK, I'm curious if from flash can you call client side JavaScript functions that exist outside the flash?

I'm trying to get something to work (there's another post about it on here) but when I click the submit button, it doesn't seem to be trying to call the javascript function with the information I have the flash module collecting... any ideas/help?





























Edited: 02/08/2007 at 12:23:00 PM by Online_in_Oregon

Defining Variables For Buttons For Next Movie To Load
Hi!

I´m planning to make a magazine in Flash, and I would have to load several pages of it in order. But I´d like to put the buttons forward and previous on the main movie and make then load each page in a container.

Is there a way to set variables for each page so the main movie "knows" what movie is loaded at the moment and what page it has to load next.

Defining Variables/actions In External Movies
Hey everybody,

I have a question about movies loaded to the main movie via loadMovieNum.

1. I have a movie, called "index.swf", another movie called "main.swf", and another movie called "about.swf"

2. On the only frame in "index.swf" I have the code


Quote:




loadMovieNum("main.swf",1)




3. On a specified frame in "main.swf" I have the code

[quote]
loadMovieNum("about.swf",2)

4. In the movie "main.swf" I have a button with this code


Quote:




on(press){
//to unload movie "about.swf"
unloadMovieNum(2);
//to continue to the next frame of "main.swf"
gotoAndPlay(19);
//code related to "main.swf"
var skip2:Boolean = new Boolean();
skip2=true;
}




5. I do not want "about.swf" to simply unload and disappear though. I would like for the button in "main.swf" to be able to create a Boolean value within "about.swf" and tell it to play the next frame and finish playing the movie to the end before unloading the movie. With the parts I don't know actionscript syntax for, the English translation of the code might look like what is between the *english* tags:


Quote:




on(press){
*english* Create Boolean variable in current frame of "about.swf";
play next frame of "about.swf";
only when "about.swf" is complete (has reached its final frame) then do next
line of code on this button;*english*
unloadMovieNum(2);

gotoAndPlay(19);

var skip2:Boolean = new Boolean();
skip2=true;
}




I hope the idea of the *english* tags help and don't confuse. Thanks for reading! I'm a complete amateur at this, but I'm not just copying code to do something. I'm learning how to apply this code in multiple ways, so I hope no one finds me annoying. This forum is great.

Defining/Re-defining Variable Value Based On Button Press?
I've got 50 buttons, each with an instance name of Example_1 thru Example_50.
I have a variable x whose value I would like to redefine based on the button pressed; i.e. Example_1 pressed, x = 1, Example_2 pressed x = 2, and so on.

Is there a way to do this that is more graceful than a button action for each button instance?

Thanks

Help Defining Function
I am tring to build a navigation system, that when the user rolls over a certain MC, the MC will rollout to a predetermined position along the x axis. I believe the best way to accomplish this would be by creating a function that when the user passes over the MC, it slides out. I am pretty sure I'll have to use the slide algorithm to create the sliding/"rolling out" effect.

However, I am puzzled on how to accomplish this effect. Any help would be greatly appreciated. thanks.

ryan

Defining Coordinates
hi,
I have a rectangle and a circle drawn in it. Then I have a draggable movie clip in the rectangle.
My problem is, I want the movie clip to move inside the rectangle (given the constrain to rectangle option) but not enter the circle.
What script do I define for the movie clip to drag upto a maximum of some coordinates(the rectangle) and not go below some minimum coordinates(not enter the circle).

Thanxz.

Defining A Grid
Can anyone explain to me how I'm supposed to define a grid? Like, if i wanted to make a chess game.

I looked at some source, and realize I can create rows and coulms using two arrays with For loops, but how do I define the position of each row/column/cell using x-y coordinates so that a piece on the grid can be moved to specific square?

Thanks.
CountBule

Defining Functions
How do I define a function in flash 5, and how do i call it when i need it ie. on(press)?

Thanx!

Pre-defining MX Privilages
Hey, is there anyway of doing this?

You know if you load up an .swf and it asks you if you want to give it access to your microphone; how much space it can take up etc - is there a way of pre-defining it so it never prompts you?

Defining Functions
so apparently there's 2 ways of defining functions

function myFunction(args){
}

OR

myFunction = function(args){
};

What's the difference?

How come the first one returns [function, myFunction] in the outputWindow and the second one returns just [function]?

Why can't I call the second one with a setInterval but I can call it directly?

Defining Positions...
Hi there,

I've made a 'navigation' using this scripting, which I've got from the forum a couple of months ago... .

the file I'm talking about is available at

www.woowoos.com/vccc/damn.zip (7.04Mb)


what I need to do, is to make sure that once you click a name of someone, flash redirects the big movieclip to put that person in the middle of the stage... .

Is that possible with this script?


greetings

robin

Defining Boundaries
Hi,
I have a ball (as a MC) with a Stop action on frame 1.
Frame 2 has the following:

if (_y<0) {
_y = 0;
if (_rotation>=0) {
_rotation = 180-_rotation;
} else {
_rotation = -(180+_rotation);
}
} else if (_y>600) {
_y = 600;
if (_rotation>=0) {
_rotation = -(180+_rotation);
} else {
_rotation = 180-_rotation;
}
}
if (_x<0) {
_x = 0;
_rotation = -_rotation;
} else if (_x>800) {
_x = 800;
_rotation = -_rotation;
}
_y -= Math.cos(0.01745*_rotation)*speed;
_x += Math.sin(0.01745*_rotation)*speed;
if (speed>0.1) {
speed -= 0.1;
} else {
speed = 0;
prevFrame();
}

Frame 3 just has:
prevFrame();
play();

The ball basically bounces off the 4 walls of my 800x600 movie when activated. But how do i define another smaller set of boundaries within my movie (see diagram)so ball will bounce in this smaller section as well?
I thought about using hittest on an invisible area so when ball enters this area it changes the boundaries to the smaller section i need? is this right or is there an easier way?? help!

cheers
geoff

Defining And Using Objects
I'm making a game and I've decided the best way to do it is to make my own objects. I'm just not sure how I would do this. What I want to do is make a function so that I create a new enemy object that has a certain amount of health or something (would that be called a class?). Heres what I think i have to do, just tell me what I have to change.
I put this in the first frame of my movie, all of the other code is in frames, not in movieclips.
function Guy() {
health = 1;
ammo = 10;
moveSpeed = 20;
}
I know about parameters and stuff so I know how to set health to a variable. But I dont know how to set a movie clip to this object. Do I do it within the method or after i declare the object? I'm guessing that you attach a movieclip to the object like this
Frank = new Guy();
Frank.attachMovie("badguy", "badguy" + i, i);
I tried that though and it didn't work out too well. Do i have the right idea? I just need to know where to put stuff.

Defining A Variable In MX
I would like to define the data in a dynamic text box named score as a variable, but I'm not really sure of the syntax.
thanks.

Defining OnRelease Twice?
Can i add an onRelease function to a button that has already has an onRelease function defined elsewhere in the script ?

My 5 buttons were created and defined from within a for loop. The buttons animate on a onRelease function within this loop. So thats all fine and dandy, i have a navigation bar that kinda works, but now i want to add content with attachMovie for each button without adding more script to my for loop.

G

Defining A Variable. HELP...
Hey all,

I've got several nested thumbnail pics which are buttons, that when pressed, need to go into a another nested symbol, play the first ten frames, and then, depending on which thumb was pressed, go to a specific frame label.

I'm trying to define a variable on each button that's activated when pressed so it will remember and then go to the right label.

this is on the first btn;

on(press){
vendor="baileyStreet"
_root.homeDecor.gotoAndPlay("intro");
}

and then once it's played the ten frame intro I need it to jump to a specific frame in that same symbol by acknowledging the defined variable and going there.

this is on the last frame after the intro;

stop();

gotoAndPlay(vendor);


I'm doing something wrong because it's just sits on the 10th frame and doesn't go anywhere. I need some help!

thanks...

Defining A Variable... HELP... (again)
I've got several nested thumbnail pics which are buttons, that when pressed, need to go into a another nested symbol, play the first ten frames, and then, depending on which thumb was pressed, go to a specific frame label.

I'm trying to define a variable on each button that's activated when pressed so it will remember and then go to the right label.

this is on the first btn;

on(press){
vendor="baileyStreet"
_root.gotoAndPlay("home decor vendors");
}

and then once it's played the ten frame intro I need it to jump to a specific frame in that same symbol by acknowledging the defined variable and going there.

this is on the last frame after the intro;


gotoAndPlay(vendor);

Once a variable is defined, it's global right? Not just applicable to that nest level... It's got to be a syntax issue, but I can't figure it out. would really appreciate some enlightenment...

thanks...

Defining A Range...
Hi All,

I have a problem. My movie width is 500 pixels, I need this size to represent x size and be able to define the x size so that I can move a line along that line by a user being able to specify a value (x) in a input box.

This is a GPS app, basically I have a city center, the lat and long values have a range of 1500, but my movie is only 500 wide (and 500 high), when I get the lat and long values I need to move 2 lines along the X and Y values to show your location. If you took this example the movement of this would have to be 500/1500 = 0.33 . Does Flash support the ability to move a line by ultra small decimals? (I noticed it rounds decimals up to 1 decimal place)

I hope you understand what I mean.

Cheers

Carl Bruiners

Defining Loadedmc
I have a collection of buttons in a external swf. Each of the buttons has


Code:
on (release) {
_root.centre.boxmc.target_xscale = 675;
_root.centre.boxmc.target_yscale = 445;
_root.centre2.loadMovie"one.swf";


....."two.swf, three.swf etc etc


This works fine, however if i press the button that has the relevant loaded swf, if reloads it. Is there some script that i can add to the button that when pressed, itll check which swf is loaded and if the swf is the same as the pressed button action itll just ignore it and NOT reload the same movie..?

....i hope this makes sence...thanks in advance for your help...i feel like i want to cry!

Defining An Instance Name If 1 In Cs3?
Hi all

Ok I was using this script to create a menu system, Now I am using cs3 I am having some problems with instance names.

Code here: .swf attached below:


PHP Code:



numOfMenu = 4;
defaultY = 40;
max = new Array(80, 80, 80, 80);


for (i = 1; i <= numOfMenu; i++)
{
    this[i].defaultY = this[i]._y;
    this[i].bg.onPress = function ()
    {
        _global.over = this._parent._name;
    };
  
   
    this[i].bg._height = defaultY;
    if (i != 1)
    {
        this[i]._y = this[i - 1].bg._height + this[i - 1]._y;
    } // end if
    this[i].onEnterFrame = function ()
    {
        if (over == this._name)
        {
            this.direction = "next";
            this.nextFrame();
        }
        else
        {
            this.direction = "prev";
            this.prevFrame();
        } // end else if
        if (this._name > over)
        {
            this._y = this._y + (this.defaultY + max[over - 1] - this._y) / 4;
        }
        else
        {
            this._y = this._y + (this.defaultY - this._y) / 4;
        } // end else if
    };
} // end of for




The 4 movie clips on stage have the instances of 1, 2, 3, 4 but with cs3 I am unable to name a new mc instance of 5, 6 ecetera... How would I go about fixing this.?

Defining Functions...
Is there a way to define global functions outside of frames? Let me try to explain...

I have a script I want to write and let's say I want to pass in an argument into a function from the actionscript in frame 3 into a function. Is there a way I can make a function that I can call on it outside of the frame?

I'm trying to get a bunch of already defined variables that are defined in one frame and access them in another frame without having to rewrite all the code... or is it already possible to do this with nothing special to define?

Does any of my questions make sense?

Basically I'm altering a bitmap with alpha pixels in certain places ("erasing" it). But after I erase a little it takes you to another frame via gotoAndPlay and shows an entirely different subject matter, BUT I want to come back to the previous frame with the altered bitmap and I need it to stay updated or be able to define a function to store the altered bitmap and return to it when I come back to the frame.

Defining A Var In Actionscript
Ok Im very used to php, and Im trying to accomplish something in actionscript... heres what im trying to do

I have a line in my actionscript that goes like this:
loadVariables("http://www.blahblah.com/member/stats/charts/nutrition/npg.php?username=Mike", _root);

What I wanna be able to do is have the username instead of = Mike, to equal whatever it was given to it via URL embedding.

So If I embed the flash into a website using these tags:
<embed
src="http://www.mymuscle.com/member/stats/charts/nutrition/nsnew.swf?username=Mike"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="305" wmode="transparent"></embed>

That it would recognize Mike in the URL and put it in the actionscript

Please Please help me, Ive tried everything!!!!

Defining 'e.' Or 'event.'
Well, here's the simple, incomplete code I'm working with. I simply want to make a character (hero) move and animate when the left key is pressed. However, I can't determine whether the following script works:

ActionScript Code:
package{                                               
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.display.MovieClip;

    public class character_movement extends MovieClip{     

    private var walkspeed:int = 4;
    public var left:Boolean;
    public var right:Boolean;
    private var walking:Boolean;
   
    function character_movement(){
        stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
        walking = false;
        }
    private function keyDownHandler():void{
        if (event.keyCode == 37){
            if (walking == false){
                walking = true;
                hero.gotoAndStop('walk');
                hero.scaleX -= .5;
                hero.x -= walkspeed;
                left = true;
            }
            }
    }
    }
}

The problem currently is the line
ActionScript Code:
if (event.keyCode == 37){
which returns an error 1121: access of udefined property event.

But I see this "event." or "e." in everyone's tutorial. What am I doing wrong?

Defining Hit Area
i have a movieclip on which i have the following code

ActionScript Code:
onClipEvent (enterFrame) {
 if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
 this.nextFrame();
 } else {
 gotoAndPlay(1);
 }
}
when the mouse rolls over any part of the movieclip it plays

can i make it so only when it rolls over a certain graphic in the movieclip it plays?

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