Targeting A Function Using A Variable
I am trying to target a function from a abutton in a movie using a variable, this targets a mc on the root with one frame with seven functions: one, two, three etc etc, I have seven buttons all instaniated by the same names ne, two, three etc etc, how can I use the insance name to target the function. I tried
inst_name = _name; _root.functions.inst_name();
I know thiat this doesnt work, is there a way to do this?
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-31-2001, 10:41 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Function () Targeting
I am trying to write a function that I can call to make clips scale. It works if they are on the same level (ie on the same movie clip) The following code works on single movie clip... but what I want to do is make it so that I have the function on the main timeline (_root) and then call it from where ever.
this is what I got so far.
onClipEvent(load){
myDistance
go=true
Destination=250
function heightMotor(Destination){
if(go){
if (myDistance>=5) {
deltaX = Math.round(this._height-Destination);
myDistance = Math.round(Math.sqrt((deltaX*deltaX)));
if (this._height != Destination) {
this._height += (Destination-this._height)*.8;
}
} else {
go=false
this._height=125//_parent.squair._height-8
}
}
}
//trace(_parent._width);
}
onClipEvent (enterFrame) {
heightMotor(Destination);
}
Targeting A Function
I would like to fire a function that is inside my main script from a class
like so :
ActionScript Code:
var myClassTest:MyClass = new MyClass(this, myFunction);
public myFunction(){...}
And MyClass :
ActionScript Code:
package
{
public class MyClass
{
private var m_container:Object;
public function MyClass(container:Object=null, myFunction:String)
{
m_container = container;
m_container[myFunction];//????
}
}
}
Targeting A MC With A Variable
A silly question maybe. I'm using a variable in the html-code to be able to manipulate my swf. I would like to jump to a certain frame-number or label in a MC using this variable.
the html code:
....VALUE="nav_home.swf?actief=2".... etc.
actief is the variable I want to use, to jump to a frame in the MC named "on".
the script I used is:
tellTarget ("on"){
gotoAndStop ("actief");
}
It is allmost to simple but I can't seem to get it working. All the other functions -using the same variable- work!
Thanks
Targeting A Variable MC
I am trying to create a situation where the release of a button will tell a MC to play a "fade in" sequence and also tell a previously selected MC to play a "fade out" sequence.
I currently have it working this way ... when the "fade in" sequence is complete, the variable "current" is set.
stop();
_root.current = "MC2";
Targeting With A Variable Name
hi
i used to do this easily with
tellTarget (variable name ) {
}
back in the day - but am finding it a bit tricky with mx.
Ive set up the variable "flashpic" which is a target path with a random number "chosenpic" at the end
flashpic = "_root.loadingimgs.flasher"+chosenpic;
ive tried
flashpic.gotoAndPlay(2);
but that just tries to target something called flashpic - how can i get flashpic variable to be the target?
any pointers
duncan
Targeting A Variable
I'm having a syntax issue targeting a variable inside a loadVars object. I have a loadVars object called "tipTxt" that has loaded text inside of it. the loaded text has variables named "title_1" etc. separated by a "&".
I also have another variable that randomizes a number between 1 and 10 called "tip".
I'm tring to create a new variable called "myVar" that targets the tipTxt object and picks a random "title". My code is as follows:
myVar=tipTxt.title_+tip;
I want "myVar" to equal "title_'random number between 1 and 10' " It's not working. I think it's just a syntax issue. Any ideas what I might be doing wrong?
Targeting Variable Mc's
I've tried everything. Help would be greatly appreciated!!
Question: How do you target a movieclip instance that was named with a variable? eg...
whichPic=1;
Pictures=10;
--frame2
onEnterFrame = function()
{if(_root.whichPic<_root.Pictures)
{attachMovie("Picholder", "Picholder"+_root.whichPic, _root.Depther);
gotoAndPlay(3);}else{stop();}
--frame3
???"Picholder"+_root.whichPic._set_some_type_of_pr operty???
_root.whichPic++;
_root.Depther++;
gotoAndPlay(2);
Function -targeting Problem
Hi,
I have the movie with multiple movieclips, where I want to create textfields using the function on the root:
stop();
var va37 = "test";
function showCaption() {
this.createTextField("mytext", 0, 10, 100, 120, 20);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
mytext.background = true;
mytext.variable = "";
myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
myformat.underline = false;
mytext.text = _root.va+(getProperty(this, _name));
mytext.setTextFormat(myformat);
}
I planning to name these clips like 1, 2, 3, and load corresponding variable values into the text fields created by this function. But there is no success at all.
Please help!
Targeting A Function In A Frame
Hi,
I have a frameset which makes one frame called "main" (commonly used for domain forwarding). The html of "main" contains a flash movie and a javascript function that is called by the flash movie using getURL().
It all works fine on mac but on pc IE the getURL can not seem to find the function when I load the frameset url (it works fine if I load the frame directly).
I've tried using getURL(url, "main") and getURL(url, "_self") but it still won't work when the frameset html is loaded into the browser.
I'd really appreciate any help.
Cheers,
Mo
Targeting A Function From Loaded Swf
hi,
I have the following function on the first frame of an swf:
Code:
function loadControl(mov2load, section_title) {
_root.informer.bytesLoaded = 0
_root.informer.bytesTot = 0
_root.informer.percent = 0
_root.tint_mc.gotoAndStop(2);
trace("CALLED");
_root.displayer.stop();
//
duplicateMovieClip(_root.copier, "holder", 100);
_root.holder._x = 1000;
loadMovie(mov2load, _root.holder);
//
_root.informer.onEnterFrame = function() {
bytesLoaded = _root.holder.getBytesLoaded()/1000;
bytesTot = _root.holder.getBytesTotal()/1000;
percent = int((bytesLoaded/bytesTot)*100);
trace("bytesLoaded = "+bytesLoaded);
trace("bytesTot = "+bytesTot);
trace("percent = "+percent);
_root.indicator._x = 796;
_root.indicator_2._x = 796;
_root.indicator._width = percent;
_root.displayText.text = "Loaded "+int(percent)+"% of "+section_title;
if (percent>=100) {
_root.displayText.text =""
_root.doneLoading(mov2load);
delete this.onEnterFrame;
}
};
}
This is to load in an swf into a holder clip off screen, and then load it into the display clip when loaded.
This works fine when calling the function from the main swf, but when I try to call the function like from the swf files that I load in it calls it but the traces on the 'onEnterFrame' function loop out 0 for all the preload values.
I am calling in the function from the loaded swf's like this:
Code:
_parent._parent._parent.loadControl("clothes.swf", "Moose");
Can anyone tell me what is wrong with the onEnterframe part (or others)
Thank you
Targeting Asfunction Function
Hi,
how can I use a relative path to target the function I'm using with asfunction..
I've noticed that I could use an absolute path to the function, like this.
code:
<A HREF="asfunction:_root.MyFunc,Foo ">Click Me!</A>
But I can't use a relative path, like.
code:
<A HREF="asfunction:this._parent.MyFunc,Foo ">Click Me!</A>
I need to use a relative path..
Thanx
Targeting A Nested Function
I have a script that uses a dynamic nested function, but can't seem to target it:
PHP Code:
// this works:
var theFunction:String = "alpha";
this[theFunction].apply(null);
function alpha():Void {
trace ("alpha() called."); // traces -> alpha() called.
}
// this doesn't work:
function outerFunction():Void {
trace ("outerFunction() called."); // traces -> outerFunction() called.
var theFunction:String = "nestedFunction";
this[theFunction].apply(null);
function nestedFunction():Void {
trace ("nestedFunction() called."); // nothing traces; why?
}
}
outerFunction();
Thanks in advance for the help.
Targeting Different Movieclips With Same Function
I need to use this same function over and over again but changing what movieclips are targeted
function hotdog(rate) {
_root.yChange = Math.round(40-_root.a._height);
_root.xChange = Math.round(40-_root.a._width);
_root.xMove = Math.round(_root.xChange/rate);
_root.yMove = Math.round(_root.yChange/rate);
//i have tried using this._width....but
//it screws up b/c it is relative to the stage
//what i really need to know is how to use
//a movieclips target path as a parameter
_root.a._width += _root.xMove;
_root.a._height += _root.yMove;
_root.a1._width += _root.xMove;
_root.a1._height += _root.yMove;
_root.a2._width += _root.xMove;
_root.a2._height += _root.yMove;
_root.a3._width += _root.xMove;
_root.a3._height += _root.yMove;
}
i have tried adding another parameter
hotdog(3, _root.a._width);
but that doesn't work
any suggestions?
Targeting An MC In A Function Parameter
I have created a function with the parameter "target" which is designed to target individual MCs.
function maskMove (target) {
_root[target]._y = 500;
}
I'm calling the function within a setInterval.
maskController = setInterval (maskMove, 100, "mc1.mask");
The "mc1.mask" isn't able to target the MC...not sure how to script the parameter so it can target individual MCs (mc1.mask, mc2.mask). The actual script is more complicated so I was hoping not to have to break the scrpited into more parameters.
Does anyone know a simple work around?
Problems Targeting Function Within MC
Hullo, I am trying to start and stop an animation from outside of the main timeline. I have written the functions inside the movie to start and stop the animation and they work fine when called from within the movieclip but when I call them from the maim timeline I get nothing. I have checked the targeting is correct and can't think what this is!
If anyone could help I would be really really grateful.
I've attached an fla to show you what i mean!
Thanks
Schm
Trouble Targeting A Function
ok so basicly what i want to create is a random card dealer.
to start i want to deal 18 cards, but one at a time.
here is what i have so far:
ActionScript Code:
nextcard = function () { this.onEnterFrame = function() { if (Math.round(this._x) == this.destX && Math.round(this._y) == this.destY) { //======================================================= _parent[this.myNextCard].nextcard(); //======================================================= delete this.onEnterFrame; } else { this._x = this._x+(this.destX-this._x)/5; this._y = this._y+(this.destY-this._y)/5; this._rotation = this.rmax+(this.destY-this._y)/5; if (this._xscale>=100) { this._xscale -= 15; this._yscale -= 15; } } };};for (var i = 0; i<18; i++) { item = _root.attachMovie("card", "card"+i, i); item.myNextCard = "card"+(i+1); item._x = 0; item._y = 0; item._xscale = 200; item._yscale = 200; item.destX = Math.round(Math.random()*Stage.width); item.destY = Math.round(Math.random()*Stage.height); item.rmax = Math.round(Math.random()*225); if (i == 0) { item.onEnterFrame = function() { if (Math.round(this._x) == this.destX && Math.round(this._y) == this.destY) { //======================================================= _parent[this.myNextCard].nextcard(); //======================================================= delete this.onEnterFrame; } else { this._x = this._x+(this.destX-this._x)/5; this._y = this._y+(this.destY-this._y)/5; this._rotation = this.rmax+(this.destY-this._y)/5; if (this._xscale>=100) { this._xscale -= 15; this._yscale -= 15; } } }; }}
the first card comes out, but i cant seem to attach the nextcard function to [myNextCard].
is there a better way to pace this? or am i just targeting the function incorrectly?
Problem With Targeting A Function
I'm trying to call a function (comeon()) that is in a loaded movieclip (haitch), loaded into level3.
I thought _level3.haitch.comeon(); would do it but it doesn't seem to work, and I've even tried built in functions (play()) to see if I can target the loaded movieclip with no success.
Any ideas?
Code for the holder swf:
Code:
var haitch:MovieClip = this.createEmptyMovieClip("haitch", 3);
haitch._x = 484;
haitch.loadMovie("hbox.swf");
_level3.play();
The swf loads in fine, but I can't target it.
Targeting Variable From Loaded Swf
I am trying to target a variable from a loaded swf like this :
BUTTON #1:
on (release) {
section = "celebrex";
_level99._root.play();
}
BUTTON #2:
on (release) {
section = "bextra";
_level99._root.play();
}
In _level99 I have another action which recognizes the variable and loads another appropriate swf like this :
if (_level1.section == bextra) {
loadMovieNum("subfiles/HomeBextra.swf", 3);
} else if (_level1.section == celebrex) {
loadMovieNum("subfiles/Homecelebrex.swf", 2);
}
_level99 loads properly but neither _level 2 or 3 loads after that, as if the variable isn't being recognized. Can anyone help with this ?? Thanks in anvance.
Targeting Instance With A Variable
hey there
I know this is pretty simple but i can't seem to get it!
i am trying to get the current section which is the string variable sectionNum, to gotoAndPlay UNFADE, which closes the section, before going into the new section. I am not sure what the syntax is for expressing an instance name as a variable.
help if you can! thanks much. this is what i have now:
on (release) {
[sectionNum].gotoAndPlay("UNFADE");
gotoAndStop("m05");
sectionNum = "m05";
}
Variable/Targeting Troubles
I have three buttons on the stage (buttonOne, buttonTwo and buttonThree), three animations (animationOne, animationTwo and AnimationThree) and the following code in frame 1 of the main timeline:
Code:
var activeButton:MovieClip = null; ///
buttonOne.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
buttonOne.addEventListener (MouseEvent.CLICK, clickHandler);
buttonTwo.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
buttonTwo.addEventListener (MouseEvent.CLICK, clickHandler);
buttonThree.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
buttonThree.addEventListener (MouseEvent.CLICK, clickHandler);
function overHandler(event:MouseEvent) {
var target:String = event.currentTarget.name.substr (6);
var targetAnimation:MovieClip = MovieClip (getChildByName("animation" + target));
targetAnimation.gotoAndPlay ("fadeIn");
}
function clickHandler(event:MouseEvent) {
if (activeButton != null) {
activeButton.mouseEnabled = true; ///
}
var target:String = event.currentTarget.name.substr (6);
var targetAnimation:MovieClip = MovieClip (getChildByName("animation" + target));
targetAnimation.gotoAndStop ("active");
var targetButton:Object = Object (getChildByName("button" + target));
targetButton.mouseEnabled = false;
activeButton = targetButton;///
}
I'm having issues with changing the info held by the variable activeButton. The code utilizing the variable has been marked by "///". Trying to make the jump to AS3 so any input on all aspects of the code would be appreciated.
I think my issue is in the output provided by event.currentTarget and being used to AS2 to easily compile information held by a variable...but I was probably sliding on non-perfect code...because is I delete ":MovieClip" after where the variable "activeButton" is initiated the code works, but I read it's bad practice to do this.
Problem Targeting My Mc Using Variable ?
Hello, i have all my code working apart from this and it makes no sense. It has stopped me in my tracks. been using flash for a few days, but know a bit about other languages so understand variables, loops etc.
I am storing the name of a movieClip in a variable...
_global.firstturned = this._name;
In another movieClip i then target it (unsuccessfully) using
firstturned.gotoAndStop(1);
have also tried putting _level0. _root. and _parent in front. ..but this doesn't work.
I am using trace command (in both MCs) and it picks up the variable correctly. So _global variable 'firstturned' defo contains 'card3b'. I have also made sure that i can in fact make the mc play frame 1 of the other mc, by using [ _root.card3b.gotoAndStop(1) ] It all works fine, but for some reason I can't put the variable inside the gotoMC command.
I'm losing my mind here, it all works and have been stuck for hours with this. Am I missing something? HELP PLS!! The only thing of note is that both mclips are sourced from same symbol, but are different instances...but as i said, doesn't affect anything else. Anyone know what is the correct code for this?.. or what i'm doing wrong?
Targeting A Movieclip Using A Variable
Hi there, I hope I can explain this clearly, I've made a flash video presentation which is divided up into 15 different movie clips which are like scenes or chapters. I've also built some buttons into my presentation which should allow the user to pause, jump one chapter forward or backwards and mute the background music. muting the music is fine but I'm having problems with the other 3 because I cant figure out how to target the 'chapter' movie clip from my pause button, each chapter movie clip has a unique name since the clips overlap on the stage during transitions, otherwise I wouldn't have any problems.
So what I've tried to do is set up a variable on the main timeline which changes every time a new chapter begins, so on my action layer on the frame where the new chapter begins I would have something like:
currentChapter = Chapter2;
So my pause button currently looks like this:
Code:
on(release){
_parent._parent.stop();
_parent._parent.currentChapter.stop();
_parent._parent.currentChapter.voice.stop();
_parent._parent.redwings.stop();
this.gotoAndStop(2);
}
if I trace _parent._parent.currentChapter it will return the desired value ex: Chapter2, also if I replace 'currentChapter' with 'Chapter2' and press the button while the movie is on Chapter2, it works perfect.
but I suppose the problem with my variable code is that it is looking for Chapter2 on the same timeline as my pause button and not two levels higher where it's located. I've been playing around with it for an hour trying everything I can think of, just not sure the proper way to make it read the variable and target it propery...I thought maybe if I changed my variable declaration to currentChapter = "_parent._parent.Chapter2"; but no dice, I'm out of ideas if anyone could help I'd really appreciate it.
lp
Targeting W/ Variable Woes
It seems like a simple problem. I have a MovieClip on the stage and I want to target it. After that things get more unusual. Without going into to much detail I am essentially trying to target the mc using a variable that has stored part of the name of the mc I am targeting. Take a look at the code below and hopefully you will understand what I am trying to do, and perhaps even better why it doesn't work.
The instance names of the MovieClips on my stage are box_1 and box_2. What I am trying to do is store the numerical part of that instance name in a variable, so that I can increment it over time and use the new name to refer to a seperate MovieClip named box_2. This is a very simplified example of what I actually want to accomplish but it should give the general idea.
Thanks in advance for any help.
Code:
var boxNumber:Number = 1;
var boxName:String = ('box_' + boxNumber);
trace(boxName);
boxName.x = 500;
//this.box_1.x = 500;
if (box_1.x == 500)
{
boxNumber += 1;
boxName.x = 400;
trace(boxName);
};
Targeting A Variable Inside A MC?
I have a movie clip called curtain_mc with this actionscript inside:
onClipEvent (load) {
stop();
f = false;
}
onClipEvent (enterFrame) {
if (this.f == true) {
this.nextFrame();
} else if (this.f != true) {
this.prevFrame();
}
}
On my first frame I have this:
play_btn.onPress = function() {
btnHandler();
};
var btnCounter = 1;
function btnHandler() {
if (btnCounter == 1) {
_parent.curtain_mc.f = true;
btnCounter++;
trace(btnCounter);
} else if (btnCounter == 2) {
_parent.curtain_mc.f = false;
btnCounter = 1;
trace(btnCounter);
}
}
I would like to change the variable 'f' from true and false by clicking a button but the actionscript on my keyframe doesn't recognize the actionscript in my movieclip?? I know its a targeting issue, but not sure how to alter it in order for the two to talk to each other??
Targeting A Variable (FLASH)
How do i target a variable that is on another level to the one that I am currently on?
I load a movie onto level1, then I want to use a variable on level0 in a script in the movie on level1. I have tried _leve0.checkSub == "xyz" but that does not work.
If i do a trace on the variable from level1, i get a message saying undefined. Please help.
Chris
Targeting Problems W/ An [Array / Function]
//on the _root I have the following:
companyAlphaArray = [a, b, c, d];
function fncFirstInit(array, menuItem) {
for (var i = 0; i < array.length; i++) {
menuItem.array[i].dest = eval(menuItem.alphaArray[i])._y;
menuItem.array[i]._y = menuItem.alphaArray[i].dest - 50;
menuItem.array[i]._alpha = 0;
menuItem.array[i].fill._alpha = 30;
}
}
// THEN within a Movie Clip in the _root named 'theCompany', I have 4 MC's respectively labeled a, b, c, and d. And within the first frame of 'theCompany' I have the following code to initiate the function above.
_root.fncFirstInit("companyAlphaArray", "theCompany");
//Now my problem lies, in that the MC's are NOT being targeted by the code that I have above, if anyone could make suggestions, modifications, changes, etc. in order to make this target properly, that would be GREAT! Thanks
-gr3ven
AttachMovie + Dynamic Targeting Using Function
I am building a presentation that is made up of about half a dozen smaller mc's. I've built the main shell file that has the navigation. In the main shell there is a contentMC. When the nav is clicked the shell attaches the coordinating individual mc to the contentMC on the stage. (I am using linking properties in the library for the indiv. mc's) Now how do I target that attached mc from the _root. if at all possible. I've created a function which should handle this. NewPresenationVar is set by the nav so it's available (tested using trace). My probablimatic line has the "***" around it.
function ChangeContent(frameVar,headerVar) {
// set main images keyframe to:
***_root.contentMC.NewPresentationVar.mainImages.g otoAndStop(frameVar);***
// set header text
_root.headerVar = headerVar;
// activate header
_root.border.headerMC.gotoAndPlay("go");
}
Here is the function that the nav sets :
function LaunchPresentation() {
if (PresentationVar<>newPresentationVar) {
contentMC.removeMovieClip(PresentationVar, "contentMC", 1);
trace("In Function PresentationVar = "+PresentationVar);
contentMC.attachMovie( newPresentationVar, "contentMC", 1 );
trace("In Function NewPresentationVar = "+NewPresentationVar);
}
PresentationVar = newPresentationVar;
trace("In Function Set PresentationVar = "+PresentationVar);
}
Targeting A Movie Clip Via A Function
i wish to target a movie clip that is within a function...this is what i have on frame one of the main timeline:
function myFunction(var1){
_root.var1.gotoAndStop("play");
}
and on a buttion i have something that says:
on(release){
_root.myFunction(clip1);
}
i have also tried it with clip1 in quotes...
is it something that i have to convert it to a string?
thank you...
OnRelease Function Targeting Button In Mc
I have a few buttons in a movie clip (remote_mc) on the first frame of the mc.
I have one button on the second frame of the mc (remote_mc)
From the maintimeline first frame I use this
remote_mc.mybutton.onRelease = function() {
//some code here
}
This works on the buttons in the first frame.
When I send movie clip to second frame and click button the function for that button does not work.
How do I target buttons in a movie clip (not on frame 1) from a function on main timeline.
Thanks
Targeting A Button Whose Name Is Stored In A Variable
hey all
i have a variable called 'button_name' that gets assigned the name of one of many buttons that i have on my stage, depending on different conditions. what i want to know is how can i use this variable to target the different buttons. for example, i want to call the following statement:
---
button_name.gotoAndPlay("show");
---
however, when i do this, its looking for a button called 'button_name', when in actuality what i want is to target the button whose name is *stored* in the variable 'button_name'. is there any way to do this???? thanks so much.
cheers
j
Targeting A Frame Based On A Variable Value?
I want to be able to target a specific frame of a movie clip, based on the value of a variable (set by the button a user chooses).
The Flash movie I'm creating is a jeopardy-style game, where the user clicks on a question within a certain category. I've set it up so that clicking on each button assigns 2 variables: "category" (either 1, 2, 3, 4 or 5) and "value" (100, 200, 300, 400, 500, 600). A movie clip is also loaded which I would like to jump to a frame to display the appropriate question, by targetting the frame label. I wanted to avoid manually creating 30 instances of a movie clip with different names. But I can't figure out how (or if it's possible to) target a dynamically specified frame label.
If anyone has any advice, I'd really appreciate it.
_root Function Targeting A Loaded Swf .htmlText
function showPage() {
stopAllSounds();
_level0.ui.content_area.content.loadMovie("content /" + contentItems[currentContentItem].attributes.FILENAME);
loadTxt(); //the line above loads the external swf
//I am having trouble targeting the text fields in that swf
if (contentItems[currentContentItem].attributes.audio != "") {
// create a new sound object
var soundHolder = new Sound();
// load mp3 into the sound object
soundHolder.loadSound("content/" + contentItems[currentContentItem].attributes.audio,false);
// play the sound
soundHolder.start(0,99999);
}
}
Targeting The GetURL Function To One Consistent Window ?
I have a flash site that I am building and I have pop-up windows from the main page to galleries and other pages. I create the window with the following code and subsequently needed javascript code in html.
The getURL function looks like this:
on (release) {
getURL ("javascriptpenNewWindow('galleryflash.html','th ewin','height=700,width=700,toolbar=no,scrollbars= yes');");
}
My question is....Is there a way to target the window so that all of my different getURL functions open within the same window so that my user has only two windows to deal with when using my site and not so many that they hate me and get confused and never come back?
Targeting Problem After Adding Function To Movieclip
//can some1 tell me where Im going wrong
// this targets the timeline in the 'mcImage' timeline (which is what I want)
mcImage.onRollOver=function(){
this.swapDepths(this.getNextHighestDepth());
this.gotoAndPlay(2);
}
// but when i try to make a function ( so I can reuse it) it now targets the main timeline... how do I get it to target the 'mcImage' timeline
function mOver(){
this.swapDepths(this.getNextHighestDepth());
this.gotoAndPlay(2);
}
mcVan.onRollOver=function(){
mOver();
}
Targeting / Call Back Function Problem
I'm having a problem with a movieclip that I have added a number of instances to the stage with attachMovie. On frame one of the movieclip I setup the following code :-
this._alpha = 10 ;
this.onMouseDown = function() {
trace("down");
}
stop();
The problem is that I add 6 instances to the stage but when I click on one of the movieclips they all trigger the event function i.e. the output displays down 6 times.
I hope I have explained this clearly. Thanks in advance
Targeting Variable Text Fields In Movie Level 1...
How do I target a dynamic text field called 'box_text' sat in a movie clip called 'mouse' that is in a movie 'mouse.swf' I have loaded into level 1?
I need to be able to update the text within a mouse tool-tip / help box as it rolls over a diagram. The loaded movie clip is loaded in level 1 and all of the dynamic text box and surrounding graphics is within a movie clip called 'mouse' that is dragged around the screen by the user.
At the moment I am using:
with (_level1) {
mouse.box_text = "Welcome";
}
[F8] [AS2] Access An Instance Variable From Within A Function Within Another Function
So here is the scenario that has completely stumped me. I have a class, within the class a function and within that function an xml onload handler. So herein lies the problem, I need to store the array of values that I receive from the XML into an instance variable belonging to the class. How can this be achieved?
To illustrate:
Class A {private var values:Array;public function getValues():Void{Xml sendandload code here.xmlReply.onLoad = function(){iterate through xml code and generate array of values.Store this array back into values belonging to class A}}}
using the variable straight up doesn't work.
if I use "this" it refers to the onload function, not the class.
i tried creating another class method called setValue and calling this.setValue(arr) and setValue(arr), but neither of those work.
i even tried combinations of _parent and this, still no go.
The only way I can get it to work is to make reference to _root.class.value, but this is not solid code and is very impracticale, especially if what calls the class doesn't happen to be in the root of the file.
Any ideas would be appreciated.
[Help]Class Function As Function Variable And Using 'this'
Hi, its me again!
I met with a problem now. I was trying to implement the Merry-go-round tutorial in OOP. I created a class, had a function exactly like displayPane function. But here's the problem. The 'this' in displayPane is pointing to the class I created. Not to the object I was about to pass this function to. I thought of maybe static will help. But after some more thought I find out that I need to access some of the class object data i created. This really leave me with a hard time. How can I tell AS to point the this to the object I was about to pass this function to. Is there's any possibility to pass in parameters value while you passing function reference to a variable? (I don't there's this possiblity right)
Thanks in advance. Any help is appreciated.
Pass Variable Function In Function
I'm counting how many elements are are in my XML tree and then adding a button and changing the postioning. I can load the info in perfect, but when I try and pass the color variable to the button function things start to screw up.
PHP Code:
var theXML:XML=new XML();
theXML.onLoad = function()
{
buttonx=10;
nodes=this.firstChild.childNodes;
//trace(nodes.length)
for(i=0; i<nodes.length; i++)
{
newname="button"+i;
_root.mc5.attachMovie("button", newname,20+i);
_root.mc5[newname]._x+=buttonx*i;
new_color=nodes[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
newname="button"+j;
mc5[newname].onPress = function (new_color)
{
end_color=int(new_color)
doBlend = 1;
set_interval=setInterval(interval_function,1);
return end_color
}
}
}
theXML.load("xml.php");
I'm totally stumped. Any ideas?
How To Put External Variable's From PHP Into Variable's In A Function
I already echo my variable's the right way. I want to make it possible to adjust collors trougout my database. This is what my PHP file echos:
&homecolor=33ff33&newscolor=000000
this is how my PHP file looks:
PHP Code:
<?php
require("connection.inc.php");
$query = "SELECT name, color FROM outlinecolors";
$result = mysql_query($query);
while(list($name, $color) = mysql_fetch_row($result)) {
print("&$name=$color");
}
?>
This way of using PHP also works for the text I use in my movie, which I let flash put in a dynamic textfield. So I tought that it should be possible to have the variable colors above being used in the next function:
code:
home_btn.onRelease = function() {
outline.fadeColor(homecolor, 100, tweensspeed, test);
};
"homecolor" is the place where the value/echo from php must come (&homecolor=33ff33) so "33ff33" must be in the function in stead of homecolor.
Can anybody help me?
Greets..
Flash 4 Actionscript - Using A Variable In The Function Go To And Stop ("variable")
Sorry to take everyone back to Flash 4, but I have a question about using the Go to and stop command to go to a label in a separate movieclip. Basicly it is like this:
I have a thumbnail movie, each thumbnail has a button over it which sets a variable _level0:ITEMNO per each thumbnail.
I also have a fullsize movie, with several fullsize images that correspond with the thumbnails. Each image is on it's own frame with a label name which is it's item number (ITEMNO).
I want the fullsize movie to Go to and stop ("_level0:ITEMNO")
please help.
Variable + Function ?
The goal > an input text field and a small button next to it - the user types a url into the text field and clicks the button - he/she is taken to that url.
so i set the text field as variable "url" then tell the button to somewhow get the value of "url" and go to it? is this right? something along the lines of this maybe
any info on how i can do this, or directions to a tutorial that deals with this specifically would be very nice
Function And Variable
Hi
May be that's a simple question, but I need to understand it. I have a function. Inside this function I want to create a new variable. If I do it like this -> var iSec2 = this.iGetSec % 10; it does not work. I don't understand why I can not initialize a variable in a function on one line and give it a value.
I can do -> var iGetSec; this.iGetSec = this.iGetSec % 10;
or I can do it without the var, just using
this.iGetSec = this.iGetSec % 10;
So I just want to know why. Cause if i'm outside the function I can initialize a variable and give it a value in the same time but not in the function.
// this.iGetSec % 10; is a value that cahnge each time the function is called.
tanx
Variable In A Function?
Hi,
in a function I need to do som action only once that is only the first time this function is called.
I tried the following :
Function Functionname(){
if (_level0.StatesAreIn==null) {
set (_level0.StatesAreIn,true);
GetStates();
}
}
and also:
Function Functionname(){
if (StatesAreIn==null) {
set (_level0.StatesAreIn,true);
GetStates();
}
}
In both cases GetStates is performed ALL the times the function is called.
What am I doing wrong?
Getting A Variable Out Of A Function
How do i get the variable news_compiled out of this function, ie in a different movie clip
PHP Code:
var news_compiled;
var newsXML = new XML();
newsXML.ignoreWhite = true;
newsXML.onLoad = processnews;
newsXML.load("news.xml");
function processnews(success) {
rootHandler = this.childNodes;
nodeHandler = rootHandler[0].childNodes;
nodeHandler.reverse();
if (nodehandler[0].nodename == "news") {
for (var i = 0; i<nodeHandler.length; i++) {
childHandler = nodeHandler[i].childNodes;
news_date = childHandler[0];
headline = childHandler[1];
body = childHandler[2];
news += news_date+"<br><font color='#2D01FE'>"+headline+"</font><br>"+body+"<br><br>";
}
news_compiled = "<b>News</b> <br><br>"+news;
} else {
news_compiled = "Load Error";
}
}
Get A Variable Out Of A Function
so i have a function getting info out of an XML page and there is a variable "i" that is in a for loop that keeps track of the number of lines in the XML page....but i cant call that variable out side of the function....how do i get the value of the variable out of the function
some one help me please....i know its something simple but cant put my finger on it...also i tried global variables with no luck
eddie
[F8] Using A Variable From A Function
I have a varialbe declared in a onPress function i want to be able to use in a different onPress function but i am not able to get this correct....
i have two buttons (pause and play) when a user pauses the sound i want to get a var with the current position of the sound file so i can play the sound file from the appropriate location with my Play button, i have:
//Pause the sound
_root.btnPause.onPress = function() {
var my_sound_position:Number = my_sound.position;
trace(my_sound_position + "in pause");
my_sound.stop();
stop();
}
//Play the sound
_root.btnPlay.onPress = function() {
_root.my_sound.start(_root.btnPause.my_sound_posit ion);
trace(my_sound_position + "in play");
play();
}
the trace for the Pause is correct, but the trace in the Play outputs nothing for the my_sound_position.
ive tried like: _root.btnPause.my_sound_position also and nothing.
how do i use one var in the onPress of one button in a onPress function of a different button???
[F8] Using A Variable From A Function
I have a varialbe declared in a onPress function i want to be able to use in a different onPress function but i am not able to get this correct....
i have two buttons (pause and play) when a user pauses the sound i want to get a var with the current position of the sound file so i can play the sound file from the appropriate location with my Play button, i have:
//Pause the sound
_root.btnPause.onPress = function() {
var my_sound_position:Number = my_sound.position;
trace(my_sound_position + "in pause");
my_sound.stop();
stop();
}
//Play the sound
_root.btnPlay.onPress = function() {
_root.my_sound.start(_root.btnPause.my_sound_posit ion);
trace(my_sound_position + "in play");
play();
}
the trace for the Pause is correct, but the trace in the Play outputs nothing for the my_sound_position.
ive tried like: _root.btnPause.my_sound_position also and nothing.
how do i use one var in the onPress of one button in a onPress function of a different button???
|