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




3 Lines Of Code



Can someone tell me why this doesnt work, or if there is another way?

_root.grid.lowerB.attachMovie("block","block_"+_ro ot.numb,_root.numb);
_root.grid.lowerBound["block_"+_root.numb]._y=this._y;
_root.grid.lowerBound["block_"+_root.numb]._x=this._x;


Right basically it attaches the movie to grid.lowerB, but i need to set the _x and _y values after, how can i target the newly attached movie clip?

Thanx in Advance?

Mortolee



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-08-2003, 11:58 AM


View Complete Forum Thread with Replies

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

Few Lines Of Code Better Than Many
I want eight instances of eight mc's to appear invisible on the scene when a button is clicked. Instead of on release....visible= falsebla, bla... eight times, i'd like to choose a most inteligent way to get it, with very few lines of code if possible. But, as i'm not very clever with actionscript, i claim for experts help - i know they're really are -.
Thanks in advance.

How Much Lines Of Code?
Does anyone know how much lines of code flash can handle in one frame?

tnx
Jan

Repeating Lines Of Code
i would like to repeat this line of code inside of a keyframe:
_root.menu1.type = text1

menu1 is a dynamicly loaded mc, with a dynamic textbox inside called type. Im trying to load in text from a textfile into this box. The textfile's variable is text1. I would like to end up with a bunch of these (menu2, text2;menu3,text3 so on so forth), so what i thought i would do is repeat that line, and just add one to it. Could somebody tell me how to go about doing this?

How To Read As3 Code Lines
is there anybody who can tell me is there any kind of reading techniques for reading as3 lines of code, and i mean like you read a book?

boris// thanks

Explaining The Code Lines
http://www.sendspace.com/file/0fznp8

Guys, I need some hel with this. My life is on the line, I have this project I'm making and the due date is today. Can anyone explain me each line of this code inside of the flash file? I REALLY need each line to be explained, otherwise I might give up on school.

Please, help me out.

Too Many Lines Of Executed Code
It seems that we've written a program that executes too many lines of code in a single frame... not in the sense that it stalls and returns an error saying "a script is taking too long" but in the sense that adding another line of code causes an error that seems like no more lines are being executed and no more variables are getting loaded.

it is as if it (the flash player running the swf) makes it most of the way and halts.

Removing lines that are not run changes nothing. Exporting code into .as files changes nothing. Placing code into different movie clips changes nothing.

Has this problem happened before? is there a workaround?

If you could point us in the right direction we would be most grateful.

sincerely

will.

Does It Matter If Code Is On 1 Or 2 Lines?
Using AS 3, when adding code to make a button go to another frame in another scene like this:

myButton.addEventListener(MouseEvent.CLICK,buttonClick); function buttonClick(event:MouseEvent):void {gotoAndStop("Scene2", 1); }

Does it matter if the code all resides on line 1 or if I hit enter/return and carry some of the code over to line 2?

Thanks.

Does It Matter If Code Is On 1 Or 2 Lines?
Using AS 3, when adding code to make a button go to another frame in another scene like this:

myButton.addEventListener(MouseEvent.CLICK,buttonClick); function buttonClick(event:MouseEvent):void {gotoAndStop("Scene2", 1); }

Does it matter if the code all resides on line 1 or if I hit enter/return and carry some of the code over to line 2?

Thanks.

2 Lines Of Code:what's Wrong?
I get the "1046: Type was not found or was not a compile-time constant: VideoEvent.

What I want is that whenever the FLVPlayback (which I've instanced myVid) has loaded the video, we go to frame called "about".

Thanks!







Attach Code

function onMyVidReady(evt:VideoEvent):void {
gotoAndStop("about")
}

myVid.addEventListener(VideoEvent.READY, onMyVidReady);

























Edited: 09/22/2008 at 06:14:10 AM by Pau Perez

Table (Just A Few Lines Of Code And I Don't See A Bug)
var dane:Array = new Array();
dane_xml = new XML();
dane_xml.ignoreWhite = true;
dane_xml.onLoad = function(sucess) {
if (sucess) {
processBook(dane_xml);
}
};
dane_xml.load('dane.xml');
function processBook(dane_xml) {
var n:Number;
var temp:String;
for (n=0; n<3; n++) {
temp = dane_xml.firstChild.childNodes[n].childNodes[0].firstChild.nodeValue+"
";
temp += dane_xml.firstChild.childNodes[n].childNodes[1].firstChild.nodeValue;
dane.push(temp);
// trace(temp);
}
}
trace(dane[0]);

-----------------------
and this last trace gives me undefined while trace(temp) gives me what I want

Skipping Lines Of Code?
im having a problem that seems to me that its skipping lines of action script

for (a=1; a<=8; a++) {
for (b=1; b<=18; b++) {
var A:String = let(a);
var B:String = b.toString();
if (HEX.prox2.hitTest(this[A+B+"_mc"]) && HEX._name != A+B+"_mc") {
if (this[+A+B+"_mc"].clr == "red" && v>this[A+B+"_mc"].Value) {
var holdX:Number = this[A+B+"_mc"]._x;
var holdY:Number = this[A+B+"_mc"]._y;
var V = this[A+B+"_mc"].Value;
var d:Number = ((a-1)*18)+b;
var hex:MovieClip = attachMovie("Hex.2", A+B+"_mc", d);
hex._x = holdX;
hex._y = holdY;
hex.Value = V;
} else if (this[A+B+"_mc"].clr == "blue") {
this[A+B+"_mc"].Value++;
if (this[A+B+"_mc"].Value>20) {
this[A+B+"_mc"].Value--;
}
}
}
}
}

(attachment .fla)
but when this is run, it wouldnt go into some of those if statements. So i debugged it to see what happened. and at some points, it just wouldnt go into the statement even though its conditions were true.
any ideas what im doing wrong?

Blank Code Lines?
Hello,
I was coding normally today, but suddenly, blank lines after comments! Thousands of them!
OK now seriously, what the heck is this:
?

it appears after every comment with no script in it, and it came all of the sudden today. I tried re opening the file / flash but it's the same. In a new flash file it doesn't happen, but when I copy one of these things it does, even on a new one.
Did my Flash/FLA got screwed up, or is there a feature flash really wants me to see?

Thanks a bunch!

FAST ONE Code Does Not Work. 3 LINES
on (rollOver) {
setProperty(info, _x, this._x);
_level0.info.info_p = "+7 " + this._name;
}


what am i doing wrong? it wont set the x position of info MC to the x postition of "c" MC. Even if i change this._x to c._x. And, it does do the second part... so confused... plz help

Limite Of Lines To One Actionscript Code? MX
Hi,

Im working in a multichoice quest, and for a frame at this moment i have 467 lines and i need more, and before i continue:

How many lines can we put in a actionscript code?

And the MX can execute all without any conflit?

Postion 35 Boxes Without 70 Lines Of Code?
I have duplicated a movie clip square (80px / 80 px) 35 times and want to place then side by side on my stage (560px / 400px). There must be a way of doing this that rather write actionscript:

this.box1_mc._x = 40;
this.box1_mc._y = 40;
this.box2_mc._x = 120;
this.box2_mc._y = 40;
this.box3_mc._x = 200;
this.box3_mc._y = 40;
...and so on until all 35 are done!

Any ideas?

2 Lines Of Code 1 Works 1 Doesn't
OK I am trying to create buttons dynamically. I'm sure this has been posted a million times, but I cannot find the answer. How can you create onRelase functions inside a dynamically created MC? here's what I have so far which works:

Code:
_root.createEmptyMovieClip("test", 10);
test.createEmptyMovieClip("container", 10);
test.container.loadMovie("images/1.jpg")

test.onPress = function() {
test._x = 100;
}


and this does not work:

Code:
_root.createEmptyMovieClip("test", 10);
test.createEmptyMovieClip("container", 10);
test.container.loadMovie("images/1.jpg")

_root.test.container.onPress = function() {
test._x = 100;
}


Can I only place this type of code on the root level? is there any work around?
Thanks for looking

Converting To AS 2.0 Class (only A Few Lines Of Code) - Can Someone Help?
This goes out to the AS 2.0 gurus out there.

I have this little file (downloaded from http://www.levitated.net) written in AS 1.0 (Flash MX). It's an awesome little animation of some computer generated sperm like creatures that glide effortlessly around the screen (file attached.)

I am trying to conver this to AS 2.0 syntax and I'm having some difficulties - would anybody out there be able to help me?

The file itself consists of the following 20 or so lines of code on the main timeline :


/////////////////////////////////////////////////////////////
/////////////////// 1 st frame of root timeline /////////////
/////////////////////////////////////////////////////////////

// register root as environment
Object.environment = this;

// simple rad to degree convertor
Math.prototype.degrees = function(r) {
// given r rads, convert to degrees
return (r*180/Math.PI);
};

// maximum numbe r of simultaneous tentacles
maxtents = 3;

this.onEnterFrame = function() {
if ((!random(30)) && (tents<maxtents)) {
// create a new tentacle object
var nombre="tent"+String(depth++);
var neo=this.attachMovie("tentacle",nombre,depth);
// position it at screen bottom
neo._x = random(Stage.width - 200) + 200;
neo._y = Stage.height - 10;;
// point up initially
neo.theta=270;
// keep track of number of tentacles
tents++;
}
}
stop();

/////////////////////////////////////////////////////////////


followed by the following code on a clip named "tentacle" (with Linkage turned on) in the library :


/////////////////////////////////////////////////////////////
////////// 1st frame of "tentacle" mc timeline /////////////
/////////////////////////////////////////////////////////////

#initclip
// constructor
function TentacleClass() {
// total number of nodes
this.numNodes = 27;
// the general size and speed
this.head = 2+random(4);
this.girth = 8+random(12);
// locomotion efficiency (0 - 1)
this.speedCoefficient=.09+random(10)/50;
// the viscosity of the water (0 - 1)
this.friction=.90+random(10)/100;
// muscular range
this.muscleRange=20+random(50);
// muscular frequency
this.muscleFreq=.1+random(100)/250;
// create point array to represent nodes
this.generateNodes();

// swim
this.onEnterFrame = this.move;
}

// allow component to inherit MovieClip properties
TentacleClass.prototype = new MovieClip();
// instance methods

TentacleClass.prototype.generateNodes = function() {
// create all body part nodes
this.node = new Array();
for (var n=0;n<this.numNodes;n++) {
var point = {x:0,y:0};
this.node.push(point);
}
}
TentacleClass.prototype.move = function() {
// mouse handle - uncomment to control tentacles with mouse
//this.node[0].x = this._xmouse;
//this.node[0].y = this._ymouse;

// directional node with orbiting handle
// arbitrary direction
this.tv+=0.5*(Math.random()-Math.random());
this.theta+=this.tv;
this.tv*=this.friction;
this.node[0].x = this.head*Math.cos(Math.PI / 180 * this.theta);
this.node[0].y = this.head*Math.sin(Math.PI / 180 * this.theta);

// muscular node
this.count+=this.muscleFreq;
this.thetaMuscle=this.muscleRange*Math.sin(this.co unt);
this.node[1].x = -this.head*Math.cos(Math.PI / 180 * (this.theta+this.thetaMuscle));
this.node[1].y = -this.head*Math.sin(Math.PI / 180 * (this.theta+this.thetaMuscle));

// apply kinetic forces down through body nodes
for (var i=2; i<this.numNodes; i++){
var dx = this.node[i].x - this.node[i - 2].x;
var dy = this.node[i].y - this.node[i - 2].y;

var d = Math.sqrt (dx * dx + dy * dy);
this.node[i].x = this.node[i - 1].x + (dx * this.girth) / d;
this.node[i].y = this.node[i - 1].y + (dy * this.girth) / d;

// check if muscle node is outside of viewable window
if (i==2) {
this._x-=dx*this.speedCoefficient;
this._y-=dy*this.speedCoefficient;
if (((this._x+this._width) < - 400) || ((this._x-this._width) > Stage.width) ||

((this._y+this._height) < -300) || ((this._y-this._height) > Stage.height)) {
// no longer visible, remove
Object.environment.tents--;
this.removeMovieClip(); // very important must be able to do this in as 2.0
}
}
}

// draw nodes using lines
this.clear();
this.moveTo(this.node[1].x,this.node[1].y);
for (var i=2; i<this.numNodes; i++){
this.lineStyle((this.numNodes/(i-1))*1.5, 0x333333, 100);
this.lineTo(this.node[i].x,this.node[i].y);
}
};
// Connect the class with the linkage ID for this movie clip
Object.registerClass("tentacle", TentacleClass);
#endinitclip

/////////////////////////////////////////////////////////////


As you can see the file structure very closely mimics the Class/methods OOP principles inherent in AS 2.0 and should be pretty

easy to convert, alas when I tried to I failed miserably...

I tried creating a new class (TentacleClass.as) with something like : class TentacleClass extends MovieClip () {} and using the

code above, but i keep breaking it...

Any takers?

Incidentally, for those few who don't know it already, levitated.net rocks!!

Thank you (respectfully) in advance,

FlashFroggie

Join 2 Lines Of Actionscript Code?
Hey,

I have a line of Actionscript that is apparently too long for Flash to display on one line. It cuts the code of at Col 1022 and continues it on the next line. Only the next line isn't a number in the code line numbers. Example below.

Is there any way to join two lines of Actionscript?


Example of what I mean:


Code:

11 _root.mybutton....... etc......
code continues here after being cut off on line 11
12 _root.my_mc (a brand new line of code)
13 .....

Maximum Number Of Lines Of Code
Hello all,

I've been creating a huge code for something I've been working on and somewhere between 1000 and 10000 (I did a "copy/paste" so I'm not sure of the limit) the code just stopped working (and there's no error on it)

Does actionscript 2.0 has a limit of code lines? Does actionscript 3.0 has it as well?

Tnx in advance
Keish

Help With Writing 2 Lines Of Code - My Bad Syntax
Hi,

I need a bit of help writing a couple of lines of code.

i set a variable, which is the path, on a button


PHP Code:



on (release) {
    _root.proppath = ("pret/roland/");
}




then i need to set the path on another button by calling the variable - then adding the rest of the path.. understand?
something like : (this is wrong)

PHP Code:



on (release) {
    _root.xmlDataPath = "_root.propath/exterior/deliver/gallery1.xml";
    loadMovie("_root.propath/deliver/viewer.swf", "_root.content.propmc.ss");
}




Can someone help me write these two lines properly?
Thanks
JH

How Many Lines Of Code Can I Put In The Actions Panel?
I've heard Flash can't handle more than 1500 lines or so. Is this true for Flash 8?

EDIT: Found it in the documentation for Flash 8. 1500 line limit indeed. How can I get around this?

Help Explaining A Few Lines Of Code I Found
I found some code for a Mac-like dock effect that I was trying to understand so that I could create something similar. There are a few lines and some operators that I can't really understand. If someone could briefly explain a few lines, I'd really appreciate it.

So it's an external actionscript file called Dock.as

here's the constructor:

Code:
function Dock() {
setParameters();
setLayout();
createIcons();
createTray();
onEnterFrame = monitorDock;
}
That all makes sense. Here's that first method called.


Code:
private function setParameters():Void {
this.layout = this.layout ? this.layout : 'bottom';
this.icon_min = this.icon_min ? this.icon_min : 32;
this.icon_max = this.icon_max ? this.icon_max : 96;
this.icon_spacing = this.icon_spacing ? this.icon_spacing : 2;
this.span = this.span ? this.span : getSpan();
this.amplitude = this.amplitude ? this.amplitude : getAmplitude();
this.ratio = Math.PI / 2 / this.span;
}
What are those question marks and colons doing? How does any one of those variables get its value?


Code:
private function createIcons():Void {
var i:Number;
var id:String;
this.scale = 0;
this.width = (this.items.length - 1) * this.icon_spacing + this.items.length * this.icon_min;
var left:Number = (this.icon_min - this.width) / 2;
for(i = 0; i < this.items.length; i++) {
this.createEmptyMovieClip(String(i), i + 10).attachMovie(this.items[i].id, '_mc', 1);
this[i]._mc._y = -this.icon_size / 2;
this[i]._mc._rotation = -this._rotation;
this[i]._x = this[i].x = left + i * (this.icon_min + this.icon_spacing) + this.icon_spacing / 2;
this[i]._y = -this.icon_spacing;
this[i].onRollOver = raiseText;
this[i].useHandCursor = false;
}
}
The line that confuses me here is "this.createEmptyMovieClip(String(i), i + 10).attachMovie(this.items[i].id, '_mc', 1);" It looks like it creates a clip, names it using a number, and then does it immediatel attach a movie to that clip? The following lines start using this[i] as if an array was created. Did that previous line initiate some kind of array as well?

Thanks for any help on this. I think it'll be very educational for me to figure this out.

Can Autoformat Somehow Wrap Lines Of Code?
A few lines in one of my AS scripts are particularly long, and autoformat will make it one huge line that I need to side scroll to read.

Is there any way to force a new line just for readability's sake?

RegExp - Can You Condense These Lines Of Code?
Just wondering if this can be condensed... Thanks...

ActionScript Code:
//
regExp = /</gi;
s = s.replace(regExp, "<");

regExp = />/gi;
s = s.replace(regExp, ">");

regExp = /"/gi;
s = s.replace(regExp, """);

regExp = /'/gi;
s = s.replace(regExp, "'");

regExp = /&/gi;
s = s.replace(regExp, "&");

How Many Lines Of Code Have Made Up Your Sites?
For those of your who have made websites 100% in flash:

How many lines of as3 or as2 have you used? on average.

I'm curious, because I'm about to launch another one and all the ones I've done so far have used about 5k lines of as3.

So, anyway, how many do you use?

How Many Lines Of Code Can You Get Away With In One Frame/function?
Been getting into some complex projects lately and I really hate to use the flash timeline at all. I like to live in code but I am still stuck in AS2 (having CS3 pro since it came out) because mProjector and MDM Zinc only supported it. (Yes, just yesterday Zinc 3 came out with full AS3 support, but I need to learn it)..

Sooo I'm finding that I can get away with running up to about 4-5 thousand lines of code before flash player starts to noticably have trouble completing a frame in time (31fps). Albeit it obviously matters what the code is actually doing but I'm wondering how many lines do you all run before you find it starts to fall behind on framerate? What is reasonable?

How Many Lines Of Code Before Flash Lags
Hey Just wondering if theres a limit i should have before flash starts lagging because of code length.
I have about 4000 lines here and there and its starting to lag i can tell... I started using mx 2004 to maybe stop it but i found it worse dealign wit hso much code.

have i hit a plateau with this little macromedia applet or what?

Extend Code To Multiple Lines
Hey guys, could someone tell me the symbol (or pair of symbols) to extend a line of code to multiple lines? For example, rather than this:

Code:
if (a == b and c == d and e == f and g == h and i == j and k == l and m == n and o == p and q == r and s == t and u == v and w == x and y == z){
something like this:

Code:

if (a == b and _
c == d and _
e == f and _
g == h and _
etc.
Thanks!

Sound: 2 Code Lines--1 Error
Hello community, I'm trying my best to learn how sound works in flash cs3. But I can't get past the simplest thing... getting an imported mp3 to play. This is my code:

var s:Sound= new Sound("test1.mp3");
s.play();

Flash isn't playing the sound because of the following error: 1067: implicit coercion of a value of type String to an unrelated type flash.net:URLRequest

The library shows that "test1.mp3" is of type sound. But AS3 thinks that it is a string variable. Does someone know what I should do?

Interesting Flash Bug (3 Lines Of Code)
Try this:

var arr:Array = new Array();
trace(arr["random text"]); //outputs undefined
trace(arr["map"]); //outputs function Function() {}


Why is "map" defined as an entry in this array? Am I missing something?

How Many Lines Of Code Before Flash Lags
Hey Just wondering if theres a limit i should have before flash starts lagging because of code length.
I have about 4000 lines here and there and its starting to lag i can tell... I started using mx 2004 to maybe stop it but i found it worse dealign wit hso much code.

have i hit a plateau with this little macromedia applet or what?

Xml Code Breaking Lines At Elements
using the xml code
Code:

<?xml version="1.0" encoding="utf-8"?>
<menu>

<item><red>"TENDERNESS</red>AND<red>KINDNESS</red>ARE NOT SIGNS OF WEAKNESS AND DESPAIR BUT MANIFESTATIONS OF<red>STRENGTH</red>AND RESOLUTION."
<author>KHALIL GIBRAN</author></item>

<item>"THE BEST PORTIONS OF A MAN'S LIFE, HIS LITTLE, NAMELESS, UNREMEMBERED<red>ACTS</red>OF<red>KINDNESS</red>AND<red>LOVE."</red>
<author>WILLIAM WORDWORTH</author></item>

<item>"LIFE'S MOST PERSISTENT AND URGENT QUESTION IS,<red>'WHAT ARE YOU DOING FOR OTHERS?'"</red>
<author>MARTING LUTHER KING, JR</author></item>

<item><red>"KINDNESS</red>IS THE GOLDEN CHAIN BY WHICH SOCIETY IS BOUND<red>TOGETHER."</red>
<author>JOHANN WOLFGANG VON GOETHE</author></item>

<item>"THE IDEALS WHICH HAVE LIGHTED MY WAY, AND TIME AFTER TIME HAVE GIVEN ME NEW COURAGE TO FACE LIFE CHEERFULLY, HAVE BEEN <red>KINDNESS</red>,<red>BEAUTY</red>AND<red>TRUTH."</red>
<author>ALBERT EINSTEIN</author></item>

</menu>

every time the <red> element is used
the next piece of text
goes onto the next line...

no idea why though, i've tried playing about with a few things, but can't seem to figure out why its happening,
i'm condensing the white space, ive tried embedding a few different things...
does anybody have an idea?

thanks

2 Simple Lines Of Code, That Refuse To Work
hmm.. well im making a game. and this is the little AI thing im trying out, it makes the charcter move towards the player and attack:


PHP Code:



// attack function
function moveAndAttack () {
    speed = 3;
    MaxX = _root.player._x+100;
    MinX = _root.player._x-100;
    MaxY = _root.player._y+5;
    MinY = _root.player._y-5;
    var targetX = _root.player._x;
    var targetY = _root.player._y;
    if (this._x<=(MinX)) {
        this._x += speed;
        walkingX = true;
        xPos = false;
    } else if (this._x>=(MaxX)) {
        this._x -= speed;
        walkingY = true;
        yPos = false;
    } else if (this._y>=(MaxY)) {
        this._y -= speed;
        walkingY = true;
        yPos = false;
    } else {
        yPos = true;
    }
    if (ypos == true && xpos == true) {
    //STATEMENT BELOW DOESNT WORK    
sprites.gotoAndPlay("attacking");
    }
    if (walkingX == true || walkingY == true) {
    //STATEMENT BELOW DOESNT WORK    
sprites.set.gotoAndPlay("walking");
    }
}
// end of attack function




those two lines do not work! and im fed up with trying to find out what the problem is with them. The path is correct, ive tried the full path, converting the "gotoAndPlay" to frame numbers, pretty much everything. Anything you can see im doing wrong?

Making 50 Lines Of Repetitive Code Into A Couple?
can someone please help me simplify my dumb coding???...all i want is some duplicated movie clips to successively move to certain positions...

3 Lines Of Code..stuck For 2 Hours ..HELP LoadVars
Hi please help... i have no idea what im doing worng and have been stuck for 2 hours.. have used LoadVars class before so cant get why this isnt working:

var myLV:LoadVars= new LoadVars();
myLV.load("vars/tracks.txt");
info_txt.text=myLV.totalTracks;


When i test the movie all i get in the text field is "undefined"..

The flash movie is just outside of the vars folder which contains the track.txt file...

why do i keep getting undefined..im going crazy..thanks..ive attached the files so u can have a look..thanks!!!

OnLoad Function Does Not Want To Execute 3 Lines Of Code
Hi, quick actionscript question: WHAT IS WRONG? Trying to get data from database. The "http://www.laurierSOS.com/getsessiondata.php?course=1" works when you put it into the url of a browser. The info is 'echo'ed to the screen, but in my flash test, the onLoad function does not execute! I need it to execute - thoughts are MUCH appreciated!!

var receiver:LoadVars = new LoadVars();

receiver.onLoad = function()
{
DOES NOT GET INTO HERE!
}

receiver.sendAndLoad("http://www.laurierSOS.com/getsessiondata.php?course=1",this,GET);
stop();

Maximum Lines Of Code Flash Can Handle
hello... i got a huge project and i may need write down lots of code...so far i estimated it around 500 lines ...

Whats the maximum flash can handle and if there is any... is there a solution to this? Like getting code from an external file or smth?

Thanks

Flash Refuses To Run With More Than 3700 Lines Of Code.
As soon as i add one more line of code to my game flash will no longer run the movie. ): What can i do? I already tried putting the code into different places with no luck. I estimate that the final game will be somewhere in the 5000 line area.

Long Lines Of Code... How Can I Drop Down A Line?
total noob question here and I'm surprised this is the first time I've encountered this but...

I have a very long line of script that I'm having to scroll far to the right in the Actions panel to modify. What's the trick for keeping the code constant but dropping it down a line for easier access?


thanks!

Breaking Actionscript Code Into Two Or More Lines In The Editor
How do I break an actionscript statement onto more than one line? and is there any limit to the number of lines I can break it onto?
It's for a really large string and I don't want to scroll in my editor.

Cheers,
Daf

````

Urgent - 3 Lines Of Code..stuck For 2 Hours ..HELP LoadVars
3 lines of code..stuck for 2 hours ..HELP loadVars

Hi please help... i have no idea what im doing worng and have been stuck for 2 hours.. have used LoadVars class before so cant get why this isnt working:

var myLV:LoadVars= new LoadVars();
myLV.load("vars/tracks.txt");
info_txt.text=myLV.totalTracks;


When i test the movie all i get in the text field is "undefined"..

The flash movie is just outside of the vars folder which contains the track.txt file...

why do i keep getting undefined..im going crazy..thanks..ive attached the files so u can have a look..thanks!!!

Resizing Window Works, But Not In All FP. Narrowed To 4 Lines Of Code, But Can't Fix
I created this resizing window that will scale with ease/slight bounce to the content contained (well actually, scale to values pulled from an array). It's basically just a frame with some shadows etc. It works fine in FP6 and I know the problem preventing it from working in 7 & 8 exists in 4 lines of code... I have just been staring at it for so long and trying everything I can think of, that i am obviously missing something. At one point, I got it working in FP7 (although very choppy motion), and before i saved i got sidetracked with something else, system froze up and had to re-boot Anyway, please take a look, I'm sure it's an easy fix for anyone other than me at this point. The sample just pulls random array values and scales the mcs accordingly.

I figure i'll post the code as well, since many of you can probably look at that and tell me how to correct it. So here it is... it includes options and comments to try to explain things and make it easier to find the solution.(If you create 4 rect mc's and name them inShadow, screen, frame & dropShadow, [stacked in that order, inShadow being topmost] you can copy & paste this code and it should work fine):
Code:
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.showMenu = false;

// --------------------- >> PROTOTYPE TO RANDOMIZE THE ARRAY
Array.prototype.Randomize = function() {
var v1 = this.length;
var v2 = new Array();
for (var i = 0; i<v1; i++) {
var v3 = Math.round(Math.random()*(this.length-1));
v2[i] = this[v3];
this.splice(v3, 1);
}
for (var j = 0; j<v1; j++) {
this[j] = v2[j];
}
};

// --------------------- >>
var a:Array = [650, 390, 460, 350, 700, 537, 723, 482, 390, 476, 582, 635, 200, 580, 430, 420, 280];

// --------------------- >>
function expand(id) {
var v1:MovieClip = id;
var winWidth:Number = a[0]; // THIS WILL COME FROM A MULTI-DIM
var winHeight:Number = a[1]; // ARRAY IN FINAL MOVIE, a[0] & a[1] ARE RANDOM HERE
var bounce:Number = 0.4;
var speed:Number = 2;
var pad:Number = 20;

v1.onEnterFrame = function() { // COMMENT OUT FOR CALL METHOD TWO
var v1:MovieClip = this; // COMMENT OUT FOR CALL METHOD TWO

// ENDING X / Y POS
v1.end_X = (Stage.width - winWidth) * .5;
v1.end_Y = (Stage.height - winHeight) * .5;

// WIDTH / HEIGHT : SMOOTH EASE METHOD
v1.endWidth = v1.winWidth * bounce + (winWidth - v1._width) / speed;
v1.endHeight = v1.winHeight * bounce + (winHeight - v1._height) / speed;
// WIDTH / HEIGHT : BOUNCE EASE METHOD
//v1.endWidth = v1.endWidth * bounce + (winWidth - v1._width) / speed;
//v1.endHeight = v1.endHeight * bounce + (winHeight - v1._height) / speed;

// OFFSET X / Y POS : SMOOTH EASE METHOD
v1.offsetX = v1.winWidth * bounce + (v1.end_X - v1._x) / speed;
v1.offsetY = v1.winHeight * bounce + (v1.end_Y - v1._y) / speed;
// OFFSET X / Y POS : BOUNCE EASE METHOD
//v1.offsetX = v1.offsetX * bounce + (v1.end_X - v1._x) / speed;
//v1.offsetY = v1.offsetY * bounce + (v1.end_Y - v1._y) / speed;

// SCREEN (or ID)
v1._width += Math.round(v1.endWidth);
v1._height += Math.round(v1.endHeight);
v1._x += Math.round(v1.offsetX);
v1._y += Math.round(v1.offsetY);

// FRAME
frame._width = v1._width + pad;
frame._height = v1._height + pad;
frame._x = v1._x - (pad * .5);
frame._y = v1._y - (pad * .5);

// INSET SHADOW
inShadow._width = v1._width;
inShadow._height = v1._height;
inShadow._x = v1._x;
inShadow._y = v1._y;

// DROP SHADOW
dropShadow._width = v1._width + (pad * 2);
dropShadow._height = v1._height + (pad * 2);
dropShadow._x = v1._x - pad;
dropShadow._y = v1._y - pad;

/* BTW -- THIS CHECK NEVER SEEMS TO STOP THE ENTERFRAME LOOP
if (v1._width == winWidth && v1._height == winHeight){
v1.onEnterFrame = null;
}
*/
}; // COMMENT OUT FOR CALL METHOD TWO
}

// --------------------- >> CALL METHOD ONE ------------ >>
onMouseDown = function () {
expand(screen);
a.Randomize(); // RANDOMIZE THE ARRAY
};

/*
// --------------------- >> CALL METHOD TWO ------------ >>
onMouseDown = function () {
screen.onEnterFrame = function() {
expand(this);
};
a.Randomize(); // RANDOMIZE THE ARRAY
};
*/

I should also mention that i have scoured thoe boards here and on actionscript.org for the past two days, trying to find another/better/functional way to do this.... I really need your help on this. please!?!?

Thanks for any help/suggestions.

How To Break A Long Line Of Code Across Multiple Lines
(sorry this is such a stupid question but...)
I hate having a loooooooong line of code that i have to scroll left and right on so I like to break them to make the code more readable...

in asp I would do

variable = "this string is so long" & _
" that I broke it across" & _
" three lines


what is the actionscript way?

Guru Advice Needed: Is 75 Lines Of Code Too Much For A Clip? Prototype Better?
If any of you could give this a look I'd be grateful.

http://www.geocities.com/vegasdzl/

It uses the set.Transform method of the color object and works fine. Click anywhere and the clips randomly colorize and return to onLoad state no problem. The problem is that it requires about 75 lines of code per clip and I thought that functions would be better so I thought about prototypes. My question. Should I write new clip methods using a prototype for this or do you think keeping the code as is would be satisfactory? Any insights are appreciated. I'm not looking for any code handouts just a quick answer from those of you with guru experience and the Color object methods. Thanks to anyone who can give it a quick glance.

6 Lines Of Problem Code; Using A For Loop (8increments) To Dup/mask Loaded Jpgs.
this doesn't work. why?

Code:
stop();
for(var i=1;i<=8;i++){
imageholder.duplicateMovieClip("imageholder" + i, i);
loadMovie(["im"+i+".jpg"], _root.imageholder["imageholder" + i]);
_root.imageholder.setMask("maskmc");
linkholder.duplicateMovieClip("linkholder" + i, i);
loadMovie(["ln"+i+".jpg"], _root.linkholder["linkholder" + i]);
_root.linkholder["linkholder"+i]._y = i*25;}


i have the 3 symbols on the stage, all empty, named correctly.

if i use createEmptyMovieClip instead of placing them, the script works; but i have a bunch of script that's supposed to go on those mcs for other stuff and as far as i know that means i cant use createEmpty.

tyia.

How To Find Number Of Lines Of Dynamic Text...and How Many Lines In Textfield
is there any way of finding out how many characters will fit in a dynamic textfield?

I have a textfield that is dynamically loaded with text. Sometimes the text is long and i need scroll buttons, but when the text is short i would like not display the scroll buttons.

How can i figure out if text is short enough not to display the scroll buttons?

oh..to make it even more complicated; the font of the text is not always the same. I use textformatting to display header-like lines in the textfield.

Bad Images - Straight Lines Are Jagged Lines - Why?
Hello -

Wondering if anyone had a solution --- I have some images for a portfolio - almost all of them have a diagonal line that's supposed to look straight, and in flash it's looking jagged and wiggly.

I began with 300 dpi images - saved them to the proper size, no compression, saved PNG's, then imported to Flash with lossless (jpg,png) setting, created Graphic Symbol with all graphic information in the upper left quadrant, and it is in an even space on the stage (no 113.4, but 113.0)....

I did a lot of research to make sure I got the best quality images & have taken all of these steps and it's still coming out crappy....

Any ideas? Much appreciated...

Some Problems Drawing Lines Over Other Lines...
Hi.
I'm designing a character for a movie I'm gonna make, but I'm having some trouble. I recently decided to change the colors of the lines I used, so I switched them around a bit to match the fills but some of the lines I changed the color of now overlap the lines that are supposed to be in front. I tried to draw the 'good' color over them again but at the moment I release the button the lines I draw disappear again and the others overlap them. Any help? I'm using mx 2004.

Thanks in advance

Lines, Lines, Lines....and Their Movement...
How do i make a line to move, grow, shrink, follow a path...i thought about masking but i believe there must be an easier way of doing it via actionscript...am i right?

please help...
Thanx a lot for your time...

:eek:

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