While Function Not Working With Else If Function
I got a code ( Code: onClipEvent (enterFrame) { if (_root.chatbox == "buy") { while (_root.shop == "What would you like to do?") { _root.shop = "Yes, Ok then."; _root.items._visible = 1; } else if (_root.chatbox == "sell") { _root.shop = "Ok. I see you have chosen sell."; _root.items._visible = 0; } } } )
the Else if function doesnt seem to work well with while function. When i got rid of the while function it worked.
Any one know why this is happening?
FlashKit > Flash Help > Flash MX
Posted on: 08-17-2004, 02:19 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Function In A Function In A Function, A Scope Problem
Is this basic or what.. I have a nested functions, and I'm having a hell of a time getting all my variable through.
ActionScript Code:
var canyouseemee;
public function move()
{
for(var i:Number = 0; i < blah; i++)
{
zing, and then zang
if (zing==0)
{
guts
}
if (zang ==0)
{
something else
}
}
}
Now, I had always thought that since var canyouseemee is declared at the topmost layer, that I'd be able to see it from anywhere below it. Well, it turns out that I can only see it from within the move()function, and not anything below it. is this normal? I thought you couldn't see a local variable of a lower (deeper) function, but could see higher (shallower) variables...
Function Not Working
I'm using flash 5 to develop.
I am very perplexed...
Here's my code....
============================
AScript, text_box and button on main timeline
function test (txt1, txt2) {
text_box = txt1 + txt2;
}
============================
on Button click.....
on (release) {
test ("Text One", "Text Two");
}
============================
The button works fine when run on local PC, but when uploaded to server, it doesn't work. I have Player 8 when I am browsing on the web
What is wrong?
Function Not Working
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...
Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}
[F8] Function Not Working
Hi everyone,
I'm trying to get the following function to work:
function door() {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip("business.swf", myLoader);
door_mc.gotoAndPlay("sceneIn");
}
I then call the function here:
businessBtn_mc.onRelease = function() {
door();
}
It works fine as is but I'm trying to make it work for all the other buttons as well by trying to add a parameter to the function like this:
function door(movieName) {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip(eval(movieName), myLoader);
door_mc.gotoAndPlay("sceneIn");
}
then call the function again with the value added:
businessBtn_mc.onRelease = function() {
door("business.swf");
}
...but it doesn't work.
I've attached the fla files so you can see the full code.
I wonder if someone could take a look and see where I've gone wrong?
Thanks so much.
Function Working Only Once ?
Hi I have this function that scrolls my menu back to it's original place :
Code:
//Tweens
import mx.transitions.Tween;
import mx.transitions.easing.*;
ResetMenu = function() {
ResetScrollBar = new Tween(_root.scroll_bar, "_x", Bounce.easeOut, _level0.scroll_bar_x, 42.5, 1, true);
ResetMenu = new Tween(_root.menu_holder, "_x", Bounce.easeOut, _level0.menu_holder_x, 18, 1, true);
}
I call it from a button and it works but only the first time, if I click a second time on the button (after scrolling my menu) nothing happens :cry:
Code:
on (press) {
ResetMenu ();
}
Can you please help ?
dip
Function Not Working...
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...
Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}
Function Not Working
on my main timeline on the frame
ActionScript Code:
stop();
csub._alpha = 0;
bsub._alpha = 0;
function FadeIn(c) {
this.onEnterFrame = function() {
if (c._alpha < 100) {
c._alpha+= 5;
}
}
}
function FadeOut(d) {
this.onEnterFrame = function() {
if (d._alpha > 0) {
d._alpha-= 5;
}
}
}
then on my button I have
ActionScript Code:
on(release) {
FadeIn(csub);
}
This all works great. Although if I do:
ActionScript Code:
on(release) {
FadeIn(csub);
FadeOut(bsub);
}
The Fade out works great too. Although the FadeIn stops working. Anyone know what I'm missing here?
Sandman9
Function Not Working Right.
I have a problem with my function, it works alright but for some reason it only works once at a time..
let me explain, i have a bullet and an object, when the bullet hits the object both mc's get unloaded but after they unload and effect and an item will appear in its place... but as soon as you hit another object with a bullet the first lot of item/effect dissappear? why is this?
here is my code..
I have an MC labeled functions and in its actions are these functions...
ActionScript Code:
onClipEvent(enterFrame){
dropchance = random(2);
}
onClipEvent(load){
unloadframe = 51;
depth = 0;
itemdepth = 99998;
function attachItem(a, b) {
if (dropchance == 0){
namea = "itemdrop" + itemdepth;
_root.attachMovie("itemdrop", namea, itemdepth, {_x:a, _y:b});
_root[namea].gotoAndStop(random(3)+1);
} else {
trace('No Drop');
}
}
function effectExplode(a, b) {
nameb = "explode" + depth;
_root.attachMovie("explode", nameb, depth, {_x:a, _y:b});
_root[nameb].onEnterFrame = function () {
if (this._currentframe == unloadframe) {
this.unloadMovie();
}
}
}
}
and the hittest is as follows:
ActionScript Code:
if (this.hitTest(_root.theobject)){
_root.theobject.unloadMovie();
this.unloadMovie();
_root.functions.effectExplode(this._x, this._y);
_root.functions.attachItem(this._x, this._y);
}
so why does this only work once and then seem to remove once another hittest occurs? i dont get it..
any help is welcomed.
thanks.
Function Not Working
i'm trying to call a function from inside nested functions and can't get it to work. i tried directing the scope of the call to the function every way i knew how (_global, _parent, _root) and even tried declaring the function in a different way like
var myFunction = new function() { ...... }
below is the appropriate part of my code. bospv2_start() is the function that won't work. what am i doing wrong? i can call the function in other places just fine.
Attach Code
function flushLSO() {
agent_so.data.bospv2_agentName = dataAgentName;
agent_so.data.bospv2_agentEmail = dataAgentEmail;
agent_so.data.bospv2_agentGroup = dataAgentGroup;
agent_so.flush();
var twLSOundefinedOut:Tween = new Tween(LSOundefined, "_alpha", Strong.easeOut, 100, 0, 3, false);
twLSOundefined.onMotionFinished = function() {
LSOundefined.removeMovieClip();
bospv2_start();
};
}
function bospv2_start() {
Function Not Working
I'm making a little quiz for school. And a function I used just the other day isn't working. Why not.
ActionScript Code:
stop();countries(c1,"Morocco",p1);//more African countries.function countries(box,count,countx){ if(box==count){ countx=1; }else{ countx=0;}
That's all on frame 1.
On frame one there's also an imput text box with the instance name c1, and a next frame button.
On the next frame I have a dynamic text box witht he instance name total.
frame 2 has the AS
ActionScript Code:
//imagine p1+p2+p3+p4toatal.text=p1}
Why dosen't this work?
Function Not Working
I don't get why my menu dropdown function is not working. It works when I put the instance name of the dropdown menu in, but when I try to use eval for the instance name it won't work. This code is giving me the problem.
ActionScript Code:
menuopen(eval("d"+q), -219, 0);
This is most of my AS
ActionScript Code:
/////////////////////////Button Functions/////////////////////////function menuclose(item, beg, end) { var butclose:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskclose:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, -225, .3, true); clearInterval(dropup1);};function menuopen(item, beg, end) { var butopen:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskopen:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, end, .3, true);};function butup(item) { if(dropup1 != null){ clearInterval(dropup1); } var butin:Tween = new Tween(item, "_alpha", Strong.easeOut, 0, 12, .5, true);};function butdown(item) { var butin:Tween = new Tween(item, "_alpha", Strong.easeOut, 12, 0, .5, true);};///////////////////////Button Actions/////////////////////////Buttons on the main nav barvar q:Number = 1;b1.onEnterFrame = function(){ eval("b"+q).onRollOver = function() { butup(this); menuopen(eval("d"+q), -219, 0); }; eval("b"+q).onRollOut = function() { butdown(this); dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225); }; eval("b"+q).onReleaseOutside = function() { butdown(this); dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225); }; q++; if(q == 3){ delete this.onEnterFrame; }}
Function Not Working
Hello good people!
Is this right?
PHP Code:
function something(){ //code}mc.onRelease = function(){ something();}
or is it like this?
PHP Code:
something = function(){ //code}mc.onRelease = something;
Thanks!
Not Sure Why Function Not Working
I am using Flash 8 and just learning ActionScript 2.0.
I have a basic call to a function that I am not sure why it is not working.
3 Questions:
1.) Am I passing the value into the function correctly.
2.) Can I pass a value into a function and not use it.
3.) How come in the code that works, I don't have to call the function by togglePower(), Instead I call it without the ()?
Here is my code:
NOT WORKING
CODEfunction togglePower(myVar:Number):Void {
remote_mc.light_mc.play();
}
remote_mc.power_btn.onRelease = togglePower(55);
Function Not Working
ok, this is my first time using a function, help me:
on frame one i made the following function:
function introClosing(){
_root.gotoAndPlay("introClosing");
_root.introTitle.gotoAndPlay("16");
}
the function is called when a button is pressed
the first line works
the second lines works to the point of bringing up that movie clip instance, but it does not play frame 16
WHY??????? what have i done wrong and do u need more information?
Function Not Working
hi all,
could you pls help me this is the script i put this script in to my site but it is not working properly i don't no why is, when i am testing moving in site flash i worked but when access through browser it won't work why is that could you please help me
thanx somiadiscon
function _() {
}
function url1() {
getURL("javascript:window.external.AddFavorite('(URL address blocked: See forum rules))", "");
}
Stage.scaleMode = noScale;
var expand = new ContextMenu();
expand.hideBuiltInItems();
var $tab1 = new ContextMenuItem(" site ", tab, false, false, true);
var $url1 = new ContextMenuItem("Bookmark this site ...", url1);
var $tab2 = new ContextMenuItem("------------------------------------------", tab, false, false, true);
var $url2 = new ContextMenuItem(" Pro ", url2);
expand.customItems.push($tab1, $tab2, $url1, $url2);
expand.onSelect = menuHandler;
_root.menu = expand;
Random X Function Not Working
The function is supposed to assign a random x value to a movie clip, however it is not working.
Whats wrong with this function?
This actionscript is being called from frame 1 of layer 1 on the root:
function randomX() {
x = _x.random(490)+30;
return x;
}
This script is being called from a movie clip on frame 1 of layer 1 on the root:
onClipEvent (load) {
function randomX();
}
onClipEvent (enterFrame) {
if (_root._currentframe == 1) {
_x = (randomX.x());
}
}
How Do I 'stop' A Function From Working?
Hi, the animation that I'm trying to build is probaly very simple, but I can't quite work it out?
What I'm trying to make is a basic drag and drop where the object ('dragt') slowly returns to it's starting point by following the target ('targett') in order to get there.
The problem is that the function I'm using to move it there 'movet' = pasted in below) keeps going. So that when you try to click on it again, it's still working and it causes a flickering between the movement it's trying to accomplish and the drag action.
I tried included a variable ('ton') to build in a basic on/off state into the function, so that it won't work until 'ton == 0', ton is made equal to 0 as part of the start drag action. However, as said, this only works once as the function is still going when you go back to click again. So the hitest (seen below) registers again and puts 'ton == 1' before the drag can even begin.
So... what I need is some way to tell the function to stop doing what it's doing when the movieclip returns to it's original co-ordinates?
Hopefully I'm explaining this in some way that makes a degree of sense and somebody can solve this, or has encountered something similar before,
thanks loads,
-Eoin McD
Here's the function:
setInterval(movet, 5);
// call the catchase function every 5 ms
function movet() {
// set x, y for cat closer to x, y of mouse
if (_root.ton == 0) {
_root.dragt._x = _root.dragt._x+(_root.targett._x-_root.dragt._x)/20;
_root.dragt._y = _root.dragt._y+(_root.targett._y-_root.dragt._y)/20;
}
if (_root.dragt.hitTest(_root.targett)) {
_root.ton = 1;
}
if (_root.ton == 1) {
gotoAndStop(1);
}
}
updateAfterEvent();
For Loop In A Function Is Not Working HELP
Hi,
I have a preloader scene. This scene preloads and also loads my ASP page that contains variables like baseURLs, etc. I load my asp file and then run a function. The function stores these global variables. My problem comes in when I get to the for loop in the function. The for loop does not execute. I'm positive that the reason is that the variable _root.sliderFileTotal has not been loaded from the ASP file yet. Instead the for loop runs first and cannot get the value of _root.sliderFileTotal .
I know this because I've traced _root.sliderFileTotal outside of the for loop and I get the value. But in the for loop it does not trace. I'm sure that the for loop is taking precedence in the function and is running first.
Can anyone help me with this. I've been stuck on this the entire day. Also, I don't want to take the for loop out of the function. Everything else works fine in this function so I don't really want to drastically modify all this code because my deadline is breathing down my neck.
Thank you for your help (and even reading this far).
frame1:
Code:
var fileNames = new LoadVars();
fileNames.load("Flash/getFileNames.asp");
frame2:
Code:
fileNames.onLoad = function(success) {
if (success) {
// set the baseURL global variables + get the filenames to be loaded
_root.bottomURL = fileNames.bottomURL;
_root.baseURL = fileNames.baseURL;
_root.baseXMLURL = fileNames.baseXMLURL;
_root.billBoardFile = fileNames.billBoardFile;
_root.cube1File = fileNames.cube1File;
_root.cube2File = fileNames.cube2File;
_root.cube3File = fileNames.cube3File;
_root.cube4File = fileNames.cube4File;
_root.cube5File = fileNames.cube5File;
_root.cube6File = fileNames.cube6File;
_root.cube7File = fileNames.cube7File;
_root.cube8File = fileNames.cube8File;
_root.cube9File = fileNames.cube9File;
_root.comboBoxFile = fileNames.comboBoxFile;
_root.competitionBoardFile = fileNames.competitionBoardFile;
_root.sliderFileTotal = fileNames.sliderFileTotal;
for(n=1;n<_root.sliderFileTotal+1;n++) {
_root["slider"+n+"file"] = fileNames["slider"+n+"File"];
trace(n); // here's my problem. n does not trace. it's not hitting the for loop
}
}
}
if (fileNames.loaded && _framesloaded >= _totalframes) {
gotoAndStop ("Scene 1", 1);
} else {
var loadedbytes = getBytesLoaded();
var totalbytes = getBytesTotal();
var frame = int(loadedbytes/(totalbytes/100));
loader.gotoAndStop(frame);
}
frame3:
Code:
gotoAndPlay(2);
On(rollover){do Function();) Not Working Right
I have a MC containing just the nav buttons for my movie. on this MC's timeline I have two functions. One opens a display, the second closes it.
I also have many buttons that each have an call to the first function to open the display and write some text when the mouse is over them.
There is also one lone button that actually closes the display. It calls the second function on mouse over.
Well up to this point all work fine (kinda). See the problem is after you mouseover one button the rest will not work. To be clearer, if I play the movie and mouseover button1 the function will execute as expected. If I then mouse over button2 nothing happens. Same thing if I start with button2, then button 1 will not work.
Here's the details
I have reduced this to be readable but even these few lines do not work.
function showHint(hintStr){
hintBoxMC.hintBox.text=hintStr;
hintBoxMC._alpha=100;
return false;
}
function resetHint(){
hintBoxMC.hintBox.text="";
hintBoxMC._alpha=0;
return false;
}
All of the buttons except for one call showHint on(mouseOver)
The other button calls resetHint();
Since all of the buttons work (as long as they are the first one pressed) I know the tergeting is correct. Also all MC's within this MC are paused at this point so that shouldn't be an issue.
Any ideas? Thanks in advance
Function Not Working Correctly, Please Help
the following function is returning a single value when multiple items are selected. Can anybody see why? I'm using flash mx if that matters.
function Subscribe(){
var selectedItems = new Array();
selectedItems = Subscribe_lb.getSelectedItems() ;
for ( var i = 0 ; i < selectedItems.length ; i++ ){
formData.Subscribe = selectedItems[i].label;
}
}
thanks,
Howard
Mx SendForm Function Not Working...please Help
Hi all,
I have this registration form which is similar to others that work just fine. I cant seem to find any errors preventing the code to work, but its not working.
here is the link to the form online registration form
here is a link to the fla
I really need another pair of eyes on this one. thanks in advance
Howard
Moive Function Not Working
here is the functioon:
PHP Code:
var acceleration = 17;
var friction = 0.4;
function Move (targetX, targetY) {
var xdif = targetX-this._x;
var ydif = targetY-this._y;
this.xspeed += xdif/this._parent.acceleration;
this.yspeed += ydif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this.yspeed *= this._parent.friction;
this._x += this.xspeed;
this._y += this.yspeed;
this.checkDistance();
};
function checkDistance () {
if (Math.abs(targetX-this._x)<0.2 && Math.abs(targetY-this._y)<0.2) {
if (Math.abs(this.xspeed)<0.2 && Math.abs(this.yspeed)<0.2) {
this._x = this.targetX;
this._y = this.targetY;
delete this.onEnterFrame;
}
}
};
then when the movie reaches a certain frame, I call the move function with the following code:
PHP Code:
onEnterFrame = _root.intro.main.Cail_dmask.Move(-73.2, -80.7);
But my mask pops into place instead of moving graduaally then slowly oscillating till it comes to a halt.
What's wrong with my code?
thanks
Simple Function Not Working
I feel kind of silly asking this, but can anyone tell me whats wrong?
code:
function overButton (ClipName) {
trace("workingOver " +ClipName);
ClipName.submenu.surroundings.heading.colorTo("0x0 099FF",.2,"easeInOutSine");
ClipName.submenu.surroundings.heading.tween("_x",5 ,.2,"easeInOutSine");
ClipName.submenu.surroundings.back.alphaTo(100,.2, "easeInOutSine");
trace("workingover complete");
}
Say ClipName is "commercial" the trace comes out fine with commercial inserted. Even when i replace ClipName with "commercial" and hard code it in, the function works! but not with the parameter.
Can anyone tell me where im going wrong?
Cheers!
EDIT: Added [ as ] tags - jbum
On Rollover Function Not Working, Please Help
I have created a invisible button to control my MC, I am trying to get 2 actions to work when on (rollOut) whats the best procedure to do this because the code below is not working properly. thanks in advance
Code:
on (release) {
_root.click1.gotoAndStop(13);
}
on (rollOver) {
_root.click1.gotoAndPlay(2);
}
on (rollOut) {
if (_root.click1_currentframe == 13) {
gotoAndStop(13);
} else {
_root.click1.gotoAndPlay(7);
}
}
LoadMovie() Function Not Working
I am trying to make a new layout for my website. My website has flash movies I made. I want to make a flash menu, that plays my movies. I am currently using the code:
on(release){
_root.watch.loadMovie("http://www.myfilestash.com/userfiles/penguinflash/andyandjake.swf", "_root.watch")
}
and the movie is not loading... before, I used the code:
onClipEvent(enterFrame){
this.loadMovieNum("http://www.myfilestash.com/userfiles/penguinflash/andyandjake.swf", 0)
}
and with that, it loads my movie, but the frame I made disappears. So, neither of my codes work. Can someone please help me?
Why Isnt This Function Working?
Okay I got my enemy creator, and enemyAI function done, but when i test it out, it isnt working.. It will attach the enemies, but it wont assign them to their X and Y that i have assigned, and the enemy AI function wont work for them.. Can anyone help me? Here is my enemy AI function:
function enemyAI(enemy,num) {
for(b=0;b<num;++b) {
_root["enemyHealth"+b] = 100;
}
diff = Math.ceil(hero._x-enemy._x);
if (diff > -350 && diff < 370) {
if(!Stop) {
moving = true;
if (hero._x> enemy._x) {
enemy._xscale = -100;
enemy._x += enemySpeed;
enemy.gotoAndStop("enemyRun");
}
if (hero._x< enemy._x) {
enemy._xscale = 100;
enemy._x-= enemySpeed;
enemy.gotoAndStop("enemyRun");
}
}
}else {
enemy.gotoAndStop("enemyStand");
}
/////////////////////////////
if (enemy.hitTest(hero) && attacking == false) {
thisTime = getTimer()/1000;
if (thisTime>nextStab) {
Stop = true;
nextStab = thisTime+delay2
enemy.gotoAndStop("enemyStab");
hp -= 2;
}
}else {
Stop = false;
}
if(alive == true) {
if(enemy.hitTest(hero) && attacking == true) {
_root["enemyHealth"+b] -= str*level;
if(level <= 3) {
strExp++;
}else if(level >= 4 && level <= 7) {
strExp += 2;
}else if(level >= 9 && level <= 12) {
strExp += 4;
}
}
}
if(_root["enemyHealth"+b] <= 0) {
enemy._y = enemy._x = -100;
_root["enemyHealth"+b] = 0;
alive = false;
enemy._visible = false;
}
if(enemy.hitTest(hero._x,hero._y,true) && hero._x > enemy._x) {
hero._x += moveSpeed;
}else if(enemy.hitTest(hero._x,hero._y,true) && hero._x < enemy._x) {
_hero._x -= moveSpeed;
}
}
and here is my enemy creator function:
function createEnemies(guys, xArray, yArray){
for(a=1; a<=guys; ++a){
_root.attachMovie("enemy","enemy"+a,a+99)
_root["enemy"+a].x = xArray[a-1];
_root["enemy"+a].y = yArray[a-1];
_root["enemy"+a].onEnterFrame = function() {
enemyAi(_root["enemy"+a],guys);
trace(_root["enemy"+a]);
}
}
}
and here is how im trying to do it:
createEnemies(2,[100,300],[350,350]);
Call To Function Not Working?
Hi,
I have a function that changes the background colour of a text field:
Code:
function changeColour() {
_root.ticker_txt.backgroundColor = "0xFFCC00";
_root.ticker_txt.background = true;
_root.ticker_txt.border = true;
}
I call this function in another function that refreshes the screen every 5 seconds:
Code:
// delay function
function unpause() {
// get XML file each time
getXML();
// change colour of text field
changeColour();
trace("Colour Change: "+changeColour);
// clear existing delay interval
clearInterval(_global.my_interval);
}
The XML feed is parsed and the text put into the textField I want:
Code:
// parse XML
function loadXML(loaded) {
if (loaded) {
// trace XML data
trace("XML Data: "+xmlData);
// get ticker & volume
_root.ticker = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
// set text box values
_root.ticker_txt.text = _root.ticker;
} else {
trace("File not loaded!");
}
}
This unpause function is called in one last function that loads XML data into my textField:
Code:
// get XML function
function getXML() {
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("xmlfeed");
trace("Requested Feed: xmlfeed");
// request ever 5 seconds
_global.my_interval = setInterval(unpause, 2000);
}
I have a textfield on the stage with an instance name of ticker_txt. I don't see why this is not working?
If I move the changeColour(); call outside of the unpause(); function - it works perfectly!?
Any ideas - I am sure it is the way I am refrencing the textField - but everything is in the same moviclip/scene/frame - so _root should work surely?
I am utterly at a loss - tried lots of things - really need some advice.
Cheers,
Chris
Function To AttachMC Not Working
i can't figure out why this line of code isn't working, similar function in my fla (which dont attackMCs but change frame work fine) this is the is an essential part ofthe game im making and its been eluding me for days as to how to get this working.
function checkAttack() {
if (time == 54) {
clearInterval(checkAttack)
this.attachMovie("attack", "mcAttack", this.getNextHighestDepth())
}
}
attackInterval = setInterval(checkAttack, 100);
Function Assignment Not Working...
I am making a top-down shooter game in Flash 8 that is nonlinear (you can fly in any direction) and I am having a hard time getting the weapon system to work. here is my code:
Code:
shots = [];
weapon = "laser";
laserspeed = 20;
onMouseDown = function () {
addon = true;
for (i=0; i<shots._length; i++) {
if (!shots[i]) {
shots[i] = true;
this[weapon].duplicateMovieClip("shot"+i, 2+i);
this["shot"+i]._x = active._x;
this["shot"+i]._y = active._y;
this["shot"+i]._rotation = 90-dir*180/Math.PI;
this["shot"+i].shotmove(dir, eval(weapon+"speed"));
addon = false;
break;
}
}
if (addon) {
this[weapon].duplicateMovieClip("shot"+shots.length, 2+shots.length);
this["shot"+shots.length]._x = active._x;
this["shot"+shots.length]._y = active._y;
this["shot"+shots.length]._rotation = 90-dir*180/Math.PI;
this["shot"+shots.length].shotMove(dir, eval(weapon+"speed"), shots.length);
shots.push(true);
}
};
MovieClip.prototype.shotMove = function(direct, sspeed, place) {
ttlcounter = 125;
this["shot"+place].onEnterFrame = function () {
ttlcounter--;
if (ttlcounter == 0) {
this.removeMovieClip();
for (i=shots.length; i>0; i--) {
if (shots[i]) {
break;
} else {
shots.pop();
}
}
}
for (i=0; i<total.length; i++) {
if (total[i].hitTest(_x, _y, true)) {
this.removeMovieClip();
for (j=shots.length; j>0; j++) {
if (shots[j]) {
break;
} else {
shots.pop();
}
}
}
}
this["shot"+place]._x += Math.cos(direct)*sspeed-_global.xspeed;
this["shot"+place]._y -= Math.sin(direct)*sspeed-_global.yspeed;
};
};
i have all the weapon type as a string stuff so that i can add different weapons later. dir is the direction the ship is facing in radians. I have tried debugging this and what seems to happen is that the function shotMove gets assigned to the shot, but only for one frame. the laser MC just stays right there in the middle of the ship. this might seem like a newbie question, but what can i do to keep shotMove assigned to the shot?
Visible Function Not Working
I'm trying to use the script to make movie clips candle2 - candle10 visible. instead of write out, candle2._visible = true 9 times, i figured i could create a loop. i have other movie clips that i need to do the same with. but when i run this script, it's not making anything visible. i did a trace, and var_name does equal candle2-10, the loop is working, just not the visible function. i did write out the candle2._visible = true just to test, and it works perfectly.
i'm also having this same problem on another frame trying to make the movie clips invisible. the loop seems to be functioning, but for some reason it's not liking the variable._visible. Please advise!!
var i = 2;
while (i<=10) {
var_name = "candle"+i;
var_name._visible = true;
i++;
}
Nested Function Not Working
Hi, i'm trying to get my gallery scroller to activate on scrollwheel instead of just button click - to do this i've added the listener code and nested the scrolling function inside, however the nested function is not being called at all, is it due to incorrect syntax or something?
Individually the components work fine, i can get traces back on the mousewheel and the scroller does work on button click...Think i am joining the two together incorrectly.
Code:
var yPositions = new Array(0, -150, -300, -450, -600);
var mouseListener = new Object();
mouseListener.onMouseWheel = function(delta) {
// this is an array for storing the positions of the slider
function jumpTo(number) {
// this function takes the variable "number" that is passed from the buttons and takes the corresponding
// value from the array of positions, then sets the new position in the slider to the new position.
slider.newY = yPositions[number];
trace(slider.newY);
trace("test");
}
};
Mouse.addListener(mouseListener);
stop();
Thanks for any help!
Start Function Not Working?
hey im stuck on this problem for a sonund player and was wondering if anybody could help me out
i have the following code on my start/pause button:
Code:
onClipEvent (enterFrame) {
this.onRelease = function() {
if (_root.playy == true) {
_root.screen.light.mySound.stop();
_root.playy = false;
} else if (_root.playy == false) {
_root.screen.light.mySound.start();
_root.playy = true;
}
};
}
the song starts when it loads and it will stop when the button is pressed but it wont start again when the button is pressed the second time... does anybody know what might be wrong?
thanks in advance
-yeps
Trace Function Not Working
everytime i use a trace fucntion, i areas I know work, as I have tested via other means, the trace fails to show in the output window!
anyone else ever have this problem?
Trace Function Not Working
I am trying some very simple code and I can't get it to work. To debug, I tried using the trace function and that doesn't even work! I opened a new doc, I added it to an old doc, but nothing seems to work!
Code sample
var myNum:Number;
pic_btn.onRelease = function () {
gotoAndPlay(2);
myNum = 0;
trace(myNum);
}
contact_btn.onRelease = function () {
gotoAndPlay(2);
myNum = 1;
trace(myNum);
}
The gotoAndPlay works but the variable doesn't get set and the trace function does not fire. What am I missing. Please help if you can!
Thanks,
Roachmoe
[F8] Function Not Working Properly?
Hi Ive made a function which I call - but nothing seems to happen?
Its supposed to move a movieclip - but it just dissapears?
Heres the code:
function MoveMe() {
startCoordinate = 100;
Speed = 1;
for (var i:Number = 0; i < 400; i++) {
UpCoordinate = (-Speed) * i + 0.6 * i;
MyMC._y = startCoordinate + UpCoordinate;
}
}
I guess It'smoving too fast? for me to see - but how do i slow it down?
Cheers!
[F8] How To Stop Working Function For A While
Hi Guys
This is my first post here, so I am saying hellow to everybody
I have such problem: There is main.swf (I made it with some tutorial) and it loads another swf, then moves it according to mouse movement in horizontal direction. You can see it here
After clicking on any button popup appears. I want to stop the horizontal animation in bacground for time when popup is shown.
I have no idea how to do that, I'v tried many ways but no result.
Is better way to try to do that with onRelease function on buttons or maybe from popup when it is showing?
The code is a little bit complicated, so if any of you wants to look at source it is here.
Cod that controls movement is in classes/Mover.as file and as controlling buttons is in library/timeline_png_v3.fla file.
Maybe someone could help me, I would appreciate it.
Thanks in advance
OnLoad Function Not Working...HELP
I've created a template interface with an empty movie clip for swf files to load when activated by their specific buttons. the interface animates until frame 20 when it is then static. This is the frame where I placed the empty movie clip on a new layer. On that same frame, I have indicated the Actionscript below. I can get the buttons to work but I can't get the initial page to load with the onLoad function.
The code I'm using is:
btn1.onRelease = function(){
loader_mc.loadMovie("about.swf");
}
btn2.onRelease = function(){
loader_mc.loadMovie("team.swf");
}
btn3.onRelease = function(){
loader_mc.loadMovie("clients.swf");
}
btn4.onRelease = function(){
loader_mc.loadMovie("folio.swf");
}
btn5.onRelease = function(){
loader_mc.loadMovie("kudos.swf");
}
btn6.onRelease = function(){
loader_mc.loadMovie("gofurther.swf");
}
btn7.onRelease = function(){
loader_mc.loadMovie("contact.swf");
}
onLoad = function(){
loader_mc.loadMovie("about.swf");
}
It all seems fine until I test the movie and "about.swf" will not initially load as its supposed to. I've uploaded the stuffed source files to http://www.clearlygreendesign.com/flash_help.html if anyone would like to have a look. I'm using Flash CS3 and AS 2.0.
Thanks!
[F8] [AS2] Trace Function Not Working
Guys, here's the hell thing:
I have two flas, with two different movieClips that extends differents Classes.
The first .fla loads the second: just like Default.fla load catalog.fla
all the functions are working just Ok, but... on the movieclip at catalog.fla, the class dont show ANY trace, eventhough it runs into all the functions.
I have even created a dinamic textfield and in the constructor function of the class I set some text and it did it, just well... what proves my functions are all working, but from any hellish reason I cant see ANY trace, so I just am not able to debug this damn class.
Could someone help me? please.
trying to be a little more expecific:
I have default.fla who has a movieClip called main. Main is a Class who extends Controller class.
And I have catalog.fla who has a movieClip called photos. Photos is a Class who extends Remote class.
so photos runs inside main. all the actions are ok, but It just stop showing me the traces of ONLY the Photos Class!
[F8] Simple Function Not Working?
Code:
var objects = Array("bg.person1", "bg.person2");
function checkForCollisions(){
var collision:Number = 0;
for (i=0; i<objects.length; i++){
//if the user collides with of the objects in the array...
if (_root.zack.hitTest(_root.objects[i]) == true){
trace("collision with " + objects[i]);
}else{
trace("no collision with " + objects[i]);
}
}
trace(collision);
}
for some reason it ALWAYS returns "no collision with blablabla" even when the mc zack is hitting an object specified in the array.
Really need help with this one guys.
Thanks.
[CS3] Function Call Not Working
Why is the function not working, any ideas?
This is my function:
function add_controll_pannel() {
this.attachMovie("controll_pannel","controll_panne lMC",10);
controll_pannelMC._x="157";
controll_pannelMC._y="186";
}
And this is my function call:
add_controll_pannel;
Nothing happens. Any help?
Thank you!
TAB Key - OnKeyUp Function Not Working.
I am creating an onscreen keyboard which mimics the user's input i.e. keys depress and return as they would on a real life keyboard.
I solved my original problem of the flash shortcut keys ENTER, BACKSPACE etc by disabling the keyboard shortcuts.
These keys now work with the onKeyDown function i have created and the animation of the key depress works but once the key has been depressed it does not return to the release position as the other keys on the keyboard do such as letters like a, s & d.
Can anyone shed some light on to why the TAB, ENTER, BACKSPACE etc keys are different.
Thanks,
Stuart
Please see my code below:
Code:
// Start Key listener
keyListener = new Object();
keyListener.onKeyDown = function()
{
switch (Key.getCode()) {
case 49 :
_root.mov_1.gotoAndStop(2);
break;
case 50 :
_root.mov_2.gotoAndStop(2);
break;
case 51 :
_root.mov_3.gotoAndStop(2);
break;
case 52 :
_root.mov_4.gotoAndStop(2);
break;
case 53 :
_root.mov_5.gotoAndStop(2);
break;
case 54 :
_root.mov_6.gotoAndStop(2);
break;
case 55 :
_root.mov_7.gotoAndStop(2);
break;
case 56 :
_root.mov_8.gotoAndStop(2);
break;
case 57 :
_root.mov_9.gotoAndStop(2);
break;
case 48 :
_root.mov_0.gotoAndStop(2);
break;
case 187 :
_root.mov_equals.gotoAndStop(2);
break;
case 189 :
_root.mov_hi.gotoAndStop(2);
break;
case Key.BACKSPACE :
_root.mov_backspace.gotoAndStop(2);
break;
case Key.TAB :
_root.mov_tab.gotoAndStop(2);break;
case 32 :
_root.mov_space.gotoAndStop(2);
break;
case 75 :
_root.mov_k.gotoAndStop(2);
break;
}
}
keyListener.onKeyUp = function()
{
switch (Key.getCode()) {
case 49 :
_root.mov_1.gotoAndStop(1);
break;
case 50 :
_root.mov_2.gotoAndStop(1);
break;
case 51 :
_root.mov_3.gotoAndStop(1);
break;
case 52 :
_root.mov_4.gotoAndStop(1);
break;
case 53 :
_root.mov_5.gotoAndStop(1);
break;
case 54 :
_root.mov_6.gotoAndStop(1);
break;
case 55 :
_root.mov_7.gotoAndStop(1);
break;
case 56 :
_root.mov_8.gotoAndStop(1);
break;
case 57 :
_root.mov_9.gotoAndStop(1);
break;
case 48 :
_root.mov_0.gotoAndStop(1);
break;
case 187 :
_root.mov_equals.gotoAndStop(1);
break;
case 189 :
_root.mov_hi.gotoAndStop(1);
break;
case Key.BACKSPACE :
_root.mov_backspace.gotoAndStop(1);
break;
case Key.TAB :
_root.mov_tab.gotoAndStop(1);
break;case 32 :
_root.mov_space.gotoAndStop(1);
break;
case 75 :
_root.mov_k.gotoAndStop(1);
break;
}
}
//Key listener
Key.addListener(keyListener);
SetTextFormat Function Not Working
Hi all, I'm having a problem with changing font attributes with setTextFormat. I am loading a formatted txt document (not html) into swf which reads letter by letter and needs to change font when a format is encountered. I can't get the code to change the font when in a function. It works fine outside the function.
ActionScript Code:
function checkstring(thestring) {
body.text = "";
show1.text = thestring.length;
j = 0;
for (i=0; i<thestring.length; ++i) {
if (thestring.charAt(i) == ">") {
theformat = thestring.substr(i, 5);
if (theformat == ">line") {
body.text = body.text + "
";
}
if (theformat == ">bold") {
makebold();
}
i = i+5;
j = j+5;
body.text = body.text + thestring.charAt(i);
} else {
body.text = body.text + thestring.charAt(i);
}
show1.text = i-j;
show2.text = theformat;
}
}
function makebold() {
bodyformat1 = new TextFormat();
bodyformat1.font = "mymedium";
bodyformat1.color = 0xFF0000;
body.setTextFormat(bodyformat1);
}
There must be a conflict of having a function within a function, but I'm sure I've done that before and it worked?
Thanks in advance for any help/explanations offered.
Joe
OnRelease Function Is Not Working
var moviename = "movie_mc" + j;
var movielevel = 1+j;
_root.createEmptyMovieClip(movie_mc, movielevel);
loadMovie("images/" + thumbnail + ".jpg", movie_mc);
_root[movie_mc].onRelease = function(){
trace("sd");
};
The image is loading in the movie and working properlly.But in case of onRelease function it is not working . Pls help the red line is not working.
A Function Not Working On First Press...
Hey forum users...
//I have this code working for a shared object working almost perfect thanks to newblack and xeef help, but something is wrong with the calling...
Code:
stop();
//This is one shared object for coins
var so:SharedObject = SharedObject.getLocal( "gamer", "/" );
var coins:Number = so.data.coins == undefined ? 0 : so.data.coins;
var shits:Number = so.data.shits == undefined ? 0 : so.data.shits;
var combos:Number = so.data.combos == undefined ? 0 : so.data.combos;
function coinCollected() : Void {
so.data.coins = ++coins;
so.data.shits = ++shits;
so.data.combos = ++combos;
trace("monedas" + so.data.coins );
trace("shapes hitted" + so.data.shits );
trace ("combos made" + so.data.combos );
}
I call the function when a movie clip instance is pressed
Code:
onClipEvent(load) {
this.onPress = function ()
{
onPress = _root.coinCollected;
trace(_root.coinCollected);
}
}
but the first press isn´t working... and so the whole function becomes unuseful because I need that it works from the beginning (first press)...
I´m confused for that two onPress nested...
Some ideas? Thanks for the help...
Geturl Function Not Working
This has been buggin me for the past few days.
i am one of many people trying to link from flash to iframes but i cannot get it to work for the life of me.
im using
on(release){
getURL("grosby.html", "iframe1");
}
with the iframe code looking like this
<iframe name="iframe1" id="iframe1" height="291" width="622" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe>
my flash is sitting with in a table set with the iframe in a different cell of the same table.
but it wont work. ive tried using flash 7 and 8 but nothing.
any ideas ?
thanx,
alex
FadeOut Function Not Working
html: http://roscoecreations.com/main_flash_help.html
fla: http://roscoecreations.com/main_flash_help.fla
Hey guys this is my final question for this project. Everything works except for this one thing. Please check out my html file listed above and click on the Executive in the middle Then hit the back button and you will see that the bullet points don't fade away like with the other people. I am doing this the same way so I don't understand why it wont work. Feel free to check out my FLA, any help would be great! Thank you.
Function To Set Opacity Of MC Not Working?
I have defined a function to set the opacity of a series of MC's to "0":
ActionScript Code:
// Set opacity to "0"
function(){
for (j=1; j<6; ++j) {
_root.slide[j]._alpha=0;
}
}
I've tried redefineing the path to the MC's by using "_level0" & "this" as well; it doesn't correct the problem. I'm sure it's how I've defined the for loop but can't figure out what's causing the trouble.
(using FLASH pro 2004, publishing as Flash Player 7 w/ AS2.0)
I'm not too sure what I'm doing wrong.
Advice?
Thanks.
|