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




[CS3] Help Need A Cleaner Way To Write This Array Of Buttons



Hi there,

not sure how difficult this is going to be, but I have 30 movie clips, which will all be sequentially numbered. (pos1, pos2, pos3......pos30).

They will all have the same functions, with the only change being the number.

I know there is a more efficient way to write this code using arrays, but I will need help with it. I would rather have 10 lines of code than 150.

I also need help with writing the code, that will disable all other movie clips, once the first one is clicked.

Also, not sure how tricky the javascript part will be.

Below is the code i am trying to achieve, but the long version.


PHP Code:


pos1.onRelease=function(){
    this.gotoAndStop("selected");        
    getURL("Javascript:JSposition('',1)");
    (all other buttons).enabled = false;
}

pos2.onRelease=function(){
    this.gotoAndStop("selected");        
    getURL("Javascript:JSposition('',2)");
    (all other buttons).enabled = false;
}

pos3.onRelease=function(){
    this.gotoAndStop("selected");        
    getURL("Javascript:JSposition('',3)");
    (all other buttons).enabled = false;
}

pos4.onRelease=function(){
    this.gotoAndStop("selected");        
    getURL("Javascript:JSposition('',4)");
    (all other buttons).enabled = false;
}

... all the way to

pos30.onRelease=function(){
    this.gotoAndStop("selected");        
    getURL("Javascript:JSposition('',30)");
    (all other buttons).enabled = false;
}



AS Guru's please help!!!
Thanks.



FlashKit > Flash Help > Flash ActionScript
Posted on: 06-12-2008, 05:23 AM


View Complete Forum Thread with Replies

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

[F8] Need To Write Array, I Think (?)
onLoad = function () {

numPart = 50;


for ( var index = 0; index < numPart; index++) {

particle.duplicateMovieClip("Particle"+index, index);
particle._x = Math.random()*320;
particle._y = Math.random()*240;
speed = Math.floor(Math.random()*3)+6;
}
}



onEnterFrame = function () {

particle._y += speed;

if (particle._y > 240) particle._y = 0;
}

This code is taken off AS 1.0 and trying to fit it over to AS 2.0 for Flash 8, since that is what got loaded into my classroom this year - and I am trying to make sure the kids are NOT writing code on the movieclips themselves and trying to get them to write on the main timeline layer.

How can I get the particle in the onEnterFrame section to create an array or loop statement so I can apply the vertical movement to all the already created duplicate clips that were created in the onLoad section.

Should I use attachMovieClip instead and just call for the clip from the library instead of duplicating it on the stage first?

Thanks for your help and my high school kids will appreciate the fix.

Write Out Array
Is there a way to write out an array without the -->,<-- that separates the elements in the array?





























Edited: 02/01/2009 at 05:49:18 AM by lammspillning

Write To An Array
How do I have variables write to an array? I have three variables coming into flash called:

spot1
spot2
spot3

and I want to have an array that holds those values. something like:

ActionScript Code:
initial = [spot1, spot2, spot3]

I've been reading the tutorials and it looks like everything has to be in quotes, but that won't work. Any ideas?

Thanx in advance.

How To Write An Array Of URL's ?
Hey guys,

Stupid question I know... But I don't know. LOL
In AS3, how do you create an array of external files loaded thru a URLLoader?

I know how to write an array, but I need to put down that it is basically an array of URL's, right? How do I add it to:


HTML Code:
var extFiles:Array = new Array("nnn", "nnn", "nnn");
Second question, also... What about an array of strings, would it be of any help in that case?

THANK YOU FOR ALL OF YOUR HELP!

Trying To Write XML Data From An Array()
Hey everyone...

I have an array called dateHolder[] and it has a random amount of items in it, each with a few dateHolder[i].date and dateHolder[i].venue style variables...

Can someone help explain to me how to write a loop that could go thru dateHolder[] and convert it to XML that I can then send out to PHP to write to mySQL?

Thanks so much!

=)

Write Vars Loaded From .txt To Array?
dear AS-masters:
how would i write an array from variables which i loaded to my movie from an external .txt- file?

my txt looks like:
variable1=value1&variable2=value2&....variableN=va lueN
the variables are loaded to flash properly (i checked this with a dynamic text field) but if i try to create a neqw array with my variables (i do this with an upcounting integer, like array[i]=user[i], i=i+1),
flash ignores the variables loaded from my .txt.
i tried to trace my variables, but nothing happened. maybe you have a solution to this...

thanks anyway
sojus

Need A Person To Write Simple Array For Me.
Don't think im dumb are anything but i need someone to write a simple array for me though all my actionscripting ive never had to do it before and I really dont have the time to learn now. Let me descirbe what has to be done really simple and then ill send you a test dummy to add the code to. The game this is for is almost completed and is one of my best creations yet.
Description:
My game consists of thousands of hit tests that all work together to stop the unit from running though small objects. (mostly alot of trees and walls).
I know nothing about arrays. Heres the simple hit test all you have to do is make the number after T everynumber possible.
if (this, hitTest(_root.world.T+[i])) {
okay if you accept this job you will be included in the Credits. The file is attached, when done send it to (with the name you want to be known as under the credits):
Darktemplarian8@aol.com

Need A Person To Write Simple Array For Me.
Don't think im dumb are anything but i need someone to write a simple array for me though all my actionscripting ive never had to do it before and I really dont have the time to learn now. Let me descirbe what has to be done really simple and then ill send you a test dummy to add the code to. The game this is for is almost completed and is one of my best creations yet.
Description:
My game consists of thousands of hit tests that all work together to stop the unit from running though small objects. (mostly alot of trees and walls).
I know nothing about arrays. Heres the simple hit test all you have to do is make the number after T everynumber possible.
if (this, hitTest(_root.world.T+[i])) {
okay if you accept this job you will be included in the Credits. The file is attached, when done send it to (with the name you want to be known as under the credits):
Darktemplarian8@aol.com

Simple Question? Write To Array In Parent?
I've got a movie that loads in an external swf into a movie clip. I need to be able to write items into the array in the main clip from the sub-clip...I thought it would be simple, but it doesn't seem to be working??

I'm using:

in the parent movie I create the array:

Code:
var aImages:Array = new Array(); aImages.push({image:"img1", fileLoc:""});
in the nested movie I use:

Code:
_parent.aImages[0].fileLoc == "test";

but when I trace it in the following line, it shows me what I push in from the parent, but not what I set in the nested clip??!!

Code:
trace("array "+_parent.aImages[0].fileLoc);

Thanks!!

Method To Write Pressed Keys Into An Array
I wanted to record pressed Key Events into an array (for a small game), does any1 have a good method to achieve this???

thanx in advance

ChromeD

ReferenceError: Error #1074: Illegal Write To Read-only Property Array
I'm really sorry if this ends up a no brainer. I'm new to both AS3 and OOP and have spent the last 4 hours getting nowhere.

the code is being used as a document class in an fla (nothing else in the fla yet).

the boiled down code is:

package
{
import flash.display.Sprite;

public class SimpleMenu extends Sprite
{
public var btnData:Array;

public function SimpleMenu():void;
{
btnData:Array=new Array("Home","About us","Projects","Clients","Press","Brochure");
trace (btnData);
}

}
}

the output says:
ReferenceError: Error #1074: Illegal write to read-only property Array on global.
at SimpleMenu$cinit()
at global$init()

I've tried every way round that I can think off including the stupid ones.
I've googled it but the errors reported there seem much more complex.

Cleaner
Hi
Just wondering if anyone uses Cleaner EZ which comes with Premier etc to compress their video files into Quicktime?
Im stuck on selecting the right settings...I need the video to be fairly small but it ALWAYS ends up being too blurred...
Thanks!

Can This Be Cleaner?
this is a movieclip that can move threw a maze of objects. if the user hits an object the movieclip jumps to frame that shows it crashing. Everything works. my question is.. can the code be cleaner or wrapped up in a function?

onClipEvent (enterFrame) {
if (Key.isDown(37)&& hitTest(_level0.wall)==false) {
_x=_x-4;
}
if (Key.isDown(38)&& hitTest(_level0.wall)==false) {
_y=_y-4;
}
if (Key.isDown(39)&& hitTest(_level0.wall)==false) {
_x=_x+4;
}
if (Key.isDown(40)&& hitTest(_level0.wall)==false) {
_y=_y+4;
}
if (hitTest(_level0.wall)==true) {
this.gotoAndPlay("hit");

}
if (hitTest(_level0.wall2)==true) {
this.gotoAndPlay("hit");

}
if (hitTest(_level0.wall3)==true) {
this.gotoAndPlay("hit");

}
}

[F8] Is There A Cleaner Way To Do This?
This code works just fine for restricting the area I can draw in, but it seems very inefficient. Is there a better way?


Code:
onMouseMove = function () {
if (_xmouse>32 && _ymouse>32 && _xmouse<607 && _ymouse<397) {
drawingArea.lineTo(_xmouse, _ymouse);
}
};
My movie actually uses close to 100% CPU after scribbling a lot, and I think it might be this code thats doing it.

AS2 - URL Cleaner
Hello, this is a great tool that i use to filter path to test locally.

the function:

function cleanVBLE(vble)
{
a = new String(vble);
b = a.split("/");
return b.pop();
}

the usage:
trace(cleanVBLE("/formas/80094/canalune.swf"));

Cleaner Animation
I am trying to make a movie which will play fullscreen with a small area with 20% opacity visible in the center. Now my character (any image) will erase the black background so that a clear picture becomes visible.
Pls. help. urgent

Cleaner Code
I have a code that consolidates current moneys into the least amount of tokens possible. It works but the actual code is extremely bulky, i was wondering if anyone has a tip or sees something that can be removed/replaced for less code

Thanks
code: C_Amount = _root.betTotal;
if(C_Amount < 25)
{
NumLeft = C_Amount % 10;
if(NumLeft < 5)
{
dollar_1 = NumLeft;
dollar_10 = (C_Amount - NumLeft) / 10;
}else{
NumLeft1 = NumLeft % 5;
dollar_1 = NumLeft1;
dollar_5 = (NumLeft - NumLeft1) / 5;
dollar_10 = (C_Amount - NumLeft) / 10;
}
}

[CS3] Cleaner Code
Hi,

Is there an easier, cleaner way to write:

type = _root.page;

if (_root.pageOn == 1)
{
if (type == 'ftp')
{
_root.content.ftp.filters = [myBlurFilter];
_root.content.ftp._alpha = 50;
}
if (type == 'news')
{
_root.content.news.filters = [myBlurFilter];
_root.content.news._alpha = 50;
}
if (type == 'hello')
{
_root.content.hello.filters = [myBlurFilter];
_root.content.hello._alpha = 50;
}
if (type == 'contact')
{
_root.content.contact.filters = [myBlurFilter];
_root.content.contact._alpha = 50;
}
if (type == 'exhibitions')
{
_root.content.exhibitions.filters = [myBlurFilter];
_root.content.exhibitions._alpha = 50;
}
if (type == 'interiors')
{
_root.content.interiors.filters = [myBlurFilter];
_root.content.interiors._alpha = 50;
}
if (type == 'conferences')
{
_root.content.conferences.filters = [myBlurFilter];
_root.content.conferences._alpha = 50;
}
if (type == 'live_events')
{
_root.content.live_events.filters = [myBlurFilter];
_root.content.live_events._alpha = 50;
}
if (type == 'new_media')
{
_root.content.new_media.filters = [myBlurFilter];
_root.content.new_media._alpha = 50;
}
if (type == 'people')
{
_root.content.people.filters = [myBlurFilter];
_root.content.people._alpha = 50;
}
if (type == 'clients')
{
_root.content.clients.filters = [myBlurFilter];
_root.content.clients._alpha = 50;
}
}

Cleaner Code
Hi all, I'm currently working on creating a simulated training flash-based presentation and I'm looking to improve my coding habits.
Part of the simulation was to create a custom cursor that functions just as any data entry cursor would. Here's where I need to improve:
The user is restricted to only entering uppercase glyphs at this point, so the cursor should only respond if a letter character is pressed. All other characters should be ignored. I've figured a method to do this, and it works just fine, but the code is very repetitive and long. I'm guessing that there is a better way to do this by referencing a list of key codes in the conditional statement, but I'm not sure how to go about it. Here's what the code looks like
Thanks

Code:
onClipEvent(keyDown) {
//ignore tab
if (key.isDown(9)) {
this._x = this._x;
} else if (key.isDown(12)) {
this._x = this._x;
} else if (key.isDown(13)) {
this._x = this._x;
} else if (key.isDown(16)) {
this._x = this._x;
} else if (key.isDown(17)) {
this._x = this._x;
} else if (key.isDown(112)) {
this._x = this._x;
} else if (key.isDown(113)) {
this._x = this._x;
} else if (key.isDown(114)) {
this._x = this._x;
} else if (key.isDown(115)) {
this._x = this._x;
} else if (key.isDown(116)) {
this._x = this._x;
} else if (key.isDown(117)) {
this._x = this._x;
} else if (key.isDown(118)) {
this._x = this._x;
} else if (key.isDown(119)) {
this._x = this._x;
} else if (key.isDown(120)) {
this._x = this._x;
} else if (key.isDown(121)) {
this._x = this._x;
} else if (key.isDown(122)) {
this._x = this._x;
} else if (key.isDown(123)) {
this._x = this._x;
} else if (key.isDown(124)) {
this._x = this._x;
} else if (key.isDown(48)) {
this._x = this._x;
} else if (key.isDown(49)) {
this._x = this._x;
} else if (key.isDown(50)) {
this._x = this._x;
} else if (key.isDown(51)) {
this._x = this._x;
} else if (key.isDown(52)) {
this._x = this._x;
} else if (key.isDown(53)) {
this._x = this._x;
} else if (key.isDown(54)) {
this._x = this._x;
} else if (key.isDown(55)) {
this._x = this._x;
} else if (key.isDown(56)) {
this._x = this._x;
} else if (key.isDown(57)) {
this._x = this._x;
} else if (key.isDown(186)) {
this._x = this._x;
} else if (key.isDown(187)) {
this._x = this._x;
} else if (key.isDown(188)) {
this._x = this._x;
} else if (key.isDown(189)) {
this._x = this._x;
} else if (key.isDown(190)) {
this._x = this._x;
} else if (key.isDown(191)) {
this._x = this._x;
} else if (key.isDown(192)) {
this._x = this._x;
} else if (key.isDown(219)) {
this._x = this._x;
} else if (key.isDown(220)) {
this._x = this._x;
} else if (key.isDown(221)) {
this._x = this._x;
} else if (key.isDown(222)) {
this._x = this._x;
} else if (key.isDown(32)) {
this._x = this._x;
} else if (key.isDown(37)) {
this._x = this._x;
} else if (key.isDown(38)) {
this._x = this._x;
} else if (key.isDown(39)) {
this._x = this._x;
} else if (key.isDown(40)) {
this._x = this._x;
} else if (key.isDown(20)) {
this._x = this._x;
} else if (key.isDown(106)) {
this._x = this._x;
} else if (key.isDown(107)) {
this._x = this._x;
//don't move left of original position
} else if (key.isDown(8)) {
if (this._x > 104) {
this._x -= 10;
}
//don't move right of new position
} else if (this._x < 112) {
this._x += 10;
}
}

If/Else - Is There A Cleaner Code?
Hello all,

I am currently working on a flash file and I'm an intermediate user. My actionscript abilities are probably close to beginner, but I'm a quick learner (most of what I have learned with actionscript has been self taught).

In my flash file I have an animation of a rotating globe. Each frame of the rotation is a separate raster image - I don't know how you would represent a rotating globe otherwise, not really something that can be tweened (suggestions are welcome).

I have different locations off to the side of the globe. When the user mouses over a location, the globe spins to that location. When they roll out, the globe spins back to a static starting point.

I wanted the animation of the globe to be as smooth as possible, so, I have a }else{ statement for every possible frame. IE - if the globe animation is rotating back from a position and the user mouses over a new location before the animation stops, it doesn't jump back to the starting static position, it seemlessly flows from the position it is currently at to the new position the user has moused over.

Make sense?

It works flawlessly as is. I've spent quite a bit of time testing it. However, the code is bulky in appearance and according to the size report bulky in bytes as well.

Is there a differnent way to set this up to cut down on size - mainly byte size if possible?

I will include a bit of code so you can see what I'm talking about:

on (rollOver) {
if (_root.EarthClip._currentframe == 1) {
_root.EarthClip.gotoAndPlay(140);
} else { if (_root.EarthClip._currentframe == 160) {
_root.EarthClip.gotoAndPlay(156);
} else { if (_root.EarthClip._currentframe == 161) {
_root.EarthClip.gotoAndPlay(155);
} else { if (_root.EarthClip._currentframe == 161) {
_root.EarthClip.gotoAndPlay(154);
} else { if (_root.EarthClip._currentframe == 163) {
_root.EarthClip.gotoAndPlay(153);

and so on, and so on . . .


Any help would be greatly appreciated.

Thank you in advance.

-MShetler

Cleaner Scripting
I think the code says it all. For a current project I need to use a hit area to start an animation when a mouse rolls over a _mc.

If I use the movie clip instead of a button I can simplify the script by using the first section of the attached code. In the simplified code I only have to define one over and one out state and then I can use a this statement to control the action.
For any number of _mc's I just need one set of functions.

Using buttons, each _mc needs it's own over and out definition and it's own unique set of functions.

I've tried using a bunch of if (grnMC_button.onRollOver = true) {this statements apply only to grn_mc} (not really code) but I can't find anything that works. It would be a great time saver if I could because in the final project I've got about 75 movie clips to control with over functions.

One more thing. I can't use the movie based code because the animations move out from under the buttons and the mouse over area gets big and overlaps the other "buttons". I guess I'm really looking for a way to define a hit area and still keep the code simple.









Attach Code

Movie driven _mc sample code:
˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜
// over-out definitions
grn_mc.onRollOver = over;
grn_mc.onRollOut = out;

blu_mc.onRollOver = over;
blu_mc.onRollOut = out;

red_mc.onRollOver = over;
red_mc.onRollOut = out;

// onRollOver functions
function over () {
this.overThis = true;
this.gotoAndPlay("start");
}

// onRollOut functions
function out () {
this.overThis = false;

Button driven _mc sample code:
˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜
// button definitions
grn_btn.onRollOver = over_grn;
grn_btn.onRollOut = out_grn;

blu_btn.onRollOver = over_blu;
blu_btn.onRollOut = out_blu;

red_btn.onRollOver = over_red;
red_btn.onRollOut = out_red;

// onRollOver functions
function over_grn () {
grn_mc.overThis = true;
grn_mc.gotoAndPlay("start");
}

function over_blu () {
blu_mc.overThis = true;
blu_mc.gotoAndPlay("start");
}

function over_red () {
red_mc.overThis = true;
red_mc.gotoAndPlay("start");
}

// onRollOut functions
function out_grn () {
grn_mc.overThis = false;
}

function out_blu () {
blu_mc.overThis = false;
}

function out_red () {
red_mc.overThis = false;
}

























Edited: 05/16/2007 at 11:25:53 AM by Rick Gerard

Cleaner, Crisper Text
can anyone explain how to get cleaner, crisper text in FlashMX. Thank you.

LoriSchlitz

Cleaner 6 Or Sorenson Squeeze?
hi
I have cleaner 6, but a friend says sorenson squeeze it a better compressor for use of video in flash. Shoul i get a copy? or will cleaner suffice??

Techniques To A Cleaner Program
Hi, Im not an expert in flash, but I do on occasion help some buddies out if they want a menu or something on their webpage.  When I am making these files, it seems like my organization and technique is sloppy.  Any comments / suggestions / flames are welcome on how I could better organize this and other projects in the future.

~Thanks

Link to File:
http://www.geocities.com/matteoelbow/SR_Menu1.fla

Link to movie:   
http://www.geocities.com/matteoelbow/SR_Menu1.swf

Cleaner Movie Clip Dragging
I briefly remember seeing a tutorial for this somewhere but I cant find it anywhere. But is there a way to drag movie clips around using startDrag but with a cleaner more fluent motion as it a bit jolty when moving?

Anydony know the answer?

Flash Media Cleaner Addons
I'm looking for an add-on lilke Sorenson Squeeze for Flash, but this is a little pricey for me.

http://www.sorensonstore.com/product.../sq4mfwin.html

Does anyone know of something comparable for less? I know. You get what you pay for, but I need something to get me by while I'm learning Flash.

I'm not looking for shareware, etc. Just an inexpensive, nifty program to get me started as a newbie.

Thanks in advance for any help.

Can I just say I'm loving Flash. I just starting using it a few days ago, and I'm hooked! This is so much nicer when embedding video to webpages. Whoa!


Edit:
Does anyone know if the addon comes with Studio MX 2004? Because I plan on upgrading very soon. I definately don't want to dish out $119.00 for the addon if it ships with Macro's latest studio.

Quick Question For Cleaner Code
Just need some advice on how to clean this code up. I know there has got to be a way to combine the 2 movieclips....

Basically I have 4 movieClip buttons. currently only the first is working.... How would I add the other f2, f3, f4 MC's without having to write a function for each one?

Here is the code I have:

Code:

f1.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);
f1.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);

f2.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);
f2.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);

f3.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);
f3.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);

f4.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);
f4.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);

function hoverOver(event:MouseEvent):void
{
   f1.gotoAndPlay(2);
}

function hoverOut(event:MouseEvent):void
{
   f1.gotoAndStop(11);
}

f1.buttonMode = true;
f2.buttonMode = true;
f3.buttonMode = true;
f4.buttonMode = true;

Scripting Is Supposed Flash Movie Much Cleaner
Scripting is supposed flash movie much cleaner, there should be a straight forward way to do this.

the example we can call "test.swf"

the movie clip we will call "fade" which resides inside the library

"fade" extends over 50 frames the first 30 have a snazzy animation upon a mouse click on a button in the main menu.
I would like to use this movie clip again just starting at frame 30. My question is can you reference a frame label inside the "fade" clip from the "test.swf?"

Note tell target is usefull by adding a ../ script you can exit a movie clip. Can you preform this code to enter in a clip?

Much thanks

aspiring asssstronaught

Flash Can Write To Txt? [FLfile.write]? :confused:
Okay, a while ago I started a project for one computer. I needed a little database to store information. When I started out I was informed that flash cannot write to a txt file and that I would have to use php to do my bidding. Well.... I just found in F8 the FLfile.write command that says otherwise. I haven't tested it, but will. So what is the deal with this? What advantages are there to flash vs. php with writing to a txt file?


Code:
var URI = "file:///c|/temp/mydata.txt";
if (FLfile.write(URI, "xxx")) {
alert("Wrote xxx to " + URI);
}
if (FLfile.write(URI, "aaa", "append")) {
alert("Appended aaa to " + fileURI);
}

Problematic Flash Files: "Cleaner" Needed (Paid)
Hello all,

I've hit a wall in several small Flash movies that are integrated into one online course, things that I'm sure I can figure out with time, but time is something I ain't got. I need a Flash wiz who can figure out what I've done wrong, improve the actionscripting where necessary, and also finish off some elements that have me stumped (and tell me what I've done wrong in the process). It's actually pretty basic stuff...and all the major groundwork has been done...but there might be a few challenges. You need to be familiar with video/audio integration...everything else is standard stuff.

If you're interested, please send me an e-mail and let me know your preferred method of payment: hourly or project-basis...and if you prefer hourly, please let me know your hourly rate since I have to get approval. Also, please include a link to your Flash portfolio.

BTW - This could possibly lead to a long-term project-basis work relationship.

Thanks! I hope to hear from you!

John

Array Of Buttons?
Anyone have input to this problem?

I have an array of text strings that I want to use for names of buttons. The array size is variable, sometimes it has 11 elements, maybe the next time has 30 elements.

Each of these labeled buttons has a different (but simple) action such as "http://www.site.com/command?page=PageXXX" where XXX represents the array element number or the button number.

How do I create these buttons?

It kind of looks like a variable sized dynamic menu script.

Help With Array For Several Buttons
I have the need to have a mouse over action for 25 different buttons on one page. Unfortunately, the user has to mouse over each before they can continue.

What is the best use of an array to make sure that each has been moused over?

Thank you.

Tried And Tried But .....array Of Buttons
hi all could you please help me , i am trying to make an array of movies when you press on one the others flade out when you press on it the second time the other movies fade in ,... but was not able to do it i am not too good with array so i looking in this forumsand other forums for somthing to modify i found one ... i am tried every way for the last two weeks
this is the cod
/as
function myRollOver(mcTotal) {
this.onEnterFrame = function() {
for (var i = 0; i<mcTotal; i++) {
_root["myClipName"+0].onPress = function() {
if (paused=!paused) {
_root["myClipName"+0]._alpha = 100;
_root["myClipName"+1]._alpha = 0;
_root["myClipName"+2]._alpha = 0;
_root["myClipName"+3]._alpha = 0;
} else {
for (var i = 0; i<mcTotal; i++) {
_root["myClipName"+i]._alpha = 100;
}
_root["myClipName"+1].onPress = function() {
if (paused=!paused) {
_root["myClipName"+0]._alpha = 0;
_root["myClipName"+1]._alpha = 100;
_root["myClipName"+2]._alpha = 0;
_root["myClipName"+3]._alpha = 0;
} else {
for (var i = 0; i<mcTotal; i++) {
_root["myClipName"+i]._alpha = 100;
}
}
_root["myClipName"+2].onPress = function() {
if (paused=!paused) {
_root["myClipName"+0]._alpha = 0;
_root["myClipName"+1]._alpha = 0;
_root["myClipName"+2]._alpha = 100;
_root["myClipName"+3]._alpha = 0;
} else {
for (var i = 0; i<mcTotal; i++) {
_root["myClipName"+i]._alpha = 100;
}
}
_root["myClipName"+3].onPress = function() {
if (paused=!paused) {
_root["myClipName"+0]._alpha = 0;
_root["myClipName"+1]._alpha = 0;
_root["myClipName"+2]._alpha = 0;
_root["myClipName"+3]._alpha = 100;
} else {
for (var i = 0; i<mcTotal; i++) {
_root["myClipName"+i]._alpha = 100;
}
}
};
};
};
}
};
}
};
}
myRollOver(4);
*/as
help please
thanks for any help

[F8] Array Of Buttons
Is there a way to create an array of buttons, evenly spaced on the stage.
And at the same time give these buttons instance names?

Using An Array With Buttons
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code


Code:
numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}
But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work

Array Of Buttons Help
hey! i got an array of buttons and only one OnClick function to handle the MouseClick event for all of them..


Code:
var but:Array;
but = new Array(10);//i need 10 buttons.. well that doesnt matter
for(i=0;i<10;i++)
{
but[i]=new MenuButton();//MenuButton is a MC in the library
but[i].id=i;
but[i].x+=50*i;
but[i].tx.text="Button Nr" + String(i);
but[i].addEventListener(MouseEvent.CLICK,OnClick);
m.m.addChild(but[i]);//m is a container with another container m inside this doenst matter too
}
function OnClick(evt:Event):void
{
??? :)
}
now how do i get to know which button was pressed?.. i tried

Code:
function OnClick(evt:Event):void
{
trace(evt.target.name);
}
but it returns the button components like textField, buttonBckgMC, buttonSelectionMC.. any ideas?

or maybe its possible to make an array of functions for every buttons? or aother way to make functions for all the buttons?

XML Array For Buttons
I need help!!!!!!

I need to make a map and when I RollOver it would display the abbreviation for the state and a number on the bottom: so far I was able to load the xml but when it comes in creating the array and assigning each node to the respective state I freak out. Please help! I looked at several tutorials but they all just load an array and make a duplicate movie clip to populate a menu. this actually has to be assigned on rollover. Please help!!!!!!

Using An Array With Buttons
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code


Code:
numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}
But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work

Using An Array With Buttons
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code


Code:
numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}
But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work

URL To Array Buttons
i have putt buttons in array,and i want to give them a function to loadclip,
so here is my code:
Code:

var myButtons:Array = new Array(btn1, btn2, btn3, btn4, btn5);
var mymovies:Array =new Array ("home.swf","profile.swf","portfolio.swf","services.swf","contact.swf");
var selectedMovie:MovieClip = new MovieClip();


btn1.onEnterFrame=function(){
         selectedMovie = this;
         this.enabled = false;
         btn1.gotoAndPlay("press");
         delete this.onEnterFrame;

}

for (i in myButtons){
   myButtons[i].onRelease = function() {
      //
      if (selectedMovie != this) {
         selectedMovie.enabled = true;
         selectedMovie.gotoAndPlay(19);
      }
      // 
      selectedMovie = this;
      this.enabled = false;
      this.gotoAndPlay("press");


   };
}
for (i in myButtons) {
myButtons[i].onRollOver = function() {

      this.gotoAndPlay("over");
   
};
myButtons[i].onRollOut = function() {

      this.gotoAndPlay("out");

};
}

var mcl:MovieClipLoader=new MovieClipLoader();

var mclL:Object=new Object();

mclL.onLoadProgress=function(target,loaded,total){
   loader.percent.text=Math.round((loaded/total)*100)+"%"
   loader.gotoAndPlay(Math.round((loaded/total)*100));
}

mclL.onLoadInit =function(){
   loader._visible=false;
   loader.percent.text="";
}

mcl.addListener(mclL);

mcl.loadClip("home.swf",mes);

any idea how to do this?

Using An Array With Buttons
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code


Code:


numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}



But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work

Turning Array's Into Buttons
//I have the code below and I have gotten myself in over my head. I want to turn the menuArray into buttons that open up Movie Clips How would I achieve this?

//You can goto a working example at (before you goto the link What I would like to do is when you click on Company in the menu, the menu drops and you target a Movie Clip which would appear below Company.

http://www.medeirosdesign.com

//Code on the main time line

menuArray = [["Company"], ["Awards"], ["Products"], ["Info"], ["Contact"], ["blank"], ["blank"]];
for (var k = 0; k<menuArray.length; k++) {
myMenu.attachMovie("holder", "holder"+k, 100-k);
myMenu["holder"+k].id = k;
for (var m = 0; m<menuArray[k].length; m++) {
if (m == 0) {
myMenu["holder"+k].attachMovie("menu", "menu"+m, 100-m);
} else {
myMenu["holder"+k].attachMovie("submenu", "menu"+m, 100-m);
}
myMenu["holder"+k]["menu"+m].txt = menuArray[k][m];
myMenu["holder"+k]["menu"+m].endY = 40+(m-1)*20;
}
}
//--------------------
arrange = function () {
sumY = 0;
for (var k = 0; k<menuArray.length; k++) {
myMenu["holder"+k]._y = sumY;
sumY += myMenu["holder"+k]._height - 10;
}
};


//More Code on the main time line

menuRollOver = function (id) {
myMenu["holder"+activeId].active = false;
activeId = id;
myMenu["holder"+activeId].active = true;
};

//The Button that is duplicated has this code

on(press){
_root.menuRollOver(_parent.id);
}

//How would I do this it make sense to me to try to say Company = _root.companyMC
Awards = _root.awardsMC

But that didn't work....
[Edited by montara on 09-18-2002 at 03:45 PM]

Loading An Array Into Buttons?
i am making a flash 5 trivia game and i need some help.

i have a text file that has groups of arrays like the following:
Question
Statistic
Correct Answer
Answer
Answer

i want to bring this group of information into flash and go to different places.
1. the Question will go to a dynamic text field.
2. the statistic will go into a dynamic text field.
3. Each answer needs to go into a dynamic text field in its own button. there will always only be 3 answers, 1 correct and 2 incorrect, so 3 buttons. after the user clicks an answer, the statistic will show.

then it will move on to the next question.

the game will have 10 questions. so in the above text file there will be 10 sets of arrays.

any help is dearly appreciated.

thank you.

Creating An Array Of Buttons
Hi guys,

this is my first time using a forum, usually I'm abled to find everything I need on the internet. But not this time. So here's my question:

Is it possible to create an arry of buttons so that I can adress them like movieclip1.movieclip2.button[x]?

The buttons allready exist (so I don't need to make them in actionscript) but I just want to put them in an array to easily adress them.

Do I need to create my buttons in a special way before it is possible to put them in an array? And how do I need to create the array?

I really hope someone can help me, I've spent several hours looking for the answer but I'm just a beginner.

Thanks in advance.

Greetz.

Creating Buttons From An Array
Okay, I already tried posting this in the General Help forum, but got no responces, so I'm trying it in here as it's more ActionScript related.

Say I have an array of links:

linkTxt1 = "CNN News";
linkUrl1 = "http://www.cnn.com";
linkTxt2 = "MTV Online";
linkUrl2 = "http://www.mtv.com";
linkTxt3 = "AltaVista Search Engine";
linkUrl3 = "http://www.altavista.com";
linkTxt4 = "Yahoo! Search Engine";
linkUrl4 = "http://www.yahoo.com";
linkTxt5 = "Coca-Cola Online";
linkUrl5 = "www.coca-cola.com";

and a dummy button which consists of a text field for the link name, and an onClick action to open the url...

How, using ActionScript and this array, can I create a duplicate version of the dummy button on the stage for each link, and populate it with the correct values?


(If you still don't get what I mean, there is an example here:
http://www.flashkit.com/tutorials/In...u-73/index.php
I'm only interested in the list of links, not any of the search functionality)

Array Buttons Loadmovie
Hi there,

Someone can help me with this array.This is the script created to duplicate my button and txt for each button.Now someone can teach me setting up the array for loading in content in each button.

Something like this:
linkcase [1] should load in >holder.loadmovie("case1.swf");
linkcase [2] should load in >holder.loadmovie("case2.swf");
...

linkTxt = new Array()
linkcase = new Array()
linkTxt[1] = "case1";
linkTxt[2] = "case2";
linkCase[1]=???????
linkCase[2]=???????
xStart=20;
yStart=30;

for(i = 0;i<linkTxt.length;i++){
_root.attachMovie("myButton","myButton"+i,i);
// set the y value of the movie
_root["myButton"+i]._x = xStart+0*i;
// set x value
_root["myButton"+i]._y = yStart+20*i;
//put the text in the myButtonTextField
_root["myButton"+i].myButtonTextField.text = linkTxt[i];

}
_root["myButton"+i].onRollOut = function(){
this.gotoAndStop(1);
}

Big thx in advance!!!

Grtz,

Controlling Buttons In An Array
I have a lot of buttons (I only put 3 here) that I wanna control using the ActionScript! It all works fine concerning the rollover states etc., but when I wanna load variables from a external text file the value of "i" always seems to be set to zero no matter which button I press so I always get values for "title0" and "info0".

Is there a way around this so that this code loads variables dependent on which button I press!

For example, if i press the third button in array I want the code to pass the value of variable "title3" and variable "info3" to the textfields "title" and "info".


var buttons = ["btn0", "btn1", "btn2"];
for (var i in buttons) {

_root.tlocrt_mc[buttons[i]].onRelease=function(){

title.text = myVar["title"+i];
info.text = myVar["info"+i];

}

}


Any suggestion is welcome!

Array Of Links To Buttons
This has probably been asked a million times, but anyway, I'm trying to do an array of links that'll be inserted to each of the buttons.

Here's what I did:

I already have 5 buttons on the stage, labeled s1 - s5.


Code:
linkArray = new Array();
linkArray = ["http://www.link1.html", "http://www.link2.html", "http://www.link3.html", "http://www.link4.html", "http://www.link5.html"];

var amount = 5;
for (i=1; i<=amount; i++) {
button = this["s"+i];
button.i = i;
button.onRelease = function() { getURL(linkArray[i],"_blank");
}
}
When I try to click on a button, the URL doesn't get passed at the onRelease instance, but a new window opens nonetheless.

Am I missing something here? Please help. Thanks!

Dynamic Buttons, Array, And Url
Hi

i have 3 buttons that when pressed they will load in an image name test1.jpg and so on.


Code:

files = new Array();
var j = 1;
var l = 50;
for(i = 0 ;i < 3; i++){
files.push('test' + j + '.jpg')
trace (files[i]); // output = test1.jpg test2.jpg test3.jpg
this.attachMovie("submit",['mc_submit'+j], this.getNextHighestDepth());
this['mc_submit'+j]._y = l;
this['mc_submit'+j]._x = 450;
this['mc_submit'+j].onRelease = function (){
loadMovie(files[i],place);

}
l = l + 50;
j++;
}
everything works .....there are 3 buttons on the stage but they dont load in the image .....when i click it just says undefined

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