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








Variables/functions "pushed" To Level0 On LoadMovie


I posted this in the Flash8 forum, but I guess this is the right forum for this question:

Hey guys!
I'm trying to get an interface that will load external MCs that contain timeline control functions in them. Basically these are long "topics" that currently interface through a web content program - I would like to unify them into a single flash-based interface, but the functions that are in the external flash files, such as this:

dwnLine = function () {
totalBytes = getBytesTotal();
loadedBytes = getBytesLoaded();
percentDone = (loadedBytes/totalBytes)*100;
percentDoneRd = Math.round(percentDone);
setProperty("timeline.progLine.loadLine", _xscale, percentDoneRd);
};

get pushed to level0 when you load the next MC, instead of just being deleted with the old MC. I've tried creating a function on the root timeline to delete the variable and the specific function names, but its not working, it just fights with the phantom functions endlessly creating/deleting the variables. This is turn screws up the timeline in the new MC that was loaded. Does anyone know why/what Flash is doing here? If I knew the reason it was being pushed up to level0 I could stop it, but I'm a bit lost. Thanks, lemme know if you need more info or a sample to answer!
-Anthony

PS: I'm using a simple

on (release) {
loadMovie ("Loader1.swf", "/contentclip");
}

to load the new MCs into a container MC called "contentclip"




KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 10-30-2006, 03:41 PM


View Complete Forum Thread with Replies

Sponsored Links:

[F8] Have Sounds Play When A BTN Is Pushed, But Stop When Another Is Pushed
I am programming another touch screen computer. The movie will have pictures of a bunch of animals and when the animals is touched a sound will play, some are 30 seconds long.

What I would like to do is have the first sound stop when the second one pressed.

Right now I have the buttons for the sounds and the button to go back a page beside each other. When someone presses the sound button the sound plays, but while the sound is playing, if the person presses the back button, the screen changes, but the sound keeps playing until the clip is done. I won't the sound to quit when the back button is pushed.

Right now I have my sounds as part of the down frame in the button. Would this be easier to accomplish if I made the buttons movie clips?

Kyle

View Replies !    View Related
Loading Variables To Level0 And Use On Level2
Anybody know how to have variables from an external script (.php) load into a base movie (located on _level0) and be able to use that same variable on a level2 movie (brought in of course through an "createEmptyMovieClip")?

I'm using a script from the actionscript.org library (CLOCK AND DATE SET BY SEVER (GMT) TIMESTAMP, PHP). The php portion of it has the original call to the GMTtimer.swf file with a "?timestamp=<? php $timestamp ?> added to it. That works fine, but if I have another movie call this GMTtimer.swf movie and change the movie the .php references it won't work.

Any ideas for a work-around?

View Replies !    View Related
Passing Variables Between Loaded Movies With Both Of Them On Level0
I have two movies, moviepart1 and moviepart2. when moviepart1 gets done playing and the user clicks on the "next" button it loads moviepart2 onto level0. I need to be able to have a back button on the first scene of moviepart2 to take the user to the last scene of moviepart1. Here is the actionscripting I am using:

This is on the back button on moviepart2:

Code:
on (release) {
jump=1;
loadMovieNum ("moviepart1.swf", 0, "GET");
}
and I have a wait scene at the beginning of moviepart1 to use a conditional to figure out if that variable has been sent or not. hereis that conditional:

Code:
if (_level0.jump == 1) {
gotoAndPlay ("scene3", 1);
} else {
gotoAndPlay ("scene1", 1);
}
I hope that this is enough information to get some help and I would greatly appreciate any help.

Thanks,
Justin
[Edited by therealsyko on 12-18-2001 at 11:20 AM]

View Replies !    View Related
Can Php Send Variables To A Flash File That Is Not On Level0?
I have a flash movie that is on a level other than 0, and was wondering if variables can be passed from php to that specific flash file?

View Replies !    View Related
Loader, Passing Variables, Level0, ContentPath
I'm new to Flash, but old to programming. Can anyone help with this problem:

http://whyflashsucks.blogspot.com/20....html#comments

I'm really being driven nuts by this....

Thanks!!

View Replies !    View Related
Level1 Swf Over Level0, Buttons From Level0 Swf Still Active Under Level1 Graphic
I've got a main swf with buttons in it, that loads another file over it (level1). The buttons in the first layer are still active under any graphic or movie clip in the layer above it. Is there anything I can do to the graphic or the swf so that the buttons in layer0 are inactive (or just won't show the pointer graphic)?

Sorry for my lack of proper terminology...........

View Replies !    View Related
Class Functions Not Able To See Other Member Functions/variables?
I am having a problem which has crept up on me a few times now. I am trying to call another member function within the same class, but Flash is unable to recognize it. This also happens when I try to read values of come variables.

For example, here I am trying to set the private boolean member variable to the state of the checkbox.

//NOTE: This is an EventListener. Does this change something major?

private function CheckBoxClick( evt )
{
_enabled = _root["test_sp"].content[_checkBoxName].selected;
trace( _checkBoxName + " checked: " + _root["test_sp"].content[_checkBoxName]._y );
}

This will output the following: "undefined checked: undefined"

Now in the function directly above it, I have the following function:

public function SetYPosition(pos:Number)
{
trace( _checkBoxName );
_root["test_sp"].content[_checkBoxName]._y = pos;
}

And this function will correctly output the checkbox name as well as update the position.

If I try adding the function call "SetYPosition(500);" to the first function (CheckBoxClick), the function will never be called as if Flash cannot see it.

In the past I have avoided this by using the global instance of the class such as _global.settings.function(blah), but the class I am working on now does not have a global instance.

Any ideas? This is really annoying!

Thanks!!!































Edited: 06/27/2007 at 03:30:12 PM by JoMasta

View Replies !    View Related
LoadMovie And Functions
Is there any way to use .swf movies with Loadmovie, and still have their User Defined Functions accesible from other Loaded SWFs? instead of having to keep all the movies with functions in one SWF?

View Replies !    View Related
Loadmovie, Functions As Objects, And XML
Ok, here's the deal:

I've got an swf that's the project interface. This movie loads other movies that actually do stuff. I'm stuck on the movie loading into level1. This movie works fine by itself, but breaks when I load it into the interface. After some grueling testing, I've found the problem. Using a tutorial on XML from MM, I created the following code:

MessageXML = new XML();
MessageElement = MessageXML.createElement("LOGIN");
MessageElement.attributes.sessionID = _root.sessionID;
MessageXML.appendChild(MessageElement);
MessageElement = null;
trace ("message out: " add MessageXML);
MessageReplyXML = new XML();
MessageReplyXML.onLoad = onMessageReply;
MessageXML.sendAndLoad(url, MessageReplyXML);
MessageXML = null;

The message out is being sent fine. The problem lies with the onMessageReply function:

function onMessageReply () {
trace ("new message: " + MessageReplyXML);
if (MessageReplyXML.hasChildNodes()) {
trace ("test");
mControl.run = mControl.onMessageReply;
}
}

When loaded into level1, onMessageReply executes, but it doesn't see the MessageReplyXML variable. I can specify it like this:
if (_level1.MessageReplyXML.hasChildNodes()) {
trace ("test");
_level1.mControl.run = _level1.mControl.onMessageReply;
}

But then I can't run it on its own. I tried using _root instead of _level1, but it still doesn't work. Has anyone had any problems like this? Any help is GREATLY appreciated.

View Replies !    View Related
Working With Loadmovie Functions
I have a problem with loading external movies in Flash. For example. When I click the homepage link, it will load properly, but when I click another link, it loads other other movie over it. I put unload actions to the previous movie but it doesn' disappear when its supposed to. Can somebody check the source file and help? Thanks.

*Please note that I only configured the first three links to work...
Home, portfolio, and projects...

Because size is an issue on Flashkit, the file is located here
http://www.dabandits.com/site.zip

View Replies !    View Related
Working With Loadmovie Functions
I have a problem with loading external movies in Flash. For example. When I click the homepage link, it will load properly, but when I click another link, it loads other other movie over it. I put unload actions to the previous movie but it doesn' disappear when its supposed to. Can somebody check the source file and help? Thanks.

*Please note that I only configured the first three links to work...
Home, portfolio, and projects...

Because size is an issue on Flashkit, the file is located here
http://www.dabandits.com/site.zip

View Replies !    View Related
LoadMovie Messing Up Functions
The preloader and the page I want to load are both in the same .fla. Loader on frame 1 and page being loaded on frame 2. Now this .swf file loads and functions properly. Here is the code I use in frame 1 of the preloader:

preloadtext.onEnterFrame = function () {
loaded = this._parent.getBytesLoaded ();
total = this._parent.getBytesTotal ();
percent = ((loaded / total) * 100);
trace ("Percent: " + percent);
percentage = (int (percent) + "%");
preloadtext.percent_txt.text = percentage;
mxbox.gotoAndPlay((20*(percent/100)));
if (percent == 100) {
gotoAndPlay (2);
}
}

However, I have a container that starts the preloader. It has a blank movie clip and this code on a seperate layer:

stop();
mc_container.loadMovie("main.swf");

When I use this .swf file to go to the page I want there are problems such as certain functions don't work (drawing lines, resizing pictures). Sometimes buttons don't even work. I really don't know what to do. Thank you.

View Replies !    View Related
LoadMovie Special Functions
How could I use loadMovie command to load an external swf file and have the external swf file's action script functional in the parent movie. If I use LoadMovie to load into an empty Movie Clip with _root, only the animation works. Thank you for your help

View Replies !    View Related
LoadMovie And OnLoad Functions
I'm trying to create a system which does a simple loadMovie function

on (release){
_root.loadMovie("rework.swf");
}

and in that movie rework I have a onLoad Function which doesn't want to run:

onLoad = function (success) {
_root.Button1Position = 1;
_root.Button2Position = 2;
_root.Button3Position = 3;
_root.Button4Position = 4;
_root.Button5Position = 5;
_root.growth_counter = 0;
_root.movement = 0;
_root.Button1.gotoAndStop(10);
_root.Button2.gotoAndStop(5);
_root.Button3.gotoAndStop(1);
_root.Button4.gotoAndStop(15);
_root.Button5.gotoAndStop(20);
_root.movement2 = 0;
};

Now this LoadFunction sets up the move so that it is running right, and when I just open it normally it runs fine, but if I open it within another Movie file, it doesn't run at all. Am I missing something?

View Replies !    View Related
Is LoadMovie AS Messing Up My Functions?
i will try to explain as best I can. I'll post my fla.

here is my .fla
www.zunskigraphics.com/showme/index.fla

In my timeline i have 8 buttons

Each button has an instance name of RWone_mc
Each button also has the AS of:

ActionScript Code:
on (release) {
    loadMovie("rw1.swf", (2));
}
NOTE:: Above is for the first button. Obviously each button has an instance name of RW"thebuttonnumber" and loads the rw'buttonnumber.swf"

I have also in the first frame of the actions layer the following AS for each button (just a simple rollover technique for _mc's to act like _btn's)

ActionScript Code:
this.RWone_mc.onRollOver = function() {
    RWone_mc.gotoAndPlay("_over");
};
this.RWone_mc.onRollOut = function() {
    RWone_mc.gotoAndPlay("_out");   
};


this.RWtwo_mc.onRollOver = function() {
    RWtwo_mc.gotoAndPlay("_over");
};
this.RWtwo_mc.onRollOut = function() {
    RWtwo_mc.gotoAndPlay("_out");
};


this.RWthree_mc.onRollOver = function() {
    RWthree_mc.gotoAndPlay("_over");
};
this.RWthree_mc.onRollOut = function() {
    RWthree_mc.gotoAndPlay("_out");
};


this.RWfour_mc.onRollOver = function() {
    RWfour_mc.gotoAndPlay("_over");
};
this.RWfour_mc.onRollOut = function() {
    RWfour_mc.gotoAndPlay("_out");
};


this.RWfive_mc.onRollOver = function() {
    RWfive_mc.gotoAndPlay("_over");
};
this.RWfive_mc.onRollOut = function() {
    RWfive_mc.gotoAndPlay("_out");
};


this.Rsix_mc.onRollOver = function() {
    RWsix_mc.gotoAndPlay("_over");
};
this.RWsix_mc.onRollOut = function() {
    RWsix_mc.gotoAndPlay("_out");
};


this.RWseven_mc.onRollOver = function() {
    RWseven_mc.gotoAndPlay("_over");
};


this.RWseven_mc.onRollOut = function() {
    RWseven_mc.gotoAndPlay("_out");
};


this.RWeight_mc.onRollOver = function() {
    RWeight_mc.gotoAndPlay("_over");
};
this.RWeight_mc.onRollOut = function() {
    RWeight_mc.gotoAndPlay("_out");
};

In the actions layer about 20 frames later, I call for a movie in another spot with this AS

ActionScript Code:
loadMovie("soundon.swf" , (4));

Now, what I am having trouble with is the rollOver status of each movieclip. It worked fine before I did the AS for the soundon button. Is this due to the way I call it? loadMovie vs. loadMovieNum ???

I don't get it!!!
Please Help!!!

see the example here

www.zunskigraphics.com/showme/index.swf

Thanks!!
ZG

View Replies !    View Related
LoadMovie Callback Functions?
I'm building a modular flash shell for a client and it loads all of the content from external sources, particularly the swf files for content. If the specified file does not exist I would like it to load an internal file instead, but I can't find any sort of callback to the loadMovie method. Do anyone know a way of checking whether a loadMovie call failed or succeeded?

Cookies for all who answer.

View Replies !    View Related
_root.loadMovie And _global Functions
If I load a new swf into the root with _root.loadMovie my _global functions and variables should still be there shouldn't they?

I would have thought so but it doesn't seem to be the case.

Thanks for amy help.

View Replies !    View Related
Why Does LoadMovie Push Functions To _root?
I posted this over at Kirupa, but didn't find an answer. Basically I want to know why Flash, when loading external swf's that contain looping functions(such as for a timeline, or anything constantly updated), the second swf loaded seems to push the functions from the first to the _root level. I'll attach a zip with example files, but let me explain more first:

I have my main flash file that has 2 buttons and a container MC named "contentclip". The first button has this code:

on (release) {
contentclip.loadMovie("Loader1.swf", "contentclip");
}

and the second, this code:

on (release) {
contentclip.loadMovie("Loader2.swf", "contentclip");
}


Now, say I have the two external flash files named Loader1.swf and Loader2.swf. One has the following function:

fruitbowl = function() {
apples = "36"
}
setInterval(fruitbowl,20)

and the second has no function at all.

What happens is that when I click on the first button, things load normally. If I click it again, OR if I click on the second button, the variable "apples" gets pushed to level0 (_root). Why? Thanks so much guys, I'm trying hard to figure this one out, but its stumping me.

Here's the file: http://www.netonup.com/echelon/FlashCourse.zip

View Replies !    View Related
Setting Properties And Calling Functions After Loadmovie
I have a series of external .swf files that I want to load into a container movieclip on my top level timeline using Flash MX and AS1. I'm quite happy doing this using loadmovie and checking getBytesLoaded and getBytesTotal to determine when it's loaded using a setInterval function.

What I would like are some suggestions to solve the following problems:

1. I have a number of top level timeline defined variables that I would like to use to create custom properties on the container movieclip into which I am loading the external .swf files. I'd rather not write code in each external .swf to access these directly from the _parent timeline because I may change the relative location of these variables at some point in the future. I would also prefer not to use the _global namespace either as it is too difficult to manage effectively. My preferred approach would be to write some code on the top level timeline to assign the properties to the container movieclip at an appropriate time for the external .swf access in frame 1. One approach I have tried is adding a query string to the end of the loadmovie URL but this has the problem that it doesn't work when running the movie through the standalone Flash player which will impact our development turnaround. Are there any other techniques which will allow me to create the timeline variables in the container movieclip before the code in frame 1 is executed?

2. The external .swf files that I am loading are single frame movies and have a number of timeline functions defined in them in the first frame that I would like to call from the top level timeline. As far as I understand it these functions are not defined until the playhead of the movieclip's time line has passed through the first frame once.
One approach I have tried is to check if the functions are defined before I call them. This works but is not a generic solution since the external movies have a range of different functions with no common functions between them all. Again I'd rather not write any code in the external .swf files that ties them into the environment into which they are being loaded in case this changes in the future.
Another solution that I have tried is adding this code to the top level timeline:
MovieClip.prototype.onEnterFrame = function() {
this.onEnterFrame = null;
this.movieLoaded = true;
};
and then checking for the movieLoaded property on the container movieclip in a setInterval function prior to calling the functions. As I understand it the prototype defined onEnterFrame function is executed as the playhead enters frame 1 and is then set to null. When the movieLoaded property is true I can be sure that the playhead has passed through the 1st frame at least once. Any onEnterFrame functions defined in frame 1 are not affected by this code as their definition happens during frame 1 and is only current on the second onEnterFrame event. This approach falls down if there is an onEnterFrame event defined in the external .swf files in a #initclip block which would be executed before frame1. In my case I know is not true but I am seeking a general solution. Any other ideas?

Thanks for your help in advance.

Martin.

View Replies !    View Related
Variables And Functions
My movie has dynamically loaded variables on the main timeline like this:
tmp1=wo
tmp2=lz
tmp3=lz
etc.

The first sides of my variables must tell where(position), and the right sides what mc.
I hoped it would work like:

//firstly, for tmp1
if (tmp1 = wo) {
this.attachMovie("womc", "womcnew", 0);
womcnew._x = 137;
womcnew._y = 23;
}
if (tmp1 = lz) {
this.attachMovie("lzmc", "lzmcnew", 0);
lzmcnew._x = 137;
lzmcnew._y = 23;
}
//etc.

//and then for tmp2 and so on

if (tmp2 = wo) {
this.attachMovie("womc", "womcnew", 0);
womcnew._x = 42;
womcnew._y = 160;
}
if (tmp2 = lz) {
this.attachMovie("lzmc", "lzmcnew", 0);
lzmcnew._x = 42;
lzmcnew._y = 160;
}

How would it be reasonable to do this? How can I use variables to tell movie what to do?

View Replies !    View Related
Ug Variables In Functions... HELP
Here's an example of the problem I'm having:



Code:
function foo(alpha, beta, gamma)
{
...
x = alpha;
y = beta;
z = gamma;
...
trace(x);
trace(y);
trace(z);
...
}


the only thing the trace will show is the x. I cannot, in any way, figure out how to find the values of beta and gamma. It's like they don't exist.

This is in Flash 5.

Any ideas?

FrankenMoro

View Replies !    View Related
PHP Variables And Functions
I know you guys get this one alot but my script is alittle different than the examples.

Have this php file:
<?php
$page = str_replace("php","html",$SCRIPT_URL);
include("folder/$page");
?>
This script should load the name of the file (flash.php) and then go get the content in another folder (folder/flash.html).
How do I run this script in flash?

~JRS

View Replies !    View Related
Using Variables In Functions...
function createAboutSubMenu(_old,_new,_Slevel,_endX,_txtNam e,_txtVal) {
duplicateMovieClip(_old,_new,_Slevel);
this[_new]._x = -300;
this[_new]._y = 140.6;

tweenBallX(this[_new]._x,this[_new],_endX);

this[_new].createTextField(_txtName,51,0,0,121,18);
this[_new]._txtName.text = _txtVal;
this[_new]._txtName.setTextFormat(my_fmt);
}

//the createTextField part doesn't work, _txtName is a variable, what could be hte problem here?

View Replies !    View Related
Variables In Functions
how do you get a var to work inside a function? if not is there a simple alternative?


this is what i have & the mc instance (graf) is not moving to the correct location, it worked before i grouped it as a function, any help?


Code:
var TopTween:Number = Stage.height /2-300;
var LeftTween:Number = Stage.width /2-350;

function grafselect() {
graf.tween("_x", LeftTween, 5, MyType);
graf.tween("_y", TopTween, 3, MyType);
}

View Replies !    View Related
Using Variables Outside Of Functions
How do I use variables that are used in functions globally throughout the Flash file?

View Replies !    View Related
Variables Outside Functions
I have a question, regarding how to make a variable inside afunction be recognized by another function... for example say I want to make the variable t increment itself by one every second, and then be recognized outside that function...
SetInterval(function (){t+=1; return (t):},1000);

someother function (){trace(t);}

of course that doesn´t work, it says undefined
or even just a trace(t); that is not inisde a function, will only trace the inital value of t... help, please!

Another question, is there anyother way of making a variable increment, without using the onEnterFrame or the SEtInterval?

View Replies !    View Related
Functions And Variables?
i have a set of named functions in numerical order, named load1(), load2(), load3(), load 4(), and so on that carry out some actions based on the release event of their corresponding numbered buttons (ie pressing "button 1" executes the load1() function).

i also have a "previous" button and a "next" button that i would like to use as a means of calling either the preceeding or subsequent function, (relative to the user's 'current' numeric position in the button sequence.) so in other words, if the user was viewing page 8, which was loaded by the named function load8(), and the "next" button was pressed, i'd like for the load9() function to be called dynamically and executed.

what i'm stuck on is figuring out how to feed my named functions loadPrev() and loadNext() a number that's essentially going to change everytime a new page is loaded. i created a variable "currentload" to keep track of what function number is currently loaded. What i'd like to know is if there's any way i can introduce that variable into the prev/next functions so that i can consistently execute the matching function number that corresponds to the value of "currentload"

here is what the function definitions look like, essentially:

function load 1,2,3,4, whatever() {
loadMovie("art_1.jpg", "_parent.imagebox");
loadMovie("BTNS-art1.swf", "_parent.buttonbox");
loadVariables("TXT-art1a.txt", "_parent.infobox");
currentload = 1
}

function loadPrev(){
currentload = currentload - 1
newload = currentload
fnc["load" + newload]()
}

function loadNext(){
currentload = currentload + 1
newload = currentload
fnc["load" + newload]()
}

where the parts in red are obviously problematic. basically that's where i would execute whatever function number resulted from the new value of "currentload".

here is the bit of handling code:

btn1.onRelease = load1
btn2.onRelease = load2
btn3.onRelease = load3
btn4.onRelease = load4
(etc...)
btnPrev.onRelease = loadPrev
btnNext.onRelease = loadNext

it seems that this should be a fairly straightforward thing. i'm still a bit of a newbie with actionscript and so i'm not quite sure if how i'm going about this is even sound. any help would be greatly appreciated.

-victor

View Replies !    View Related
Variables And Functions
hi
ive looked through lots of flash tutorial websites and LOTS of them use variables and functions but i dont understand what they do, how to use them, or why to use them.
if someone could run me through this that would be great

View Replies !    View Related
Functions - Variables
Note: Newbie

Whats the difference between a variable and a function?
Ive started reading an actionscript book.....and to me it seems there the same.

pls help,

View Replies !    View Related
Functions - Variables
Note: Newbie

Whats the difference between a variable and a function?
Ive started reading an actionscript book.....and to me it seems there the same.

pls help,

View Replies !    View Related
Mc Won't Replay When Btn Pushed More Than Once
got a movieclip playing when a button is pushed. just a few frames. If the button is pushed twice in a row, the movieclip will not replay. If you push another button then come back and push the first again...it plays from the beginning.

What am I missing? Flash 8, I'm on a mac.

View Replies !    View Related
MC's Pushed Out Of Sight
Code:
if(Stage.width >= (numOfPics*picSize))
{
setProperty(_root[rightArrow], _y, -100);
setProperty(_root[leftArrow], _y, -100);
}
else
{
setProperty(_root[rightArrow], _y, 0);
setProperty(_root[leftArrow], _y, 0);
}

while(level<=numOfPics)
{
_root.container.duplicateMovieClip(dupMovName+level, level);

currentclip = dupMovName+level;
this[currentclip].loadMovie(imageArray[(level-1)]);

setProperty(_root[currentclip], _x, (level-1)*picSize);
setProperty(_root[currentclip], _y, yposOnStage);
_root[currentclip]._alpha = 50;

level++;
}
I have a horizontal line of MC's filled with images.
When this line is bigger then the screen.width the the arrows (which are actually buttons) have to position themselves on stage (see code above), BUT...
the arrows push the line of MC's out of sight (the stage).

Why does this happen?
Is it possible to position them and not let them push the MC's down?

View Replies !    View Related
Variables, Functions, Properties
hey all...

i need a quick hand with functions, variables and properties.

essentially i have a button (A) that calls a movie clip (B) which in turn changes the properties of another movie clip (C) on the stage. right now, this is happening manually... ie, (B) has it hardcoded on a frame.

eg:
with (_root.c) {
setProperty ("_root.c", _xscale, _xscale-2);
setProperty ("_root.c", _yscale, _yscale-2);
}

what i'd like for is that button (A) pass a variable to (B) with the name of the object it would like manipulated. i can't seem to get this working. what would the action script look like for button (A) and what would the script look like for the frame in movie clip (B)?

any help on this will be godsent!

best!

View Replies !    View Related
Problem With Variables Within Functions.
Can Anyone explain why the variable "counter2"
doesn't seem to load properly the first time??
The movie must leave this frame, then re-enter it before the counter2 in the following code works correctly.

Thanks!


Code:

// START OF XML
event = new XML();
event.onLoad = xmlprocess;
event.load("events.xml");
function populateCalendar (i) {
if (event.childNodes[i].nodeName == "EVENT") {
desOut = event.childNodes[i].attributes.des;
dateOut = event.childNodes[i].attributes.date;
dateholder = new Array();
dateholder = dateOut.split("/");
eval("event"+counter) = new Array(dateholder[0], dateholder[1], dateholder[2], desOut);
counter++;
}
}
function xmlprocess (sucess) {
play();
counter2 = event.childNodes.length;
if (sucess) {
for (var i = 0; i<=event.childNodes.length; i++) {
populateCalendar(i);
}
}
}
// END OF XML
// START OF EVENT PARSING
function parsevent (init, counter2) {
for (start=0; start<=counter2; start++) {
if (year == eval("event"+(start+1))[2]) {
// Check if event is in current year
if (curmonth+1 == eval("event"+(start+1))[1]) {
// Check if event is in current month
day = eval("event"+(start+1))[0];
numday = int(day);
build = new Date(year, curmonth, 1);
init = build.getDay();
var boxpos = (numday+(init-1));
eval("e"+boxpos).gotoAndStop(2);
}
}
}
}
// END OF EVENT PARSING
// START OF CALENDAR
delete disp;
disp = new Date();
curmonther = disp.getMonth();
curyear = disp.getYear();
yearer = curyear+1900;
if (!run) {
curmonth = curmonther;
year = yearer;
monthoffset = 0;
run = true;
} else {
// Following Loop allows transfer between years
if (curmonth<0) {
year--;
curmonth = 11;
} else if (curmonth>=12) {
year++;
curmonth = 0;
monthoffset = 0;
}
}
montharray = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
monther = montharray[curmonth];
build = new Date(year, curmonth, 1);
init = build.getDay();
numdays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
leap = year%4;
if (leap == 0 && curmonth == 1) {
numdays[1] = 29;
}
end = numdays[curmonth];
boxes = new Array();
for (start=1; start<=end; start++) {
assign = (start+(init-1));
boxes[assign] = start;
}
for (start=0; start<=37; start++) {
eval("b"+start) = boxes[start];
}
play ();

View Replies !    View Related
Using Imported Variables In Functions
I want to use a value in a variable that I have loaded from a txt file into the _root of my movie.
It is called "diff"

If i manually enter a value i.e. "4" the code works fine.
But using the variable diff it does nothing.
I have tested that the variable value is there by writing it to the page in a text box.
Why won't the value be used in the function ????

// diff = my loaded var

amount = diff;
while (amount>0) {
duplicateMovieClip (_root.div, "div"+i, i);
setProperty ("div"+i, _x, random(600));
i = i+1;
amount = amount-1;
}

If i use this

amount = 4;
while (amount>0) {
duplicateMovieClip (_root.div, "div"+i, i);
setProperty ("div"+i, _x, random(600));
i = i+1;
amount = amount-1;
}

it works.

View Replies !    View Related
Passing Variables To A Functions
Hi,
this is my first post but I've gained so much help from reading other peoples post for months now and I figure if im stuck why not call for help.
Im working on a flash platformer game and im trying to use some functions to help streamline some of the processes but im having problem with using functions in flash. I wrote a function called testAhead(direct, xDist, yDist) that returns nothing but tests the distance of the movieClip that calls it to the backroung movieClip graphics. The function is supposed to give new values to xDist and yDist depending on a while loop. I know the inner part of the function works cause when i use the inner loop inside a movie clip it works. How do I get the function to assign values to the variables that i pass to it? I remember in C, (i think, i took C a long time ago) that you put '&' in front of the variables that you want to redefine within the function. I forgot what this is called. Can some one tell me if this is even possible in ActionScript?

The Shnoz
-----
http://www.audiokio.com

View Replies !    View Related
Variables And Functions In Different Levels...how To?
Hello,

i created a movie with a preloader in level 0. The main movie is loaded into level 1 and the other movies are loaded in level 2.
I have several variables and functions in level 0:
_root.window; _root.close; function fadeIn; function fadeOut, etc.

My problem is when i do something like:

MC.fadeIn(10) or if(_root.window==1) { ...

it doesn't work...i think maybe it's because i write this in level 1 MC and the funtions and variables are in level 0.
Could someone help me with this?

by the way: i load the .swf files in a content MC named "content" but if the variables and functions are in _root, so this shouldn't aftect anything cause i should still refer to _root.window, as an example.

Thanks,
Miguel

View Replies !    View Related
Variables, Functions And Levels
Hello,

in my flash web site i have level 0 and level 1. Some MC from level 1 should you variables from level 0 and functions created in level 0 but until now i wasn't able to make it work because i have been using it as everything in same level...i think that's my mistake.

i use for example, when working in level 1:

_root.window=1; but this variable is in level 0
MC.fadeIN(10, 80); but this functions is in level 1

so how to i this?
and by the way, if i am working on a variable in level 1 and i say _root.var, i am assuming the root from level 1? I mean, each level has a root? Could someone explain to me this or give me some link for me to look at it?

Thanks,
Miguel

View Replies !    View Related
SIMPLE Functions/variables Please Help
i am SO STUCK!!

i am trying for the first time to write my own function and change variables.

i am using levels.

i want it so that i click a button, and bugs run onto the screen

i click another button - the first bugs run off, and new bugs run onto the screen.

SIMPLE!

but hard for me.

i think i know how to set the value of the variable ok, but how to translate that into the name of the movieclip i want to command??



level0main.swf is the main clip

so here's my function:

PHP Code:




loadMovieNum("level50btns.swf", 50);
loadMovieNum("level20bugs.swf", 20);
newbug = 0;
currentbug = 0;
lastbug = 0;

function changebug() {
    if (lastbug = 0) {
        currentbug = newbug;
        _level20.currentbug.gotoAndPlay("in");
    }else{
        _level20.lastbug.gotoAndPlay("out");
        lastbug = currentbug;
        currentbug = newbug;
        _level20.currentbug.gotoAndPlay("in");
    }
}







and my buttons say:


PHP Code:




on (release) {
    _level0.newbug = b4;
    _level0.changebug();
}







please help! i really want to crack this!!
i know atleast one thing wrong, i need the value of the variable in the path "_level20.currentbug.gotoAndPlay("in");"
not the variable itslef - cos it looks like it's a movieClip.....

View Replies !    View Related
Global Variables And Functions?
Hi guys, below I'm declaring a global variable for getting the totalBytes of an XML file but how come even tho its declared as a global variable I can't trace output the value of "XMLSize" with my "trace(_global.XMLSize)" at the end of this script? Could someone shed light on global functions too? Thank you all!
:P
:P


userInfo = new XML();
_global.XMLSize;
userInfo.ignoreWhite = true;
userInfo.load('userInfo.xml');
userInfo.onLoad = function() {
_global.XMLSize = userInfo.getBytesLoaded('userInfo.xml');
XMLOut(this);
}
function XMLOut(xml_file){


for ( a = 0; a < xml_file.firstChild.childNodes.length; a++) {
for(z = 0; z < xml_file.firstChild.firstChild.childNodes.length; z++){

trace(xml_file.firstChild.childNodes[a].childNodes[z].firstChild.nodeValue);

}
}
}
trace(_global.XMLSize);

View Replies !    View Related
Variables In Math Functions.
Hi all,

I was wondering if anyone can help.
In my flash movie the follwing code works fine:

_root.num = random(10);
_root.holder.box.text = eval ("_root.content_"+num);

Basically this code creates a random number which is then added to "_root.content_" to randomly select some text for a dynamic text field.

However, rather than defining the upper limit of the random selection with a number (ie 10), I want to pass in a variable from a text file (_root.value). The code that I am using is:-

_root.num = Math.floor(Math.random()*_root.value);
_root.holder.box.text = eval ("_root.content_"+num);

But this does not work. NaN is being returned.
Any help would be really appreciated!!!

Thanks,
Maw.

View Replies !    View Related
Does AS 2 Not Allow You To Get Variables From Functions Anymore?
Hi all

I have an xml file being retreived and the details sorted out into arrays to then be read by mc's.

As follows:


Code:
var gridXML:XML = new XML();
gridXML.ignoreWhite = true;
gridXML.onLoad = function(success) {
if (success == true) {
trace("gridXML success");
stripXML();
} else {
trace("gridXML fail");
}
};
function stripXML() {
var grid_RootNode:Array = gridXML.firstChild.firstChild.childNodes;
var noOfItems:Number = grid_RootNode.length;
var itemNameArray:Array = new Array();
var itemClientArray:Array = new Array();
var itemTypeArray:Array = new Array();
var itemImageURL:Array = new Array();
for (i=0; i<noOfItems; i++) {
itemNameArray[i] = grid_RootNode[i].attributes.itemName;
itemClientArray[i] = grid_RootNode[i].attributes.itemClient;
itemTypeArray[i] = grid_RootNode[i].attributes.itemType;
itemImageURL[i] = grid_RootNode[i].attributes.itemImageURL;
}
trace("TRACE 1 = "+itemNameArray);
play();
}
gridXML.load("xml/grid.xml");
stop();

The "TRACE 1" comes out no problems with the values of itemNameArray but if I trace out on the next frame the value of itemNameArray it is undefined.

Basically I cant obtain the values outwith the function 'stripXML'

I am new to AS 2, am I missing a path here or anything??

View Replies !    View Related
Dynamic Variables In Functions
(am using Flash 8)

On my stage I have 3 movies, M1, M2 and M3 and a dynamic text box set to show the variable 'txt'.

On my 1st frame I have the actionscript:


Code:
for (j=1; j<=3; j++){

_root["m"+j].onPress=function(){
_root.txt=j;
}

}
What I want to be able to do is to display either the number 1, 2 or 3 DYNAMICALLY in the text box depending on whether M1, M2, or M3 was selected.

The code above will always show '4' in the text box nomatter which movie is selected. (due to the function obviously being called after for loop has finished)

How do I resolve/rewrite this please (it is imperitive that M1-M3 are kept as movie symbols)?

(please note that what I have done here is very a very simlified version of what I am tring to do, however if someone can solve this problem for me, then I can apply the result to my more complex project. Thanks)

Cheers! (P.S an example .fla FLash 8 file is enclosed).

View Replies !    View Related
[F8] Dynamic Variables In Functions
On my stage I have 3 movies, M1, M2 and M3 and a dynamic text box set to show the variable 'txt'.

On my 1st frame I have the actionscript:


Code:
for (j=1; j<=3; j++){

_root["m"+j].onPress=function(){
_root.txt=j;
}

}
What I want to be able to do is to display either the number 1, 2 or 3 DYNAMICALLY in the text box depending on whether M1, M2, or M3 was selected.

The code above will always show '4' in the text box nomatter which movie is selected. (due to the function obviously being called after for loop has finished)

How do I resolve/rewrite this please (it is imperitive that M1-M3 are kept as movie symbols)?

(please note that what I have done here is very a very simlified version of what I am tring to do, however if someone can solve this problem for me, then I can apply the result to my more complex project. Thanks)

Cheers! (P.S an example .fla FLash 8 file is enclosed).

View Replies !    View Related
Paths Variables And Functions
Hi!
I am having problems with a production I am making. Here's the description:

I have a variable in the _root called 'ordered'. I have another variable called 'total' inside a function called 'loadXML'. 'total' receives a number value from a node in a XML file correctly. I now want to transfer this value to the variable 'ordered' which, as I said, is in the _root.

However, 'total' is restricted to the function and I can't access it from the variable in the _root. Neither can I transfer the value from the variable in function to the _root.ordered, since such a line targets the _root of the function itself.

I guess this isn't too hard to solve, probably just a path issue, but I have a few rather large gaps in my knowledge of actionscripting. Can anyone help?

On the stage, there are three objects; a movieclip with the instance name 'clip', a movieclip with the instance name 'orderbox' and finally a dynamic text field with the instance name 'pos_txt'.

My code is on frame 1 and reads as follows:


Code:
System.useCodepage = true; // makes scandinavian charachters work.

// SET COUNTER
var kits = 500;
ordered = 486; // Just an initial value which is replaced later
var kitsleft = kits - ordered;
var counter = kitsleft;

//FUNCTION FOR COUNTER
loadXML = function (loaded)
{
if (loaded)
{
xmlNode = this.firstChild;
total = xmlNode.childNodes[0].firstChild.nodeValue;
//countertext = xmlNode.childNodes[0].childNodes[0].firstChild.nodeValue;
counterfunc(); // triggers function which loads value into dynamic textfield.

}
else
{
content = "file not loaded!";
} // end else if
} // End of the function

counterfunc = function() //Function that shoots the value into dynamic text field
{
pos_txt.text = 500 - total + " Tandvårdskit kvar"; // The text that is shot
_root.ordered = 500 - total; // tries to load value from xml variable "total" into "ordered"
} // End of the function

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("counter2.xml");
p = 0;

//CREATE MOVIE CLIPS
var col = 10; // # of columns
var row = 50; // # or rows
var allboxes = col*row; // # of MC's/cells in grid
var startX = 472 ; // horizontal starting position grid
var startY = 2498; // vertical starting position grid
var offsetX = -50; // horizontal offset
var offsetY = -50; // vertical offset

// RANDOM FUNCTION
Array.prototype.shuffle = function () {
this.sort(function () {return random(2) ;}) ;
} ;

// ARRAYS FOR STORING ORDERED AND REMAININGKITS
var orderedclipsArray:Array = new Array();
var remainingclipsArray:Array = new Array();

// MAKE THE GRID
for (i=0; i<allboxes; i++) {
duplicateMovieClip(_root.clip, "clip"+i, i);
theMC = _root["clip"+i];
theMC._x = startX+(i%col)*offsetX;
theMC._y = startY+Math.floor(i/col)*offsetY;
remainingclipsArray.push("clip"+i); //stores all movieclips in an array
}

//REMOVE ORDERED KITS FROM ARRAY
for (i=0; i<ordered; i++) { //actions below is based on the amount of ordered kits
remainingclipsArray.pop("clip"+i); //removes all ordered movieclips from the array and leaves the ones left
orderedclipsArray.push("clip"+i); //stores all ordered movieclips in an array
}

orderedclipsArray.shuffle(); // Shuffles the listed items in the array of ordered kits
//trace (orderedclipsArray);

//REMOVE ORDERED KITS FROM STAGE
for(i=0 ; i<ordered; i++){//actions below is based on the amount of ordered kits
removeMovieClip(eval(orderedclipsArray[i])) // removes the ordered kits from the stage
}

I also have an XML-file called counter2.xml with the following code:


Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<orderlist>
<orders>486</orders>
</orderlist>

View Replies !    View Related
[F8] Functions, Intervals And Variables
So, I want to make a function that makes a MovieClip rotate. Sounds simple enough, right? Well, onEnterFrame can't be used, because only one onEnterFrame can be used, and the clip already has one. So, I have this.


Code:
//in SomeClass
public static function startRotate(mc, spd, acl)
{
mc._rotation += spd;
spd += acl;
}

//in main timeline
setInterval(SomeClass.startRotate, 2000, 2,3)


The problem lies in that, by calling the function each time, spd and acl are both reset. So, my question is, how do I go about fixing this? Have I gone about it in a completely wrong way? Whats the best way to do this?

Thanks for the help,
Halcyon

View Replies !    View Related
Using Variables From Event Functions
He all!!

I'm trying to use value variables throw public functions in the same class.
Is there any possible to do it?

I'll explain:

Imagine we have a class name Mp3Player that plays some mp3 file and get is ID3 songName:
In that class we have the package:

Code:
//AS Code
package Mp3Player{

import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.media.ID3Info;
import flash.net.URLRequest;
import flash.events.Event;

public class Mp3Player {

private var sound:Sound;
private var req:URLRequest;
private var context:SoundLoaderContext;
private var channel:SoundChannel;
private var id3:ID3Info;
private var nomeMusica:String;

public function tocarMusica(file) {
sound=new Sound ;
req=new URLRequest(file);
context=new SoundLoaderContext(8000,true);
sound.load(req,context);
channel=sound.play();
trace("A tocar");
sound.addEventListener(Event.ID3,id3Info);
}

public function id3Info(event:Event):void {
id3=event.target.id3;
nomeMusica=id3.songName;
}
public function get getNome():String {
return nomeMusica;
}
}

//FLA Code
import Mp3Player.Mp3Player;

var musica:Mp3Player = new Mp3Player();
var nome:String = musica.getNome;

musica.tocarMusica("Saia_Indiscreta.mp3");
trace(nome);
}
The trace result is not what i espected...

Code:
A tocar
Null
Why NULL ???????

What is wrong or missing???

Anyone?

View Replies !    View Related
PHP Variables And Logical Functions
Hi there,

well i guess i got a stupid question but i cant figure it out


Code:
var zoeken:URLRequest = new URLRequest("http://www.zvcvegatigers.com/PHP/aanwezig.php");
var lader:URLLoader = new URLLoader();
lader.dataFormat = URLLoaderDataFormat.VARIABLES;
lader.load(zoeken);


lader.addEventListener(Event.COMPLETE, laden);
function laden (event:Event):void
{var karel_beslist:String = lader.data.dag2_10;
trace(lader.data.dag2_10);
trace(karel_beslist);
if (karel_beslist == "neen") {karel_mc_a.gotoAndStop(2);}
is use the as3 above to obtain values from a php page
by tracing i can confirm i receive the values properly.
BUT
when i use those values in a logical function they don't work
anyone sees a mistake in the code above ?
Cause i got an terrible headache from watching it for some time

Thanks in advance for thos trying to help,

Greetz to all

View Replies !    View Related
Passing Variables Thru Functions?
Hi.

My problem is this: I have the function block, which holds several other functions. I need to pass jpgX through to the sub function floaterBox_mc.viewDetails_mc.onRelease. However, every time I execute it, the trace(jpgX); always gives me the same thing. There must be a way to pass the variables thru, correct?

Any ideas? Thanks!

PS- please excuse my terminology if it is incorrect


Code:
block = function (btn, bTitle, detail_jpg, pdf, jpgX, jpgY) {
this.btn = btn;
this.bTitle = bTitle;
this.pdf = pdf;
this.jpgX = jpgX;
this.jpgY = jpgY;
btn._alpha = 0;
btn.onRollOver = function() {
newX = this._x;
newY = this._y;
oldBtn = newBtn;
newBtn = this;
if (oldBtn != newBtn) {
fadeOutItem = fadeOut(oldBtn);
newW = 302;
}
floaterBox_mc.titleBox_txt.text = bTitle;
};
floaterBox_mc.fBoxArrow_mc.onRelease = function() {
growItem = growWH(floaterBox_mc.fBoxBg_mc);
};
floaterBox_mc.viewDetails_mc.onRelease = function() {
//this always traces "-1307",
//the property from the last BLOCK object in the list:
trace(jpgX);
};
};
block600b = new block(fBlock600b_mc, "Block 600B", "plans/planGround.jpg", "pdf/block110.pdf", -623, -8);
block700 = new block(fBlock700_mc, "Block 700", "plans/planGround.jpg", "pdf/block110.pdf", -623, -8);
block800 = new block(fBlock800_mc, "Block 800", "plans/planSecond.jpg", "pdf/block110.pdf", -1307, -47);

View Replies !    View Related
Reuse Variables In Functions
Hi I'm have some issues trying to access one of my global variables within another function as a part of a class. Here is what I mean.

Code:
class ABC {

var Z:Number;
var num1:Number;
var num2:Number;
var SomeNumber:Number;

function ABC(Z:Number) {
getNum(Z);
}

public function getNum (z:Number) :Void{
Z= num1+num2;

}
public function Equalto(){
Z==SomeNumber;
trace("The two numbers are Equivalent");
}
All I want to do is be able to reuse Z. Right now if I try to use it in Equalto function it returns undefined

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