Resetting A Class
I've created a singleton class to load in that initial states for certain modules. This class loads in 2 XML files, first a global.xml, which contains a pre-set set of states for the entire project, is loaded into one array. It then loads in the appropriate xml file for the module that was chosen into another array. I then have the class copy the first array into an array called stateArray then overwrites items in the stateArray with the values in the 2nd array.I've also added a function to reset the class when the user selects a new module.This class works fine the first time I select a module the first time. However, when I go to select a second module, my code doesn't seem to be calling the reset function properly. Could someone please look at my code below and tell me what I'm doing wrong? ActionScript Code: class images.classes.stateManager {static var instance:stateManager;var initCheck:Number;var initCheck2:Number;var stateReady:Boolean = false;var currentInit:String = "";var currentLRU:String = "";var tempInit:String = "";var globalArray:Array = new Array();var indivArray:Array = new Array();var stateArray:Array = new Array();var indivDone:Boolean = false;var globalDone:Boolean = false; var initScript:XML;public function getStateReady() {return this.stateReady;}public static function getInstance(xml:String):stateManager {if (instance == null) {instance = new stateManager(xml);}return instance;}private function stateManager(xmlFile:String) {this.currentInit = xmlFile;this.initStateManager();}public function resetInstance() {this.stateArray = null;instance = null;this.indivArray = new Array();this.currentInit = "";this.stateReady = false;}public function initStateManager() {var rootApp = this;this.stateArray = new Array();this.tempInit = this.currentInit;this.currentInit = "./InitFiles/global.xml";this.initScript = new XML();this.initScript.ignoreWhite = true;this.initScript.onLoad = function(success:Boolean) {if (success) {rootApp.parseXml(this.firstChild);}};this.initScript.load(this.currentInit);initCheck = setInterval(this, "loadIndivXML", 50);initCheck2 = setInterval(this, "copyArrays", 50);}private function loadIndivXML() {if (this.globalDone) {this.currentInit = this.tempInit;var rootApp = this;this.initScript = new XML();this.initScript.ignoreWhite = true;this.initScript.onLoad = function (succ:Boolean) {if (succ) {rootApp.parseXml(this.firstChild);}}this.initScript.load(this.currentInit);clearInterval(initCheck);}}private function copyArrays() {if (this.globalDone && this.indivDone) {this.stateArray = this.globalArray;this.stateReady = true;for (var elmt in this.indivArray) {for (var id in this.indivArray[elmt].idStates) {stateArray[elmt].idStates[id] = indivArray[elmt].idStates[id];}}clearInterval(initCheck2);}}private function parseXml(nextNode) {while (nextNode != null) {var lastNode = nextNode;nextNode = parseCase(nextNode);if (nextNode == null) {if (lastNode.parentNode.nextSibling != null) {nextNode = lastNode.parentNode.nextSibling;}}}//If we've just finished global.xml, set that variable, //otherwise, set indivDone.if (this.currentInit.indexOf("global") != -1) {this.globalDone = true;this.currentInit = this.tempInit;} else {this.indivDone = true;}}function parseCase(currNode) {var nextNode:XMLNode;var arr:Array;if (this.currentInit.toLowerCase().indexOf("global")!=-1) {arr = this.globalArray;} else {arr = this.indivArray;}switch (currNode.nodeName) {case "IMI":nextNode = currNode.firstChild;break;case "lru":this.currentLRU = currNode.attributes.name;if (arr[currentLRU]==undefined) {arr[currentLRU]=new Array();}arr[currentLRU].lruStatus = Number(currNode.attributes.status);if (arr[currentLRU].idStates==undefined) {arr[currentLRU].idStates = new Array();}nextNode = currNode.firstChild;break;case "id":if (arr[currentLRU].idStates[this.currentLRU]==undefined) {var stateArr = currNode.firstChild.nodeValue;arr[this.currentLRU].idStates[currNode.attributes.name] = stateArr;}nextNode = currNode.nextSibling;break;default:break;}return nextNode;}public function setStateCurrent(lru, id, newVal) {var newId = id.split("_mc").join("");stateArray[lru].idStates[newId]=newVal;}public function getStateCurrent(lru, id) {var newId = id.split("_mc").join("");return stateArray[lru].idStates[newId];}public function getLRUCurrent(lru):Object {var returnArray:Object = new Object();for (var element in this.stateArray[lru].idStates) {returnArray[element] = this.stateArray[lru].idStates[element];}return returnArray;}} And here is the code within the main program: ActionScript Code: ModuleDrop.onChange = function() {_global.stateManager.resetInstance();_global.stateManager = null;//Copied from NAV button!_global.currentUnit = "";currItem = ModuleArr[Number(eventObj.target.value)];currModule = currItem.split(",")[1];_root.currentInit = currModule;_global.currentInit = "./InitFiles/"+currModule+".xml";_global.stateManager = stateManager.getInstance(_global.currentInit);} I really appreciate all the help I can get.
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 05-11-2005, 03:28 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Resetting A Class
I've created a singleton class to load in that initial states for certain modules. This class loads in 2 XML files, first a global.xml, which contains a pre-set set of states for the entire project, is loaded into one array. It then loads in the appropriate xml file for the module that was chosen into another array. I then have the class copy the first array into an array called stateArray then overwrites items in the stateArray with the values in the 2nd array.
I've also added a function to reset the class when the user selects a new module.
This class works fine the first time I select a module the first time. However, when I go to select a second module, my code doesn't seem to be calling the reset function properly. Could someone please look at my code below and tell me what I'm doing wrong?
ActionScript Code:
class images.classes.stateManager {static var instance:stateManager;var initCheck:Number;var initCheck2:Number;var stateReady:Boolean = false;var currentInit:String = "";var currentLRU:String = "";var tempInit:String = "";var globalArray:Array = new Array();var indivArray:Array = new Array();var stateArray:Array = new Array();var indivDone:Boolean = false;var globalDone:Boolean = false; var initScript:XML;public function getStateReady() {return this.stateReady;}public static function getInstance(xml:String):stateManager {if (instance == null) {instance = new stateManager(xml);}return instance;}private function stateManager(xmlFile:String) {this.currentInit = xmlFile;this.initStateManager();}public function resetInstance() {this.stateArray = null;instance = null;this.indivArray = new Array();this.currentInit = "";this.stateReady = false;}public function initStateManager() {var rootApp = this;this.stateArray = new Array();this.tempInit = this.currentInit;this.currentInit = "./InitFiles/global.xml";this.initScript = new XML();this.initScript.ignoreWhite = true;this.initScript.onLoad = function(success:Boolean) {if (success) {rootApp.parseXml(this.firstChild);}};this.initScript.load(this.currentInit);initCheck = setInterval(this, "loadIndivXML", 50);initCheck2 = setInterval(this, "copyArrays", 50);}private function loadIndivXML() {if (this.globalDone) {this.currentInit = this.tempInit;var rootApp = this;this.initScript = new XML();this.initScript.ignoreWhite = true;this.initScript.onLoad = function (succ:Boolean) {if (succ) {rootApp.parseXml(this.firstChild);}}this.initScript.load(this.currentInit);clearInterval(initCheck);}}private function copyArrays() {if (this.globalDone && this.indivDone) {this.stateArray = this.globalArray;this.stateReady = true;for (var elmt in this.indivArray) {for (var id in this.indivArray[elmt].idStates) {stateArray[elmt].idStates[id] = indivArray[elmt].idStates[id];}}clearInterval(initCheck2);}}private function parseXml(nextNode) {while (nextNode != null) {var lastNode = nextNode;nextNode = parseCase(nextNode);if (nextNode == null) {if (lastNode.parentNode.nextSibling != null) {nextNode = lastNode.parentNode.nextSibling;}}}//If we've just finished global.xml, set that variable, //otherwise, set indivDone.if (this.currentInit.indexOf("global") != -1) {this.globalDone = true;this.currentInit = this.tempInit;} else {this.indivDone = true;}}function parseCase(currNode) {var nextNode:XMLNode;var arr:Array;if (this.currentInit.toLowerCase().indexOf("global")!=-1) {arr = this.globalArray;} else {arr = this.indivArray;}switch (currNode.nodeName) {case "IMI":nextNode = currNode.firstChild;break;case "lru":this.currentLRU = currNode.attributes.name;if (arr[currentLRU]==undefined) {arr[currentLRU]=new Array();}arr[currentLRU].lruStatus = Number(currNode.attributes.status);if (arr[currentLRU].idStates==undefined) {arr[currentLRU].idStates = new Array();}nextNode = currNode.firstChild;break;case "id":if (arr[currentLRU].idStates[this.currentLRU]==undefined) {var stateArr = currNode.firstChild.nodeValue;arr[this.currentLRU].idStates[currNode.attributes.name] = stateArr;}nextNode = currNode.nextSibling;break;default:break;}return nextNode;}public function setStateCurrent(lru, id, newVal) {var newId = id.split("_mc").join("");stateArray[lru].idStates[newId]=newVal;}public function getStateCurrent(lru, id) {var newId = id.split("_mc").join("");return stateArray[lru].idStates[newId];}public function getLRUCurrent(lru):Object {var returnArray:Object = new Object();for (var element in this.stateArray[lru].idStates) {returnArray[element] = this.stateArray[lru].idStates[element];}return returnArray;}}
And here is the code within the main program:
ActionScript Code:
ModuleDrop.onChange = function() {_global.stateManager.resetInstance();_global.stateManager = null;//Copied from NAV button!_global.currentUnit = "";currItem = ModuleArr[Number(eventObj.target.value)];currModule = currItem.split(",")[1];_root.currentInit = currModule;_global.currentInit = "./InitFiles/"+currModule+".xml";_global.stateManager = stateManager.getInstance(_global.currentInit);}
I really appreciate all the help I can get.
Resetting
How do I reset a movieclip after it passes a certain Y axis position back to its original position before it moved?
Thanks
Resetting A Var
Frame one contains this:
Code:
XML.prototype.ignoreWhite=true;
oXML = new XML();
oXML.onLoad=function(){
buildVariables(this);
}
buildVariables=function(oXML){
for (var oNode in oXML.childNodes){
if (oXML.childNodes[oNode].nodeType==1)
buildVariables(oXML.childNodes[oNode]);
else
_root[oXML.nodeName]=oXML.childNodes[oNode].nodeValue;
}
}
oXML.load("http://stats.planetsidegaming.com/15/273380/stats2.xml");
Frame 2 contains this but it does not work.
Code:
//To filter ANT
if (certification8 == "Advanced Nanite Transporter"){
certification8 = "ANT";
}
Later in the .fla I have to use _root.certification8 but I've tried that here and it does not work either. How do I reset the var to return "ANT" later as opposed to "Advanced Nanite Transporter"?
Thank you kindly,
Herk
Resetting MC's
I have a movie clip called "enemies" and with in it are several other movie clips of the enemies in my level that I have drug onto the stage. Each enemy has a script that tells it to move (ie. _x = _x + 8). Well, when the player dies, I want the enemies to reset back to their original positions (without restarting the whole scene). Is there a simple way to do this, or do I have to keep a list of all their original positions?
Resetting A MC
I basically have 3 MC's submarine, cursor, and ocean clip.
Basically the problem I'm having is that after you destroy the sub it sinks to the bottom and doesn't reset. And when I alter the code a bit to do a "_root.submarine.gotoAndPlay(1);" the sub plays again but stays at the bottom instead of being set to the middle of the stage again.
Can anyone help me with this please?
Thank you.
1.) Submarine
ActionScript Code:
onClipEvent (enterFrame) {
if (_x<345 and !_root.attached) {
_root.attached = true;
_root.sonarSound();
}
if (!_root.sunk) {
_x -= 8;
_y += vd;
if (_x<-100) {
_x = 400;
vd *= -1;
gotoAndStop(1);
}
} else if (!_root.sink) {
if (random(2)) {
rot = 1;
} else {
rot = -1;
}
_root.sink = true;
_root.stopSonarSound();
}
if (_root.sink and !_root.shook) {
_x -= 3;
_y += 4;
_rotation += rot;
if (_y>240) {
_root.ocean.play();
_root.shook = true;
}
}
}
onClipEvent (load) {
x = _x;
y = _y;
r = _rotation;
vd = 1;
}
2.) The Mouse Cursor
ActionScript Code:
onClipEvent (mouseMove) {
_x = _root._xmouse;
_y = _root._ymouse;
updateAfterEvent();
}
onClipEvent (load) {
Mouse.hide();
}
onClipEvent (mouseDown) {
if (!_root.shooting) {
_root.shooting = true;
_root.explosion._x = _root._xmouse;
_root.explosion._y = _root._ymouse;
_root.explosion.gotoAndPlay(1);
_root.blastSound();
if (_root.submarine.hitTest(_root._xmouse, _root._ymouse, true) and !_root.sunk and _root.submarine._x>0 and _root.submarine._x<300) {
if (_root.submarine._currentframe == (_root.submarine._totalframes-1)) {
_root.sunk = true;
_root.submarine.nextFrame();
} else {
_root.submarine.nextFrame();
}
}
}
}
3.) The Ocean
ActionScript Code:
_root.sunk = false;
_root.shook = false;
_root.congrats.gotoAndStop(1);
_root.submarine.play(1);
Help With Resetting
To help me with learning to program AS3 (I'm a complete newb), I am making a photo album with a button that rotates the images. The problem I'm having is, the button's numbered click event is repeated so it I get a warning about a duplicate:
stop();
hb_btn.addEventListener(MouseEvent.CLICK, click1)
hb2_btn.addEventListener(MouseEvent.CLICK, click2)
hb3_btn.addEventListener(MouseEvent.CLICK, click3)
hb4_btn.addEventListener(MouseEvent.CLICK, click4)
function click1 (evt) {
var url = "http://www.URL1.com"
navigateToURL(new URLRequest(url))
}
function click2 (evt) {
var url = "http://www.URL2.com"
navigateToURL(new URLRequest(url))
}
function click3 (evt) {
var url = "http://www.URL3.com"
navigateToURL(new URLRequest(url))
}
function click4 (evt) {
gotoAndPlay (47)
}
Frame 47 rotates the images and stops with this code:
stop();
hb_btn.addEventListener(MouseEvent.CLICK, click1)
hb2_btn.addEventListener(MouseEvent.CLICK, click2)
hb3_btn.addEventListener(MouseEvent.CLICK, click3)
hb4_btn.addEventListener(MouseEvent.CLICK, click4)
function click1 (evt) {
var url = "http://www.URL4.com/"
navigateToURL(new URLRequest(url))
}
function click2 (evt) {
var url = "http://www.URL5.com"
navigateToURL(new URLRequest(url))
}
function click3 (evt) {
var url = "http://www.URL6.com/"
navigateToURL(new URLRequest(url))
}
function click4 (evt) {
gotoAndPlay (54)
}
So, because of the duplicate error, I gave each new set a new set of click event numbers. That fixed the error. Problem was, when I loop back to the beginning from the end frame, it won't play and just loops the last frame.
What I need to do is find a way to reset the numbered click event so I can reuse the click1, click2, click3 and click4. Is there a way to reset the value so I can reuse it?
Resetting A .swf
I have a large .swf that dynamically loads other .swf onto the stage. Once these smaller clips are finished, I'd like to "replay" them. Here's the problems though: Cannot just _root.gotoAndPlay(1) because I have actionscript tweens that aren't reset by setting the timeline. Also, I have locked the root down, so I don't know if I can simply tell the larger .swf to just re-load the smaller ones.
Resetting Variables
Okay to anyone who can help, here is the deal. I have a main swf file that i use as a template for a flash course. Now this template has a series of buttons that control the course, like play pause and all that. It also has a replay button. Here is the tricky part though, the actual course files are other swfs that load underneath the main swf with the buttons. These files contain text box question and answer problems, but i since there is a replay button on the main swf, this causes a problem cause now if i type in an answer and hit replay the text box answer remains. How can i make it so that i can set the variables to reset when i hit the replay button. Note once again that the replay button is in another swf in another level.
This sounds more complicated than it really is, i know.
Thanks
Resetting Variables
Hi guys,
Quick question ...
If on drag and drop detection, I am setting the variables of various MC's , how ... when I replay the animation (via a button saying replay - not manually), do I reset the mc's variables back to the original state?
Thanks.
Adele
Resetting Variables
Is there any simple little command in flash that will reset all variables in the movie?
If so, what is it?
Variable Resetting
Is there a way to reset the values of all the variables in a movie at once? In the movie I'm working with everything starts out blank, so it wouldn't seem too difficult assuming I can access all the variables with one statement.
Resetting GetTimer ?
I'm using getTimer(); in a countdown. When it reaches 0, it goes to a 'end game' scene. In this scene there is a button to play again, which uses gotoAndPlay (Scene 1,1) to start again.. but the countdown now starts from 0, going to -1, -2 etc.
Does getTimer() find the elapsed time of a MOVIE ? I thought so, so replaced "gotoAndPlay (Scene 1,1)" with:
unloadMovieNum (0);
loadMovieNum ("04cardriver6.swf", 0);
which I thought would work, but doesn't...
Does this mean getTimer() uses the elapsed timne of the opening of the FLASH PLAYER?
Resetting A Scrollbar
Hey all
I have a guestbook with a dynamic text box with a scrollbar and scroll up/down buttons in an MC. The guestbook is set to display 5 entries at a time, there are buttons for next/previous 5 entries also. A user can scroll up/down thru the current 5 entries using the scroll up/down btns or the scrollbar. The problem is when the user clicks for the next 5 entries and they are displayed in the text box, the scrollbar does NOT jump back to the top. But if you click the down btn it jumps to the top before starting to scroll down. I would like the scrollbar to reset to the top when the user first clicks for the next/previous 5 entries. This is the script attached to the MC:
onClipEvent (load){
scrolling = 0;
frameCounter = 1;
speedFactor = 3;
numLines = 7;
origHeight = scrollbar._height;
origX = scrollbar._x;
needInit = false;
function initScrollbar(){
var totalLines = numLines + GuestBook.maxscroll - 1;
scrollbar._yscale = 100*(numLines)/totalLines;
deltaHeight = origHeight - scrollbar._height;
lineHeight = deltaHeight/(GuestBook.maxScroll - 1);
}
function updateScrollBarPos(){
scrollbar._y = lineHeight*(GuestBook.scroll - 1);
}
}
onClipEvent (enterFrame){
if( needInit ){
if(GuestBook.maxscroll > 1){
initScrollbar();
needInit = false;
}
}
if( frameCounter % speedFactor == 0){
if( scrolling == "up" && GuestBook.scroll > 1){
GuestBook.scroll--;
updateScrollBarPos();
}
else if( scrolling == "down" && GuestBook.scroll < GuestBook.maxscroll){
GuestBook.scroll++;
updateScrollBarPos();
}
frameCounter = 0;
}
frameCounter++;
}
onClipEvent (mouseDown){
if(up.hitTest(_root._xmouse,_root._ymouse)){
scrolling = "up";
frameCounter = speedFactor;
up.gotoAndStop(2);
}
if(down.hitTest(_root._xmouse,_root._ymouse)){
scrolling = "down";
frameCounter = speedFactor;
down.gotoAndStop(2);
}
if(scrollbar.hitTest(_root._xmouse,_root._ymouse)) {
scrollbar.startDrag(0,origX,deltaHeight,origX);
scrolling = "scrollbar";
}
updateAfterEvent();
}
onClipEvent (mouseUp){
scrolling = 0;
up.gotoAndStop(1);
down.gotoAndStop(1);
stopDrag();
updateAfterEvent();
}
onClipEvent (mouseMove){
if(scrolling == "scrollbar"){
GuestBook.scroll = Math.round((scrollbar._y)/lineHeight + 1);
}
updateAfterEvent();
}
onClipEvent (data){
needInit = true;
}
Any help with this is greatly appreciated. Thanks in advance. Much respect.
---
Bryce
phunkyphresh@hotmail.com
Resetting Variable
Hello,
I got a script wich is resetting a variable by itself?
The first trace(a); gives the correct value, the second one (in the tellTarget function) allways gives a zero. I'm getting desperate here
in an other function a is set to 1
topnav.contact.onRelease = function() {
if(a != 5){
if(a != 0){
trace(a);
tellTarget("nav" add a){
trace(a);
gotoAndPlay("nav" add a add "Back");
}
}
tellTarget("nav" add a){
gotoAndPlay("nav" add a "Start");
}
}
}
Thanks for reading!
Frans-Jan
Resetting MytextFormat.url ? ****
hello,
i'm working on a flash-text-editor but i have a problem when i want to use links (or mails) with (mytextformat.url)
i can set the url to a piece of text like:
mytextformat.url="http://www.url.com"
Does anyone know how i can reset this url ?
when i use "mytextformat.url=false" then the link is gone but i still see the "hand-cursor" over my text. Does anyone know how to get rid of this. It seems the link is empty and it links to an empty urlPage.
thanks!!!
Resetting MC _width ?
I'm trying to change an MC's _width with the following code:
Code:
mcpreload.loadBar._width = 1;
But I'm not having any luck. This code works on a previous line on my script:
Code:
mcpreload.loadBar._width = per * 2;
Is there another way to write this code? Or to 'reset' the loadBar mc's width back to it's original width size (1).
Thanks
Foochuck
Resetting An Mc's Posistion
I'm having a problem with something which would usually seem simple. I have a game with a few levels, and it's the game where you destroy blocks with a ball. Well the problem I'm having, is getting the ball and paddle to reset their posistion when the movie goes onto the next level. I have given my ball and paddle a keyframe on each level, which should be working already, but as it's not I decided to add:
Code:
this._x = 221.8;
this._y = 269;
that to the load event of my ball, but for some reason it still wont work! Could someone please help me out, thanks.
Resetting An EventListener
I've got an addEventListener attached to a mediaPlayback component and it needs to be reset so that the video that is being played can play again when the user goes back to it.
I am using cuepoints for the eventListener and everytime I return to the video after it has reached it's cue point nothing plays the second time around.
Here is the code I am using:
player1.removeAllCuePoints();
player1.addCuePoint("part2",23);
myObj=new Object();
myObj.cuePoint=function(p){
stopAllSounds();
gotoAndPlay("part2");
}
player1.addEventListener("cuePoint", myObj);
Player1 is the instance name of the MediaPlayback component.
Help would be greatly appreciated.
Resetting _x,_y,_ And Scale?
Hello All,
Long Long time lurker. Anywho, I know my way around mx alright for most things but when it comes to code it's all just annoying to me, but Im dying to become proficient in it. FlashKit and Kirupa have always been a great resources for me, and Ive searched through the posts, but everyone codes so differently I get confused.
My issue is simply resetting the _x,_y, and scale of a movie clip after it's been changed through AS. I am using loadMovie to load external SWF's then adjusting placement of the loaded movie through a submenu using actionscript. My issue is how to reset the _x,_y and scale to 0,0,100 when you select the next portfolio piece.
Attached you'll find my nasty test movie with horrid code any help getting this to work will be greatly apprieciated. The positioning isn't set exact in this file but you'll get the gist. If I wasn't a poor human being I'd offer money but as I have none all I can offer is an illustration or custom illustrated desktop to whoever can help this wanna-be.
Take Care,
ID
Resetting Gettimer
I'm using gettimer in a game to determine what some variables are set to. When the game is ended, I need to have gettimer reset to 0 and have the game restart. Restarting the game is easy enough, but how do I reset gettimer?
Thanks.
Resetting Rotations
I'm creating an animation for the mechanisms section on my website. - File attached. The top pulley is an MC which is supposed to turn 345 degrees clockwise in 24 frames however it now seems to be turning almost two full turns.
Is there a way of finding out out how much it turns in the length of the movie clip?
Is there a way of reseting the rotation?
TIA
www.flying-pig.co.uk
Resetting A Cookie?
I have a cookie which is set using AS, but is there a way of creating a reset. So I can reset the cookie with just a button.
Any suggestions would be appreciated.
Thanks.
Resetting X And Y Properties
Hello, wondering if you guys could help me out here, ill try to describe this as best as i can.
whats happening with my movie is i have 4 images loaded into 4 created MC's within a MC already created. then ive made a mask to be called from the library, and it applys itself to each MC.
now with the problem:
i have four buttons four images stacked ontop of each other. so the 1st image is showing say i want to see image four with out seeing two and three. i just click on btn 4 and it goes there. (so that works) however what ive done is ive told each MC to move away. what i want but dont know how to approach, is reset the _x cords of each MC, after theyre hit....
here my code, also ive provided a link to my swf to make it easier to understand what i mean. thank you everyone whom can help out!
http://www.teksunstudios.com/_misc_p...slideshow.html
PHP Code:
function moveImage(clipName, speed, xDist) {
clipName.onEnterFrame = function() {
this._x += (xDist-this._x)/speed;
if (Math.abs(xDist-this._x)<1) {
return;
}
};
}
//-------------BUTTON 01-------------
btn_01.onRollOver = function() {
this.gotoAndPlay("start");
};
btn_01.onRollOut = function() {
this.gotoAndPlay("end");
};
btn_01.onRelease = function() {
moveImage(img_hold.img_2, 10, -310);
moveImage(img_hold.img_1, 10, -310);
moveImage(img_hold.img_0, 10, -310);
};
//-------------BUTTON 02-------------
btn_02.onRollOver = function() {
this.gotoAndPlay("start");
};
btn_02.onRollOut = function() {
this.gotoAndPlay("end");
};
btn_02.onRelease = function() {
moveImage(img_hold.img_3, 10, -310);
moveImage(img_hold.img_1, 10, -310);
moveImage(img_hold.img_0, 10, -310);
};
MC Button Not Resetting...
Hey Folks,
I have a problem that has been driving me absolutely
nuts. I have a MovieClip that is acting like a button - it
has an on(release) action applied to it. When I press the
button, the action occurs, but in order for me to make 'it'
happen again, I must first move the mouse just a bit
before I click. If I don't move the mouse, nothing
happens when I click the button.
Let me clarify... Imagine a button that zooms in on a
picture each time it is clicked. Idealy, I would be able to
click twice really fast, and the picture would be zoomed
in twice. Not in this case. I click twice, and there is one
zoom. If I move the mouse slightly I can zoom in again.
Again, the MovieClip has an on(release) action.
Has anybody come across something similar to this?
It seems to me like the on(release) action is not being
released until I move the mouse.
I'd sure appreciate any assistance ya'll have.
Thanks.
Swf Keeps 'resetting' Itself Within The Movie
hi
i have a problem with the galleries that i'm building for this:
http://www.bigredbutton.tv/digby7/
site. if you go inside to the sections within the 'portfolio' section you'll see galleries with thumbnail images. if you browse for a while and move the mouse around suddenly the whole gallery will reset itself to its beginning image/thumbnail position. no idea why this is happening -- any ideas?
emma.
Resetting Timer
I'm making a game with a timer that countsdown for 60 seconds. I want it to repeat because the game is about collecting resources once each minute, but everytime it goes back to frame 2, the seconds go down in intervals of 2 because the part in the code where the "time -= 1;" goes down by 1 each time the frame is revisited (first time: 60, 59, 58, 57, 56... |second time: 60, 58, 56, 54, 52... |third time: 60, 57, 54, 51, 48.. and so on)
Code:
stop();
setInterval(countdown, 1000);
time = 60;
function countdown() {
time -= 1;
if (time<=0) {
_root.wood += 25;
gotoAndPlay(2);
}
}
I've spent long hard hours working on this so help is much appreciated
[F8] Resetting Scroll Bar
I have been working on a project that has about 15 frames. Each frame has a photo and a scrolling text field. I have used the scroll bar component with these text fields. On a few of the frames - if you read to the bottom of the text and click to the next frame the scrollbar stays positioned at the bottom even though the text in the next field starts at the top. It doesn't happen on each frame though. Does anybody have any ideas?
[F8] Resetting Colors
I'm trying to get a map to highlight a user's zip code when they enter it into a textInput field. Once they enter it they click a component button and the zip code lights up. That all works fine.
My problem is that I can't get the colors to reset when a new zip is entered. The previous one stays lit up and the new one lights up as well.
Any help is appreciated,
Layne
Code:
function clicked() {
if (zipCode_ti.length == 5) {
//I thought keeping track of a previous zip and issuing it a different color before colorizing the next one would work. But it did not.
trace("Previous Zip = "+previousZip);//<-----Undefined, even on second click
var previousZipColor:Color = new Color(_root["z"+previousZip]);
previousZipColor.setRGB(0xDDDCCC);
var zipColor:Color = new Color(_root["z"+zipCode_ti.text]);
zipColor.setRGB(0xBF0000);
var previousZip:String = zipCode_ti.text;
trace("Current Zip = "+zipCode_ti.text);//<----This works fine
}
}
findZip_btn.addEventListener("click",clicked);
Resetting A Movieclip
Hello all,
I've got a menu and when clicking on a menu item the menu disappears and a movieclip opens. The user can do several things in this movieclip. When done there is a button that removes the movieclip and opens the menu again. Now when I open the movieclip again is still on the same frame as when it was closed. How can I reset the movieclip.
Thanks
Resetting My Variables
hey there. ive made a little thing where im clicking points for score, ive then let flash play a movie clip on a different frame and then at the end the app returns to frame 1. When i do this, if i have clicked on anything before hand it all resets to 0. How do i stop this from happening
[F8] My Boolean Is Resetting Anybody Know Why?
Hey guys I have the following code. For some reason the if statements are setting my 'myKey' boolean value to true every time. Any clues why? The intial trace works fine it shows both false and true so I know my previous code is working.
Code:
trace(myKey);
if (myKey=false){
gotoAndPlay("square");
trace(myKey);
}
if (myKey=true){
gotoAndPlay("circle");
trace(myKey);
}
Thank you!
[CS3] Resetting An Array
Hello,
I was wondering if there was any way to reset an array to no value? I got it at no value at the start of my program, but I can't get it to no value when pressing a button for example. I tried putting "myArray = null" but that didn't work too well. I also tried "myArray = new Array();" but that didn't reset it either. Do I have to splice all the values?
Thanks in advance!
Resetting A _rotation
Hey,
Im have an object roating back and forth and when I roll over a btn, Im wanting it to spin to its original state. Here is the code if anyone wouldnt mind taking a look that would be ideal! Also Im sorry if its a little messy... Im not the greatest writer yet.
PHP Code:
function btnName() {
var resetSpin = 10;
btn.onRollOver = function() {
globe.onEnterFrame = function() {
if (this._rotation == 90) {
resetSpin = -10;
//this._rotation == 0;
}
if (this._rotation == 0) {
resetSpin = 0;
}
this._rotation = this._rotation+resetSpin;
};
};
}
function globeSpin() {
var halfSpin = 1;
globe.onEnterFrame = function() {
if (this._rotation == 90) {
halfSpin = -1;
}
if (this._rotation == 0) {
halfSpin = 1;
}
this._rotation = this._rotation+halfSpin;
};
}
globeSpin();
btnName();
Resetting Movie
Is there a way I can have a movie reset and go to frame 1 (as though it were just loaded into the browser)? I'm having problems when I simply gotoAndPlay(1) - is there a way I can just 'wipe the slate clean' so to speak and start from the beginning again when a button is clicked?
MC Resetting To Frame 1
Hey All,
The issue I am having is that I have a MC that in on the main scene. This MC is controlled by buttons which scroll it left and right. The MC also has buttons within the movie which, when pressed, jump the user to a different part of the main timeline.
Sounds simple, but the problem is that the MC is resetting back to frame 1 once the user clicks one of the buttons. I need that MC to stay on whatever frame the user ends it on, so when they return to the main scene, they don't have to scroll back to where they left off.
Thanks for your help!
Jeff
Hot Object Not Resetting
I created a quiz using the template. All my questions are using hot objects. The game works well but the hot object from the previous question stays on for the next question until the reset button is pressed. I have not changed any of the code.
When the next question is pressed, the previous hot object is still lite, the new answer has to be pressed but the 'Click on check answer is highlighted' . Then the reset button has to be pressed, a new answer picked and then check answer.
This happens for each question
Any ideas.
Resetting The Whole Movie
I'm wondering if there is a nice easy way to call a function that will essentially act the same way as closing the .swf and opening again... except without actually having to do so. I need to make a program that handles a lot of data clear all of the data and just load fresh upon hitting a button. I could make a function myself that clears everything, but that probably will leave a bunch of junk in the memory. Is there a nice function call to reload? Please say yes :-)
Help Please Resetting A Listener
Hi,
Im trying to create a game for my 1 year old in flash that shows a letter on the screen. He has to press that letter on the keyboard to move on to the next letter.
So far Ive got this...(for letter a)
Code:
stop ();
var myListener:Object = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 65) {
play();
}
};
Key.addListener(myListener);
the problem is, when I get to letter b and put this...
Code:
stop ();
var myListener:Object = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 66) {
play();
}
};
Key.addListener(myListener);
"a" still works. How can I make it so the listener, "resets" or "forgets" any previous letter?
Thanks!
Rich
Help With Resetting Movie
Hello all,
I'm new here and just recently I've started training on flash. I've got a movie up and running that may be introduced into a new site that my company is working on, but I can't figure out why this keeps happening. I have 4 buttons at the bottom of 300x300 box. Each button has an "onRollOver" event attached to it that sends the playhead to another frame. The button on the bottom right works most of the time, but there are occasions that when rolling in and out in different patterns, it sends my movie back to the beginning. Now while I'd rather it didn't go back to the beginning at all, there are times that it even alters the way my movie plays when it resets it such as preventing something from fading in that was fading in previously.
I'd love to attach the fla file, but I'm not sure how. I'll attach the code that is contained in the 4 frames that each button links to.... be gentle if I've done something in a roundabout way.... I'm pretty new at actionscript...
Basically, the movie opens up with 4 different backgrounds fading in and out using a setInterval command with "5000" as the interval. Each background has dynamic text (updated using 4 text files) and a picture that appears with it (this is just a mock up, so the pictures are crap). There are 4 buttons at the bottom that are there throughout the entirety of the movie. Now, when a button is rolled over, it then links to these other frames and STOPS the interval fading and only moves between frames through the rollover options. Frames 50-54 are the fading frames and frames 70-73 are the rollover frames.
I've attached the code for 70-73, and the sample from frame 53 will be basically the same for all of frames 50-54 except for a few different instance names and such (I actually labeled it frames 50-55 below but it only goes through 54).
I would be very appreciative of any suggestions specifically on why it might be doing this. Any other suggestions on how to clean up my code, or something that could condense the amount of code I'm using would be welcomed also, but most importantly I'd like to figure out the problem at hand.
Thanks for everything guys.
EDIT: I'm using flash professional 8 and AS2
EDIT #2: Sorry, I don't comment or use any kind of documentation in my work very often.
Attach Code
---------------------Frame 70 code-----------------------
stop();
clearInterval(MyInterval);
pic1_mc.alphaTo(100,1,"linear")
bleedThrough_mc.colorTo(0x127CC2, 1, "linear");
announcementsPicture_mc.alphaTo(10, 1, "linear");
essentialsPicture_mc.alphaTo(0, 0, "linear");
rgbaVantagePicture_mc.alphaTo(0, 0, "linear");
webTutorialPicture_mc.alphaTo(0, 0, "linear");
essentials_btn.onRollOver = function() {
gotoAndPlay(71);
};
rgbaVantage_btn.onRollOver = function() {
gotoAndPlay(72);
};
webTutorial_btn.onRollOver = function() {
gotoAndPlay(73);
};
myData = new LoadVars();
myData.onLoad = function() {
introText_txt.htmlText = this.content;
};
myData.load("BlueText.txt");
---------------------------------------------------------
---------------------Frame 71 Code----------------------
stop();
clearInterval(MyInterval);
pic2_mc.alphaTo(100, 1, "linear");
bleedThrough_mc.colorTo(0x01A302, 1, "linear");
announcementsPicture_mc.alphaTo(0, 0, "linear");
essentialsPicture_mc.alphaTo(10, 1, "linear");
rgbaVantagePicture_mc.alphaTo(0, 0, "linear");
webTutorialPicture_mc.alphaTo(0, 0, "linear");
announcements_btn.onRollOver = function() {
gotoAndPlay(70);
};
rgbaVantage_btn.onRollOver = function() {
gotoAndPlay(72);
};
webTutorial_btn.onRollOver = function() {
gotoAndPlay(73);
};
myData = new LoadVars();
myData.onLoad = function() {
introText_txt.htmlText = this.content;
};
myData.load("GreenText.txt");
----------------------------------------------------------
----------------------Frame 73 Code-----------------------
stop();
clearInterval(MyInterval);
pic1_mc.alphaTo(100,1,"linear")
bleedThrough_mc.colorTo(0xFF711F, 1, "linear");
announcementsPicture_mc.alphaTo(0, 0, "linear");
essentialsPicture_mc.alphaTo(0, 0, "linear");
rgbaVantagePicture_mc.alphaTo(10, 1, "linear");
webTutorialPicture_mc.alphaTo(0, 0, "linear");
announcements_btn.onRollOver = function() {
gotoAndPlay(70);
};
essentials_btn.onRollOver = function() {
gotoAndPlay(71);
};
webTutorial_btn.onRollOver = function() {
gotoAndPlay(73);
};
myData = new LoadVars();
myData.onLoad = function() {
introText_txt.htmlText = this.content;
};
myData.load("OrangeText.txt");
-------------------------------------------------------------
---------------------Frame 74 code-----------------------
stop();
clearInterval(MyInterval);
pic2_mc.alphaTo(100, 1, "linear");
bleedThrough_mc.colorTo(0xFC4D30, 1, "linear");
announcementsPicture_mc.alphaTo(0, 0, "linear");
essentialsPicture_mc.alphaTo(0, 0, "linear");
rgbaVantagePicture_mc.alphaTo(0, 0, "linear");
webTutorialPicture_mc.alphaTo(10, 1, "linear");
announcements_btn.onRollOver = function() {
gotoAndPlay(70);
};
essentials_btn.onRollOver = function() {
gotoAndPlay(71);
};
rgbaVantage_btn.onRollOver = function() {
gotoAndPlay(72);
};
myData = new LoadVars();
myData.onLoad = function() {
introText_txt.htmlText = this.content;
};
myData.load("RedText.txt");
----------------------------------------------------------------------
-----------------------Sample code from frames 50-55--------------------------
//Red Background
clearInterval(MyInterval);
bleedThrough_mc.colorTo(0xFC4D30F, 1, "linear");
webTutorial_mc.alphaTo(10, 1, "linear");
rgbaVantage_mc.alphaTo(0, 1, "linear");
pic2_mc.alphaTo(100,1,"linear")
myData = new LoadVars();
myData.onLoad = function() {
introText_txt.htmlText = this.content;
};
myData.load("RedText.txt");
announcements_btn.onRollOver = function(){
gotoAndPlay(70);
}
essentials_btn.onRollOver=function(){
gotoAndPlay(71);
}
rgbaVantage_btn.onRollOver=function(){
gotoAndPlay(72);
}
webTutorial_btn.onRollOver=function(){
gotoAndPlay(73);
}
MyInterval = setInterval(function () {
gotoAndPlay(54);
}, 5000);
stop();
-------------------------------------------------------------
Edited: 05/24/2007 at 10:52:30 AM by Taidaishar
Resetting Flash
I have a swf file that does several animations depending on keystrokes.
Is there a way to add a keystroke that essentially resets the flash animation?
ie: if for some reason the flash isn't running quite right, the user can hit
'reset' and the code reloads and gives you a fresh start.
Resetting GetTimer
getTimer() is gradually incrementing within my movie. Is there a way for me to reset that timer from within my code?
Resetting The Scrollbar?
How do you reset the scrollbar in Flash? (I'm using the component, not a cusom scrollbar.)
If you go here, scroll ALL the way to the bottom and then click on "Donations" - you'll see the scrollbar stays in place.
How do I get it to refresh each time new text is loaded? I've tried refreshPane() and a few other things, but nothing works.
Thanks.
Resetting All Variables?
I don't know if this is possible...
is there a command that resets all variables to their original position/ number? There's a bunch of variables in my game... and at the end I want the option to replay. But if you play right through the game again everything will be messed up.
ah... if not I'll just tell people to X the window and reload it...
Resetting Swf's Contained In A Mc
hi all, hope someone out there can help.
I have two variations of pageflip v2 which i'm using for two seperate cv's. What I've done is created two emptymovieclips and put the two swfs in them (clipA, and clipB).
The trouble is I've noticed that when I want to switch between the two mc's more then once (so that I have visited clipA, clipB and then revisit clipA) on stage the pageturning effect no longer works properly (its as if the script of Pageflip in each swf has some kind of residual memory of when I last looked each one.)
Is there a work around solution whereby I can reload each swf contained within each clip so they play from frame1 eachtime I switch between them.
In effect loading from scratch eachtime.
Any ideas what the best approach is would be great
Resetting A Form
Anyone know how I can reset the text on an input text field?
the as im using is as follows:
on(release) {
_root.myForm.formNameField.txt = ""
_root.myForm.formEmailField.txt = ""
_root.myForm.formMessageField.txt = ""
}
and it aint working
Resetting A Variable
I've been trying to reset my rotateImage function if it hits 5_mc in the array
I have the array items with actionscript linkage to 1,2,3,4,5
Any ideas on how to do this?
Thanks,
Saveth
Code:
// NUMBER OF BANNERS
var countbanners = 5;
// DEFINE BANNER ARRAY
filenamebanners = ["1_mc", "2_mc", "3_mc", "4_mc", "5_mc"];
// GET RANDOM BANNER
for (i=0; i<countbanners; i++) {
s = filenamebanners.length;
k = Math.floor(Math.random()*s);
holder_mc.attachMovie([k], banner[k]+i, getNextHighestDepth());
}
// FADE IN IMAGE
this.onEnterFrame = function() {
if (holder_mc._alpha<100) {
holder_mc._alpha += 10;
}
};
rotateInterval = setInterval(rotateImage, 4000);
// ROTATE IMAGES
function rotateImage() {
holder_mc._alpha = 0;
holder_mc.attachMovie([k++], banner[k++]+i, getNextHighestDepth());
}
Resetting A Textbox?
I have a form, with a text box. the intitail text in the textbox says "type text here" . Is there how do I reset that text to nothign when the users clicks in that text field?
Help For Resetting Game...
I'm trying to figure out how to reset a game that I've been working on - my actionscripter is unavailable and I'm not so good! At the end of the game we want a 'play again' button, and it needs a script that takes the player to first frame (no problem!) and clears/resets the scoring, which is set up in the game logic code as the following...
_global.SetScoreItem = function(name, score)
{
_global[name] = _global[name] + Number(score);
_root.left_panel["lp_" + name].text = _global[name];
}
_global.SetScore = function(answer)
{
if(answer.knowledge)SetScoreItem("knowledge", answer.knowledge);
if(answer.wellbeing)SetScoreItem("wellbeing", answer.wellbeing);
if(answer.career)SetScoreItem("career", answer.career);
if(answer.students)SetScoreItem("students", answer.students);
Any help on a simple script that would do this? Thanks much
Resetting Scroller To The Top
Hi,
I have sliding movie, which contains 3 different MCs. these ease onto the stage depending on the respective buttons clicked. On the stage, the scrolling of any of these movies is controlled by a single scroller. the problem is this: after i've scrolled down to read and i click on another button that movie slides in to where the scroller stopped previously. I need to essentially reset the scroller to the top again when another button is clicked. how can i do this?
Thanks.....
|