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




Whats The Syntax For Doing Multiple MC Functions On One Line?



like...


Mc1.onRollOver , Mc2.onRollOut , Mc3.onRelease = function(){
lalalalala
}


So all of those do the same thing without having to create many lines?

cause i have a long list things I want it to do, but dont wanna make the list multiple times if i dont have to..

I have it in a function right now, but im curious if you can do that up there.



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-07-2006, 12:28 AM


View Complete Forum Thread with Replies

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

Whats Wrong With The Syntax?
im using mx 2004

}
on (release) if (_root._currentframe == 47 ) {
_root.gotoAndPlay(10);
}

47 is a frame number in the main movie as is 10.

Whats The Correct Syntax?
I have a function that I want to use for all my menus:


ActionScript Code:
function button(menuvar){      trace(menuvar);       _root.menuvar.gotoAndPlay("open");}


So if I call the function from a rollover I can send the menu name as a parameter to the function.


ActionScript Code:
on (rollOver) {    _root.button("aboutmenu");}


However, its not working. When I trace the variable menuvar it shows as aboutmenu. My movieclip IS called aboutmenu. If I change the target from

_root.menuvar.gotoAndPlay("open");

to

_root.aboutmenu.gotoAndPlay("open");

it does work. So I'm guessing I've got the syntax wrong or I need to define the variables differently or something.

Any help would be much appreciated.

Hi...whats The Correct Syntax For Pulling My.....
Hi...whats the correct syntax for obtaining a variable from another level ?

Im having problems with level 3 not understanding the variable that sits on level one...

Ive done this before..so im feeling really dumb

Anyone ?

[F8] Syntax Error? Whats Wrong With This Class Dec?
Ok, i am simply declaring a class variable which i later assign. Now i am making a 100% AS2 Flash site (aside from images loaded obviously) just for experience, but i am having a bit of trouble when using this custom class.. it works fine.. but i cannot understand why it won't let me make the class variable type safe. Anyway, here is the little bit of code.


Syntax Error:

Code:
private var navigationManager:AS.UI.Navigation;
No Syntax Error (the "good" one)

Code:
private var navigationManager;

Now it goes a bit beyond that, technically is not even a syntax erorr so i am really confused. If i press the check syntax button, it says no syntax errors. Nor does it say any syntax errors in any of my classes. But in that one class that is declaring the variable above, if i press auto format, it says there is a syntax error.. even though the syntax checker says there isn't.

I'm a bit confused.. any ideas?

[f8] Xml, As, Functions - Whats Up
Hi all,

I've been working on this for a while, I'm very new to flash and xml..

I've been trying to change a flash xml playlist to play when the site loads, without having to click play, or any of the playlist items.

I've been told I should use a functions and then call it in.. I'm not sure what that means.

Below is what I've been given:

xml.onLoad=function(){
startPlaying(this)
}


I put this into flash in both my XML layer, and my Sound layer. nothing happend.. I'm assuming I need to add to or change this function to get it to work right.

I can post all my source files as well if that will help get this issue solved.

http://ezekieldesign.com/clientprevi.../wowhmyns.html - here's what I'm working on.. You'll notice you have to click on the track to get it to pull the Nodes data, including the song.

thanks!

Whats The Deal With Functions?
The script below can have the bringAnimal callback before the function declaration and after it. However the animal="dog" has to be declared before the callback.

is there anything else important I should know?


ActionScript Code:
animal = "dog";
bringAnimal();
function bringAnimal() {
    //trace("section1[0] "+section1[0])
    trace("animal "+animal);
}

Functions And Syntax
Hello

I am basically trying to optimise some code so I dont have to copy and paste over and over, by trying to turn it into a function I can call at will.

I am having trouble with the syntax to make it work.

Here is my code that works fine and that I want to make extensible.


Code:
var aTrueCount:Array = new Array();
trace("true count = " +(aTrueCount.length));

mcButholder.mcBut1.onRelease = function():Void{
var bButton1Status:Boolean = true;
aTrueCount.push("but1")

trace("true count = " +(aTrueCount.length));

mcButholder.mcBut1._visible = false;
mcButholder.mcBut1clicked._visible = true;

if(aTrueCount.length == 2){
gotoAndPlay();

}
};
So I am putting all this into a function and hoping to change all instances of 1 into 2,3,4... ect by changing the functions argument/parameter.

Where I am having trouble is the syntax to join it all. For example. This is my attempt.


Code:
function buttonChecker(mcID:Number):Void{

mcButholder.mcBut[mcID].onRelease = function():Void{
var bButton[mcID]Status:Boolean = true;
aTrueCount.push("but"+[mcID])

trace("true count = " +(aTrueCount.length));

mcButholder.mcBut[mcID]._visible = false;
mcButholder.mcBut[mcID]clicked._visible = true;

if(aTrueCount.length == 2){

gotoAndPlay(5);

}
};
}
I dont know if what i'm trying even makes sense. Just wanting to give it a go and it's getting frustrating that its probably down to syntax.

I hope that I'm being clear and that someone can help
thx if you can
.....
ceez

Reading Textfield Line By Line ? Selecting Multiple Textfields At Once ?
OK i need some serious help/advice !

I`m trying to make a sort of program like word , i want to have a text field , but the problem comes when i want to create like borders around each line of text and have DIFFERENT background colors for each line.
So i was thinking if i can read line by line and get get the height of each line by examining char by char for it's size and get the biggest one ( since my text may have different fonts sizes ect on a single line) and then have like BLOCKS that are behind each line and adjust their sizes accoring to the line size and change their color also.

Also another thing that I would also want to do , i want to create a table which i did , but now how do i put the table into my text ...and not just lie on top blocking text behind it ..how do i like "push" the text around it ?? ANY IDEAS would help...thats why i thought maybe create lots of textfields just stacked from top to bottom..but then i will have the problem of selecting them all at once like in a REAL word processing problem...and also if the text becomes too big it will need to "flow" into next textfield...

Is there ANYWAY to do this ??! HELP ME!!!!

THANK YOU

Whats Wrong With This Line Of Script?
onClipEvent (load) {
reftime="2";
q = random(999999);
loadVariablesNum (http://www.website.com/cgi-bin/ref.asp?q=+q, 0, "POST");
}



whats wrong with the last line?, (apart from the obvious site name )

this bit //www.website.com/cgi-bin/ref.asp?q=+q, 0, "POST");
appears grey where as before it was blue as ...(
ref.asp?q=+q, 0, "POST");)

cheers

Functions + Components +syntax
So i have a function setup called
Get1();

I have a Component setup that has a parameter called
imageNum
(this parameter is used to attach an exported symbol from the library)

Functions + Components +syntax
So i have several functions setup called:
Get1();
Get2();
Get3();
etc.

I have a Component setup that has a parameter called:
imageNum

(this parameter is used to attach an exported symbol from the library)

For a certain action i'm trying to create, i need the imageNum value to become the number for one of the 'Get' functions.

ie, Get[imageNum]();

Here is exactly what i'm doing so far:

on (release){
i = (Number(Imagenum));
_root.Get[i]();

}

the component's 'Imagenum' value is '1'

I think my prob is in the 'Get[i]' part, but really not sure.
Can anyone help? have i been clear?
thanx

Functions Path/syntax Help
The functions on this MC worked fine when on the main timeline...

I exported the MC as a swf and am loading it via createEmptyMovieClip, now the only parts I can get to work are the bplay(); and bstop(); functions.

I have my trusty O'Reilly books, but have not had much luck.

tab, pbar, bplay and bstop need to control the mainContent_mc.mainContentHolder

Im a graphic designer learning as i go...thanks


Code:
function getRange() {
startMovie = 1;
endMovie = _root.mainContent_mc.mainContentHolder._totalframes;
startBall = pbar._x;
endBall = pbar._x+pbar._width-pbar._width;
MouseRange = endBall-startBall;
PanRange = endMovie-startMovie;
}

function myProgress(t) {
var r = (_root.mainContent_mc.mainContentHolder._currentframe-startMovie)/PanRange;
r = Math.max(0, Math.min(1, r));
t._x = (Math.round(r*MouseRange+startBall));
}

this.tab.onEnterFrame = function() {
t = this;
getRange();
myProgress(t);
};

this.tab.onPress = function() {
getRange();
delete this.onEnterFrame;
this.onEnterFrame = function() {
this.startDrag(false, pbar._x, this._y, pbar._x+pbar._width-tab._width, this._y);
var r = (this._x-startBall)/MouseRange;
r = Math.max(0, Math.min(1, r));
_root.mainContent_mc.mainContentHolder.gotoAndStop(Math.round(r*PanRange+startMovie));
};
};

onMouseUp = function() {
delete this.onEnterFrame;
stopDrag();
getRange();
this.onEnterFrame = function() {
t = this;
myProgress(t);
};
};

this.bplay.onPress = function() {
_root.mainContent_mc.mainContentHolder.play();
};
this.bstop.onPress = function() {
_root.mainContent_mc.mainContentHolder.stop();
};

Functions And Variable Syntax
This is a quick one...


I am looping to find the name of 1 of my 12 movieClips.


Code:
for (x=1; x<=12; x++) {
_root["mc"+x].alphaTo(100, x*.10, "linear", x*.10);
_root["mc"+x].onEnterFrame = function() {
this.onRollOver = function() {
this.i += 2;
this.swapDepths(this.i);
this.scaleTo(154, .75, 'easeOutElastic', 0);
this.gotoAndStop("sub");
HERE IS WHERE I WANT TO ADD CODE: ["mc"+x]Move();
};
this.onRollOut = function() {
this.scaleTo(100, .25, 'easeOutBack', 0);
this.gotoAndStop("main");
};
};
}

function mc1Move() {
something for the funtion
}

function mc2Move() {
something for the funtion
}
I want to add a function call based on the name of the clip that is "this" at the time. And I want it to call its variable named function.

Does this make sense?

Syntax On This One Line
I'm having trouble figuring out how to write this line so it works:
PHP Code:



var fish1 = fishScroller.addChild(new fishArray[0].creature);




I get this error:
Code:
TypeError: Error #1115: creature is not a constructor.
at Fish_ID_fla::MainTimeline/frame1()
I'm working my way one step at a time. This will eventually end up in a for loop placing all my images.

Multiple Functions Or Long Functions With For.. Statements?
Which is better? A long function with a couple of for... statements, or multiple functions with only one for... statement in it?

Andy

Whats This Extra Line For 2points Of LineTo()
hello fellows!!
well i was experimenting on the lineTo() function to make 3d cube, but unfortunately something is troubling!!! i expect the following figure:-

i made eight points...

1 +------------------+
/| /|
/ | / |
/ | / |
+-------------------+ 2 |
| | | |
| | | |
| | | |
| 3 +-------------|--- +
| / | /
+-------------------+4
but a line from (1 to 2) and (3 to 4) is automatically drawn.. how should remove those lines!!! Plz help

Syntax For Writing Parameters With Functions In As2
hello, i have always had this problem with as2 and its very frustrating. When passing parameters in function it always gets messed up

heres what i have:


ActionScript Code:
function passFunction(someString) {
     trace(somestring);
  }

now i have for example on the buttons


ActionScript Code:
for (i=1; i<= 5; i++) {
     _level0["someButtom" + i].onRelease = passFunction("someVariable"+i);
   }

this normally gives me different outputs or just the last i so anything i click on becomes someVariable5

now if I had put those actions on the buttons it would have worked, so for example


ActionScript Code:
on (press) {
    passFunction("someVariable1");
  }

why does this work and the first example not, how do i send parameters with functions?

Syntax Error In This Line?
Is someone able to see where I am going wrong in this syntax? It needs to read like this:
loadMovie(myWord1.thumb, _root.winPlacer.thWin1.placeThumb);
Where this myWord1.thumb is to get the value "thumbs/alex1.jpg"

This is how I have written the code:

ActionScript Code:
loadMovie(myWord[_root.testMyWords].thumb, _root.winPlacer.thWin[_root.testMyWords].placeThumb);

//This is what I have as the variable...
var myWord1:Object = {cat:"word", word:"And", thumb:"thumbs/alex1.jpg", file:"videos/And.flv"};

Thank You,
-Kirk II

Why Does This Line Give Me A Syntax Error?
why does this line give me a syntax error? it works in the sample code but not in my application

**Error** Symbol=page 1 cont 1, layer=Layer 1, frame=1:Line 5: Syntax error.
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();

Total ActionScript Errors: 1 Reported Errors: 1

AS:code below?

this.createTextField("my_txt", 1, 100, 100, 300, 100);
my_txt.multiline = true;
my_txt.wordWrap = true
my_txt.html = true;
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();

myStyle.onLoad = function(done){
if(done) {
var exampleText = "<p class='headline'>Tutorial Takes Forever To Write</p>";
exampleText += "<p><span class='byline'>Bath, UK</span>";
exampleText += "--Flash developer NWebb seemed to take ";
exampleText += "forever to finish his CSS-Flash tutorial, ";
exampleText += "but it is finished now and you can find it ";
exampleText += "<a href='http://www.nwebb.co.uk'>here</a> ";
exampleText += "along with a few others.</p>";
my_txt.styleSheet = myStyle;
my_txt.htmlText = exampleText;
} else {
trace("there was an error");
}
}
myStyle.load("example.css");

Can You Find The Syntax Error In This Line?
Is someone able to see where I am going wrong in this syntax? It needs to read like this:
loadMovie(myWord1.thumb, _root.winPlacer.thWin1.placeThumb);
Where this myWord1.thumb is to get the value "thumbs/alex1.jpg"

This is how I have written the code:

ActionScript Code:
loadMovie(myWord[_root.testMyWords].thumb, _root.winPlacer.thWin[_root.testMyWords].placeThumb);

//This is what I have as the variable...
var myWord1:Object = {cat:"word", word:"And", thumb:"thumbs/alex1.jpg", file:"videos/And.flv"};

Thank You,
-Kirk II

Syntax To Call Frame In Mc Time Line
I need to target a frame of a mc I'm loading.
Im using this
on (release) {
gotoAndStop(7);
ph.loadMovie("mensproduct.swf");
to get to the movie but I can't figure out how to get to a specific frame of mensproduct.swf. thanks

How To Make Undo And Redo Command For Draw Line Syntax?
http://doc.gold.ac.uk/~ma101hmf/Proj...icalLevel2.swf

http://doc.gold.ac.uk/~ma101hmf/Proj...icalLevel2.fla


I have a program which allows user to draw the character on the box. At the moment, I have only created a clear button which is used to clear the content for the box. I want to make another two buttons which can provide the function of Undo and Redo.

Anybody know how?

The following is my code for drawing and clearing the content


onClipEvent (load) {
currentColor = "FF0000";
_root.createEmptyMovieClip("copyBox", 100);
function draw() {
_root.copyBox.lineStyle(5, parseInt(currentColor, 16), 100);
x = _root._xmouse;
y = _root._ymouse;
_root.copyBox.lineTo(x, y);
}
function clearCopyPaper() {
_root.copyBox.clear();
}
}
onClipEvent (mouseMove) {
updateAfterEvent();
if (down && _root.copypaper.hitTest(_root._xmouse, _root._ymouse)) {
draw();
}
}
onClipEvent (mouseUp) {
down = false;
}
onClipEvent (mouseDown) {
if (_root.copypaper.hitTest(_root._xMouse, _root._yMouse)) {
x = _root._xMouse;
y = _root._yMouse;
_root.copyBox.moveTo(x, y);
down = true;
}
}

Whats The Best Way To Preload Multiple SWF's At Once.
Hey guys,

To be honest never came across this problem before.

Shaun.

CustomVideoPlayer.as, Line 196 1084: Syntax Error: Expecting Identifier Before Rightb
I received feedback on Flash AS 3 related issues on this site in the past so i am back for more knowledge....Any help / suggestions are appreciated.

Problem.

My client has sent me .swf files that are to be redone ... the problem is the original developer did not leave the .fla file so I am using a flash decompiler (*******)... I'm getting a bunch of funk code...

I am receiving one of several error messages... hope the first error will fix the others...

here is the error message(1):

CustomVideoPlayer.as, Line 196 1084: Syntax error: expecting identifier before rightbrace.

here is the action script:

line 194: var _loc_3:* = event.info.code;
line 195: switch(_loc_3 === "NetStream.Buffer.Full" ? (1) : (_loc_3 === "NetStream.Play.Start" ? (2) : (_loc_3 === "NetStream.Play.StreamNotFound" ? (3) : (_loc_3 === "NetStream.Play.Stop" ? (4) : (_loc_3 === "NetStream.Seek.Notify" ? (5) : (Jump to 23)
line 196: }// end try

I have been working on solving this problem all day with no solution... but great suggestions from developers.

I have changed the above statement from a "switch" to a "if" statement ... not too familiar with (Jump to ...) so I removed it because it just did not look correct ... and removed the colons to semi-colons ... but I am still receiving the same error message
"Re: 1084: Syntax error: expecting identifier before rightbrace."

I can post or email the project files if that will help.

Multiple Line Connections Between Multiple Objects
Hi

I have come across a number of flash movies dynamically connecting a line between 2 objects. where if either object is moved the line connection is maintained.

My application area is a circuit board where users wire up a number of instruments to a number of connection points.
What i need to do is recreate the effect above but allow a user to drag connectors from terminals on the instruments and link to a number of connection points on the circuit while maintaining the wire link in between. Effectively wiring up the circuit. When each connector from the instrument is connected to the test point, it remains in position until moved to a new point.

Is this possible

Thanks in advance

Whats The Best Way To Add Actions To Multiple Buttons?
Hi,

I have 10 buttons on 10 different keyframes, each of them needs a different instance name but they all need to have the same action, shown below:


Code:
tellTarget ("copy") {
gotoAndPlay(2);
startDrag("", true, 0, 25, 105, 200); {


What is the simplist and easiest way to add this action to each button? I'd like to know how to do it by having all the actions in one frame, rather than having to add them to each seperate button. I know this code works:


Code:
button.onRollover = function() {


But I can only get that to work for one button at a time, so I ave to copy and paste the code 10 times in the actions to do it for all the different instance names. There's gotta be a better way than that.

Thanks.

Handling Multiple Videos, Whats The Best Option?
Hi all,

I'm working on a small project that requires some video skills.

Imagine you have a normal videoclip, which you want to divide in 30 parts, like it was being shown on 30 screens.
Since it's for a website, I have some doubts about what would be the best way to handle this.

Should i have 30 small videoclips and load them all in the preloader?
Should i stream the 30 different videoclips at the same time?
Is it possible to stream the entire videoclip to a movieclip in flash and then create 30 small ones from that, using masks or copyPixels?

I'm using flash8, so i guess the sky is the limit

Thanks in advance for your help.

Whats Wrong With My Multiple Drag And Drop Code?
I've got ParaA, ParaB, and ParaC ( http://img.photobucket.com/albums/v2.../misc/para.gif ) which are dragable mc's (ie they have buttons inside them with the code below), they can be dropped onto any of the mc's Para1, Para2, and Para3.

Here's the code for ParaA button:

on (press) {

startDrag(this, true);

this.ox = this._x;
this.oy = this._y;
}

on (release) {

stopDrag();

{
if (this._droptarget == "/Para1")

{
_root.Para1.gotoAndStop(2);
}

if (this._droptarget == "/Para2")

{
_root.Para2.gotoAndStop(2);
}

if (this._droptarget == "/Para3")

{
_root.Para3.gotoAndStop(2);
}

else

{

this._x = this.ox;
this._y = this.oy;

}

}

stopDrag ();
}

When you drag ParaA to any of the mc's Para1, Para2, or Para3, it executes the relative _root.Para#.gotoAndStop(2); but only snaps to Para3. Have I missed something?

Thanks in advance.

Whats Wrong With My Multiple Drag And Drop Code?
I've got ParaA, ParaB, and ParaC ( http://img.photobucket.com/albums/v2.../misc/para.gif ) which are dragable mc's (ie they have buttons inside them with the code below), they can be dropped onto any of the mc's Para1, Para2, and Para3.

Here's the code for ParaA button:

on (press) {

startDrag(this, true);

this.ox = this._x;
this.oy = this._y;
}

on (release) {

stopDrag();

{
if (this._droptarget == "/Para1")

{
_root.Para1.gotoAndStop(2);
}

if (this._droptarget == "/Para2")

{
_root.Para2.gotoAndStop(2);
}

if (this._droptarget == "/Para3")

{
_root.Para3.gotoAndStop(2);
}

else

{

this._x = this.ox;
this._y = this.oy;

}

}

stopDrag ();
}

When you drag ParaA to any of the mc's Para1, Para2, or Para3, it executes the relative _root.Para#.gotoAndStop(2); but only snaps to Para3. Have I missed something?

Thanks in advance.

Syntax For Assigning One Value To Multiple Variables
Instead of:

function hideStuff():Void {
instance1._visible = false;
instance2._visible = false;
instance3._visible = false;
}

is there some way to do it more like:

function hideStuff():Void {
instance1._visible, instance2._visible, instance3._visible = false;
}

Basically, is there a way to shorten assigning the same value to multiple variables and/or properties?

Help With Multiple Functions
Hello again Im using Flah MX.

The effect Im trying to duplicate can be found here

http://www.thisislondonclub.com

I want to create the same sort of roller images (only vertical)

I can get one image to work and move about the stage but not multiple images.

This is what I have:

Actionscript for the function:

Code:
function moveArrow(Xcoord){
this.onEnterFrame=function(){
picone._y+=(Xcoord-picone._y)/10;
}
}
stop();
Action for the button:

Code:
on(press){
moveArrow(59.6);
}
I tried copying the code and just renameing the function but it wont go.

Can any body help me ?

Thanks in advance
Bill

[CS3] Multiple Functions
I'm trying to create two cards that flip when you click them. It works when I have only one 'Card' function but copied the code and named it CardTwo it tells me: 1120: Access of undefined property loader_mc. I realise that you can't duplicate functions but I don't think I am. I've also tried changing 'CardTwo's' types to 'typeTwo' as well as change loader_mc to loader2_mc. Please help.

package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;

public class Card extends MovieClip
{
private var _type:*;

public function Card()
{
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);
}

private function onClick(event:MouseEvent):void
{
this.play();
}

public function setType(type:*):void
{
_type = type;
loader_mc.addChild(_type);
}
}

public class CardTwo extends MovieClip
{
private var _type:*;

public function CardTwo()
{
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);
}

private function onClick(event:MouseEvent):void
{
this.play();
}

public function setType(type:*):void
{
_type = type;
loader_mc.addChild(_type);

}
}
}

Multiple Functions?
Hi
I want to have a btn that loads an image into a picHolder.

I but also want that btn to load a dynamic TextField which is linked to an external txt document at the same time.

Is it possible for this one btn to call multiples functions?
What script do i use?

Many Thanks

Multiple Functions...
Hi there everyone, I've got another one for you guys...

Still a bit of a noob and am trying to figure out the best way to do this.
I am going to try and explain this as concisely as I can...

I have my main timeline with 7 buttons on it. When clicked, each button shows a different piece of information. I want to be able to click a button and a curtain comes across covering what is already there, then depending on what button is pressed, the right information is displayed underneath the curtain, and then the curtain moves away revealing the new information.

I have spent a long time deliberating at the best way to achieve this, I thought about dynamically adding the second curtain to cover things up using the addChild, but could not figure out this way, I thought about then adding the information using the URLLoader class but then this would mean 7 extra external files, which I don't want etc..

I now think that the best way to do this is to have a 3 frame timeline. The first frame has movieclip with the curtain coming across. The second frame has a movieclip with 7 frames in it that represents each piece of information. The final frame has a movieclip with the curtain moving away again and a stop action.

so i need to...


ActionScript Code:
button01_btn.addEventListener(Event:MouseEvent, button01execute);
function button01execute(myevent:MouseEvent):void {
//play first movieclip
//on complete of first movieclip (or when a particular frame label is reached in first movieclip) go to frame 2
//in frame 2, move the playhead of the movieclip with the info in to the right place
//then go to frame 3 where the moving-away-curtain will play for itself and the stop action will stop the playhead.
}

did that make sense? so I will have a bit of code that looks like that for each button... or is there a way so that i can make one piece of code for all the buttons which will be able to change the loaded info depending on the button?

I hope that someone can help me, please.

Thank you all for hopefully taking the time to read this, much appreciated!

Multiple Functions
Can you use multiple "unnamed" functions in MX situated on the first frame???

This code seems to be ok but for x reason only the code for the web button works... anybody's got a clue as to why the design button function doesn't work? And I've already checked and doublechecked that the naming of my different objects are correct, so that's not it.

Here's my code:


Code:
stop();

/* stop the hand cursor from working*/
btnPortfolio.useHandCursor = false;
_root.portfolioRoot.btnWeb.useHandCursor = false;
_root.portfolioRoot.btnDesign.useHandCursor = false;
/*-----------------------------------*/

/*portfolio button function*/
btnPortfolio.onPress = function() {
if (_root.portfolioPressed == 0){
_root.portfolioRoot.gotoAndPlay(2);
}
if (_root.portfolioPressed == 1){
_root.portfolioRoot.gotoAndPlay(12);
}
};
/*----------------------------------*/

/*web button function*/
_root.portfolioRoot.btnWeb.onPress = function () {
if (_root.webPressed == 0) {
_root.portfolioRoot.menuWeb.gotoAndPlay (2);
}
if (_root.webPressed == 1) {
_root.portfolioRoot.menuWeb.gotoAndPlay (15);
}
};
/*----------------------------------*/

/*Design button function*/
_root.portfolioRoot.btnDesign.onPress = function () {
//trace (popo);
if (_root.designPressed == 0) {
_root.portfolioRoot.menuDesign.gotoAndPlay (2);
}
if (_root.designPressed == 1) {
_root.portfolioRoot.menuDesign.gotoAndPlay (15);
}
};
/*----------------------------------*/
Is everything ok or am I dumb???

**Error** Scene 1, Layer 'actions', Frame 1, Line 664: 1087: Syntax Error: Extra Char
Scene 1, Layer 'actions', Frame 1, Line 664: 1087: Syntax error: extra characters found after end of program.
}

I am new to importing classes and I have been practicing making a photo gallery. I am stuck and I want to know if someone can help me with the error I am getting.

If it is convenient, you can download and test my .zip at www.dhtmlguy.freeservers.com

Thanks in advance!

Multiple Functions In One Button...can You Do It?
I have a button in my host movie that is supposed to call a function of another SWF file. When you press the button, it should go to Next Scene. It works fine with this code:

on (release) {
_level14.direction = "forward";
_level14.jumpScene();
}

I have the function placed at the first frame of each scene of the movie I have loaded at level14 with this code:

function jumpScene () {
if (_level14.direction == "forward") {
nextScene ();
//this is for a similar button I also have in host to goto PrevScene
} else {
if (_level14.direction == "back") {
prevScene ();
}
}
}

Now, my problem is that I have many other movies loaded at levels6-13 as well. I've gone into those movies and appropriately written in their level # into the function. But I cant figure out how to call up more than one function at the release of ONE mouse. Here's what I've tried for 2 movies at once:

on (release) {
if (_level14.direction == "forward") {
_level14.jumpScene();
} else {
if (_level13.direction == "forward") {
_level13.jumpScene();
}
}
}

I've also tried this:

on (release) {
_level14.direction == "forward";
_level14.jumpScene();
_level13.direction == "forward";
_level13.jumpScene();
}


What am I doing wrong? How do I make a button play more than one function, depending on which one it is (or where it is in this case)?

Thanks in advanced for any help.

--Darcie

Button Does Multiple Functions. WHY?
My buttons are doing more than the Action Script asks them to do and I need to know why and how to fix it.

Here's the scenario:

I have created an MC that sits on my main timeline. Within that MC are four buttons. When a button is clicked, it should take me to a specific frame. Here is the script on the first button:

on (release) {
gotoAndPlay(93);
}

The code on all buttons is exactly the same with the only change being the frame number it's asked to go play.

I also have an Actions layer. Each frame a button sends you to has a STOP action on this layer. For example, Frame 93 on my Actions layer has a STOP action.

The buttons work exactly as I need them to - sort of - If the buttons are only clicked once, and not again until another button has been clicked, I'm fine, there is no problem. The problem comes if you click the same button twice in a row. What happens is this. If I click button #1, one time, I'm taken to frame 93 as wanted. If I click it again, I'm taken to frame 99, which is where button two should take me. Clicking it a third time, takes me back to frame 93.

If I had only clicked button #1 once (taking me to frame 93) then clicked on button #2, it would take me to frame 99 as wanted. However, if I had clicked on button #1 twice, before clicking on button #2, a single click on button #2, would take me to frame 105, which is where button #3 should take me. This problem happens with all 4 buttons.

I hope this is easy to understand, but I can't figure out whats wrong.

Any ideas?

Thanks in advance.

One Button, Multiple Functions
I was wondering if anyone knew of a tutorial explaning how to code a button to preform multiple functions. I am useing simple forward and back buttons to call swf's to an empty movie clip on my stage. It's something like a swf slideshow with buttons resembling a music player. I have over 50 swf "slides" I need the users to be able to thumb through. Any Help out there?

Functions For Multiple Objects
I was wondering how I could give multiple object the same actions/functions. I think I may need to learn more about OOP and prototypes. As a small test I have just made a few balls all with the same actions just with different speeds.

Thanks.

Adressing Multiple MC's With Functions.
Hi,
I can post the .fla if you want, but id thought id explain it all first.

Im making a wierd little project with a strange flower that looks crazed and does different stuff.
One of the things it does is have moving petals, i created a random movement code that worked perfectly when applied to each petalMC (i have multiple copies of the MC containing the MC with the code attached so it works on every single one.) But now, i want it to do different things according to different events, and the only way i can see is to use lots of variables at the _root level and LOTS of 'if' checks in the movieclips, which would eat up some system speed.
I tried setting a function with the different actions i want, and applying that to the petalMC from the root level, but for some reason now it only applies to one of the petals, instead of every petal (which it should, because its adressing the MC inside the copies, so every copy should act the same?)

Any idea of how to adress those multiple petals without using lots of check statements or arrays and complicated names,

Thanks for your time,

Alex

EDIT : Oh well, ill add it anyway

Multiple Functions For 1 Button
Mx2004
Attached is a sample for editing in MX. I am trying to push the button once have it point north, push the button again and have it point east, push it again and have it point south and push it again and have it point west. push it again and it start all over again.

I thought an "if and then statement" would be best, but that didn't pan out. stumped for the time being.

thanks

Multiple OnRelease Functions?
I'm still very new to action script so please forgive me this question makes no sense. Not sure if I'm describing the problem correctly. Basically, I have a Movie-clip button that plays another nested movie-clip when it is clicked. How would I go about and play the same nested movie clip at a different point in it's time line the second time it is clicked. Can I use an onRelease event handler twice or should I use a listener to detect the mouse click?

Anyway I hope what I'm going after makes some sense. I posted the FLA for reference (for some reason I couldnt atach the file through the forum) so here it is on my idisk--> http://homepage.mac.com/jasoninch/.Public/face.fla.zip . I also included the link that originally inspired me -->http://www.pspartgallery.com/

Basically I would like the "face2" to reset itself back to "original" face after it has been clicked the second time. As it stands now I can only achieve this with an onRollout event.

Any help or reference would be awsome.
Thanks, j

[F8] Multiple OnEnterFrame Functions
Okay, so if I add a onEnterFrame function....

mc.onEnterFrame = function()
{//code}

Then try to add another onEnterFrame function...
mc.onEnterFrame = function()
{//new code}

Flash deletes the first onEnterFrame function. Is there any way to stop Flash from doing this? Can I name, and thus reference the onEnterFrame functions differently?

Thanks for the help,
Halcyon

[F8] Multiple Functions For AttachMovie
Hi everyone,
I have a movie that runs 30 slides full screen continuously, no buttons.
Each slide is to have a different pan or zoom effect to make the slideshow a bit more interesting. Each slide fades in above the other.
I am just learning Actionscript, and I would like to stick to the Best Practices of coding. I have this so far on a test file:

-----------------------------
//FUNCTIONS
function fadeIn() {
this._alpha += 2;
if (this._alpha<=0) {
this._alpha = 0;
this.onEnterFrame = null;
}
}

//this event will make the MC move
function panLeft() {
this.onEnterFrame = function() {
//move the MC 1 pixels at a time
this._x += 1;
}
}

this.attachMovie("pic1", "pic1", getNextHighestDepth, _alpha=100)
this.onEnterFrame = (panLeft);

-------------------------------

I would like to add the fadeIn function to the panLeft function, but so far I've only been able to do one OR the other. I'm going this root so I can mix and match effects to the different slides easily, based on the whims of the client.
A nudge in the right direction would be appreciated. Thank you all for your time!

AS3 - Calling Multiple Functions
Still very new to all this and feeling a bit lost.

I have successfully created several functions (changerow1, changerow2 etc) and assigned them to associated buttons.

I now want to make some buttons that call several of the functions.

I had hoped that the following would work on my button named randomq:


PHP Code:



randomq.addEventListener(MouseEvent.CLICK, (changerow1),(changerow2))




it didn't so I tried making a new function:

PHP Code:



randomq.addEventListener(MouseEvent.CLICK, combinedfunction);
function combinedfunction(event:MouseEvent):void {
   (changerow1), (changerow2)
}




I'm sure there is a straightforward solution, but despite considerable searching I cannot find it. Guidance would be gratefully received.

Multiple Button Functions
i'm making a game, and i'm currently working on the inventory part.

i've got lots of MCs on the screen with instnace names as:
slot0
slot1
slot2
etc.

what i want to do is make it so that on each MC, when hovering over, it goes to frame 2, and when pressed, it goes to frame 3.
i also want to make it so only 1 of the slot MCs can be on frame 3 at a time.
basically, i want to show that it's selected.

i currently have this code on the main timeline for the selection:
code: function itemRelease() {
selecteditem = this.num;
if (this._currentframe == 3){
}
else{
this.gotoAndStop(3);
}
}
function itemOver() {
if (this._currentframe == 3){
}
else{
this.gotoAndStop(2);
}
}
function itemOut() {
if (this._currentframe == 3){
}
else{
this. gotoAndStop(1);
}
}

and on the slot MC, this code:

code: on(rollOver) {
_root.itemOver();
}
on(rollOut) {
_root.itemOut();
}
on(release) {
_root.itemRelease();
}

on the functions, the 'this' part doesn't work, as it's assuming that 'this' means the root as the function was made in the root.

do you know how i can fix this?
also, do you know how i could stop mutliple slots being on frame 3?

thanks,
hucki

One Button, Multiple Functions
Hi,
I need some help. I can’t figure this out to save my life!
Here’s the deal: I’ve got one button (portfolio_btn) and when you click on it a movie clip of a navigation bar (mc_RightNav) flies out onto the stag. (I’ve got this part working). Next what I want to have happen is if the user clicks on that same button again (portfolio_btn) I want the navigation to fly back off the stage. Is this possible? Below is the script that I’m working with right now. Please some tell me what I’m missing or if there’s another way of doing this. Thanks, in advance!

import fl.transitions.Tween;
import fl.transitions.easing.*;

var tweenDirection:String = "out";
var inTween:Tween;
var outTween:Tween;

mcLeftNav.portfolio_btn.addEventListener(MouseEven t.CLICK, rightNavOut);
mcLeftNav.portfolio_btn.addEventListener(MouseEven t.CLICK, rightNavIn);

function rightNavOut(event:MouseEvent):void
{
outTween = new Tween(mcRightNav,"x",None.easeNone,553,800,.3,true );
}

function rightNavIn(event:MouseEvent):void
{
inTween = new Tween(mcRightNav,"x",None.easeNone,800,553,.3,true );
}


Right now my navigation bar (mc_RightNav) flies in but when I hit the button (portfolio_btn) a second time it just flies in again and I want it to fly out. Any thoughts???

Multiple Buttons And Functions
Hey there,
I'm in the process of making an interactive family tree. Each of the members in the tree is a button, and when you click on it information and a picture is dynamically loaded into a panel to the side of the tree. To avoid writing a function for each of the buttons (there's about 30 of them) what is the best way of tackling this problem? Is it possible to write a function that will act on behalf of all the buttons, and load the relevant information depending on which button has been pressed.


Quote:




zoomMC.tree.btn1.onRelease = function(){
path = "infotext/";
myData = new LoadVars();
myData.onLoad = function() {
infoPanel.infoBox.text = this.infotext;
}
myData.load(path+info[0]);
}




'info' is the name of an array that stores all the text file names. As you can see this is the code for just one button, 'btn1'.

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