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








Creating A Function- What Am I Doing Wrong?


Hi,

i've been working on a script that will dyanamically scale some background images, I can't see what's wrong with this function:

//the 'adjustSliders' function is called by the actionscript in the actions layer in _root. it is used to move the masks of the moving background images
// desired_x and desired_xscale are called on in each slider movieclip
adjustSliders = function (1x:String,1scale:String,2x:String,2scale:String,3 x:String,3scale:String,4x:String,4scale:String,5x: String,5scale:String,6x:String,6scale:String.){

_root.slidingImages_mc.section1_mc.desired_x = 1x;
_root.slidingImages_mc.section1_mc.desired_xscale = 1scale;

_root.slidingImages_mc.section2_mc.desired_x = 2x;
_root.slidingImages_mc.section2_mc.desired_xscale = 2scale;

_root.slidingImages_mc.section3_mc.desired_x = 3x;
_root.slidingImages_mc.section3_mc.desired_xscale = 3scale;

_root.slidingImages_mc.section4_mc.desired_x = 4x;
_root.slidingImages_mc.section4_mc.desired_xscale = 4scale;

_root.slidingImages_mc.section5_mc.desired_x = 5x;
_root.slidingImages_mc.section5_mc.desired_xscale = 5scale;

_root.slidingImages_mc.section6_mc.desired_x = 6x;
_root.slidingImages_mc.section6_mc.desired_xscale = 6scale;

}

I get 13 AS errors- one for each of the lines in the function :o/

*sorry if the first few lines are broken




KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 01-26-2005, 08:19 AM


View Complete Forum Thread with Replies

Sponsored Links:

Creating A Function- What Am I Doing Wrong?
Hi,

i've been working on a script that will dyanamically scale some background images, I can't see what's wrong with this function:

//the 'adjustSliders' function is called by the actionscript in the actions layer in _root. it is used to move the masks of the moving background images
// desired_x and desired_xscale are called on in each slider movieclip
adjustSliders = function (1x:String,1scale:String,2x:String,2scale:String,3 x:String,3scale:String,4x:String,4scale:String,5x: String,5scale:String,6x:String,6scale:String.){

_root.slidingImages_mc.section1_mc.desired_x = 1x;
_root.slidingImages_mc.section1_mc.desired_xscale = 1scale;

_root.slidingImages_mc.section2_mc.desired_x = 2x;
_root.slidingImages_mc.section2_mc.desired_xscale = 2scale;

_root.slidingImages_mc.section3_mc.desired_x = 3x;
_root.slidingImages_mc.section3_mc.desired_xscale = 3scale;

_root.slidingImages_mc.section4_mc.desired_x = 4x;
_root.slidingImages_mc.section4_mc.desired_xscale = 4scale;

_root.slidingImages_mc.section5_mc.desired_x = 5x;
_root.slidingImages_mc.section5_mc.desired_xscale = 5scale;

_root.slidingImages_mc.section6_mc.desired_x = 6x;
_root.slidingImages_mc.section6_mc.desired_xscale = 6scale;

}

I get 13 AS errors- one for each of the lines in the function :o/

*sorry if the first few lines are broken

View Replies !    View Related
Function Went Wrong....very Wrong.
Okey so i made a function that should, make two movieclips (balls) move around bouncing the edges of the screen....
but something is wrong... plz help...
when i start the movie, the whole picture is moved down to the right, and the balls aint moving, thou i can drag them around...

PHP Code:



left = 0;
right = 550;
top = 0;
bottom = 400;
xspeed = 5;
yspeed = 5;
ball01.onPress = doDrag;
ball01.onRelease = noDrag;
ball01.onReleaseOutside = noDrag;
ball02.onPress = doDrag;
ball02.onRelease = noDrag;
ball02.onReleaseOutside = noDrag;
ball01.onEnterFrame = ball;
ball02.onEnterFrame = ball;
function doDrag() {
    this.startDrag();
    this.dragging = true;
}
function noDrag() {
    stopDrag();
    this.dragging = false;
}
function ball() {
    if (!dragging) {
        _x = _x-xspeed;
        if (_x-_width/2<left) {
            _x = left+_width/2;
            xspeed = -xspeed;
        } else if (_x+_width/2>right) {
            _x = right-_width/2;
            xspeed = -xspeed;
        }
        _y = _y-yspeed;
        if (_y-_height/2<top) {
            _y = top+_height/2;
            yspeed = -yspeed;
        } else if (_y+_height/2>bottom) {
            _y = bottom-_height/2;
            yspeed = -yspeed;
        }
    }


View Replies !    View Related
What Is Wrong With This Function
function basement(number) {
if (_root.text_basement == "") {
with (_root.build.walkout) {
gotoAndStop("");
}
}
}
basement("8’ BURIED BSMT w/ SINGLE AREAWAY || 9’ BURIED BSMT w/ SINGLE AREAWAY"," KR-AREA-1");


Thanks for any help.

54

View Replies !    View Related
What's Wrong With This Function?
I'm trying to make a function that will draw a line from one newly created movie clip to the next. The functions i have for creating and scatering the clips work fine. But this one, the one that draws lines between them, does not work. For some reason it always starts the first line from 0,0 instead of the x,y coordinants of the clip movie0. I can not figure out what the hell is going on. I've tried just about everything. At first i thought that maybe this function was being called before the scaterring function finished. So i moved this function's call to a comepletely different button and it still does it.

Here is the function. Tell me if you see anything obvious.

Code:
function Connect(lineName, clip) {
for (i=0; i<numClips; i++) {
_root.createEmptyMovieClip(lineName+i, _root.depth++);
with (_root[lineName+i]) {
lineStyle(1, 0x0000ff, 100);
moveTo(_root[clip+i]._x, _root[clip+i]._y);
lineTo(_root[clip+(i+1)]._x, _root[clip+(i+1)]._y);
}
}
}

View Replies !    View Related
What's Wrong With This Function?
PHP Code:



MovieClip.prototype.nc = function(){
    Math.round( Math.random()*0xFFFFFF );
    myColoredObject = new Color (this);
    myColoredObject.setRGB(myColor);





then i call the function by placing an action on the mc that says:

PHP Code:



onClipEvent(enterFrame){
    nc();


View Replies !    View Related
What Is Wrong With This Function..?
Hello, may i know what is wrong with this function? This is a function which I use to trigger an action with different time duration. When I call this function it just wont work.

function shoot1(){
x=random(2)+1;
trace(x);
if(x==1){
timera1= setInterval (shoota1,1000);
function shoota1() {
clearInterval(timera1);
_root.spider1.gotoAndPlay(2);
}
}
else if(x==2){
timera2= setInterval (shoota2,2000);
function shoota2() {
clearInterval(timera2);
_root.spider1.gotoAndPlay(2);
}
}
}

View Replies !    View Related
What Is Wrong With This Function..?
Hello, may i know what is wrong with this function? This is a function which I use to trigger an action with different time duration. When I call this function it just wont work.

function shoot1(){
x=random(2)+1;
trace(x);
if(x==1){
timera1= setInterval (shoota1,1000);
function shoota1() {
clearInterval(timera1);
_root.spider1.gotoAndPlay(2);
}
}
else if(x==2){
timera2= setInterval (shoota2,2000);
function shoota2() {
clearInterval(timera2);
_root.spider1.gotoAndPlay(2);
}
}
}

View Replies !    View Related
What's Wrong With My Function?
This girl is stuck with her function....
It's doesn't display the table correct....??!!??
Somebody can help me please...??
//
_global.xStart = 24;
_global.yStart = 265;
_global.cell_width = 92;
_global.cell_height = 135;
//
function build_table() {
if (this.list_order<=10) {
pos = this.list_order-0;
} else {
pos = this.list_order-((this.thisSet-1)*10);
}
if (pos<=2) {
this.col = 1;
this.row = pos+1;
} else if (pos>2 & pos<=4) {
this.col = 2;
this.row = pos-1;
} else if (pos>4 & pos<=6) {
this.col = 3;
this.row = pos-3;
} else if (pos>6 & pos<=8) {
this.col = 4;
this.row = pos-5;
} else if (pos>8) {
this.col = 5;
this.row = pos-7;
}
this._x = xStart+((this.col-1)*cell_width);
this._y = yStart+((this.row-1)*cell_height);
}
//

Thanx in advance..
Greetz & kisses,

Karlein...

View Replies !    View Related
What's Wrong With My Function?
This girl is stuck with her function....
It's doesn't display the table correct....??!!??
Somebody can help me please...??
//
_global.xStart = 24;
_global.yStart = 265;
_global.cell_width = 92;
_global.cell_height = 135;
//
function build_table() {
if (this.list_order<=10) {
pos = this.list_order-0;
} else {
pos = this.list_order-((this.thisSet-1)*10);
}
if (pos<=2) {
this.col = 1;
this.row = pos+1;
} else if (pos>2 & pos<=4) {
this.col = 2;
this.row = pos-1;
} else if (pos>4 & pos<=6) {
this.col = 3;
this.row = pos-3;
} else if (pos>6 & pos<=8) {
this.col = 4;
this.row = pos-5;
} else if (pos>8) {
this.col = 5;
this.row = pos-7;
}
this._x = xStart+((this.col-1)*cell_width);
this._y = yStart+((this.row-1)*cell_height);
}
function displayXML() {
_global.element_count = _root.myXML.firstChild.childNodes.length;
for (var i = 0; i<element_count; i++) {
_root.attachMovie("cell", "cell"+i, 1000+i);
}
build_table.apply(_root["cell"+i]);
//
It's displaying everything but not correctly....(the loadXML is done etc...)
Can't figure it out....

Thanx in advance..
Greetz & kisses,

Karlein...

View Replies !    View Related
What's Wrong With This Function Code ?
Here's the function code I have in the main timeline:

function submenu (here) {
onClipEvent (enterFrame) {
if (_root.here == false) {
this.gotoAndStop(1);
} else if (_root.here == true) {
this.gotoAndStop(2);
}
}
}


...is it because i have onClipEvent in the code?
I have several mc's that need this code, and using a function would be a time saver....

View Replies !    View Related
What Is Wrong With This Siple Function ?
Hi, I have 5 keyframes with pictures and I want jump from first to second etc after changing their alfa to 100... it menas, on the first keyframe to fade in and then keyframe 2 after fading in keyframe 2 jump to keyframne 3 etc etc...I have this code but after fading in, nothing happens...???

stop();
mymc._alpha = 0
this.onEnterFrame = function()
{
mymc._alpha = mymc._alpha + 15
if(mymc._alpha==100)
{
this.onEnterFrame = undefined;
}
}
gotoAndPlay(2);

View Replies !    View Related
What Am I Doing Wrong With OnPress Function?
Hi

I have a button on my time line that worked using the following Action Script:


PHP Code:



var menuBtnPressed:Boolean = true;

menuButton_mc.onPress = function() {
    
    
if(menuBtnPressed) {
trace ("pressing it now changes btnPressed from true to false");
bottomBar_mc.gotoAndPlay("menu_open");
menuBtnPressed=false;
menuPanel_state = 1

} else {
trace ("since i now = false i cant run the previus code so i had to run this block and now i set back to true");
bottomBar_mc.gotoAndPlay("menu_close");
menuBtnPressed=true;
menuPanel_state = 0
}






But i needed to have it in a movie symbol with some other stuff. So i created a movie clip symbol called menuAll_mc with my button (menuButton_mc) in it.
And changed the code so I have menuAll_mc.menubutton_mc.onPress etc.

Like this:



PHP Code:



var menuBtnPressed:Boolean = true;

menuAll_mc.menuButton_mc.onPress = function() {
    
    
if(menuBtnPressed) {
trace ("pressing it now changes btnPressed from true to false");
menuAll_mc.bottomBar_mc.gotoAndPlay("menu_open");
menuBtnPressed=false;
menuPanel_state = 1

} else {
trace ("since i now = false i cant run the previus code so i had to run this block and now i set back to true");
menuAll_mc.bottomBar_mc.gotoAndPlay("menu_close");
menuBtnPressed=true;
menuPanel_state = 0
}





This doesn't work!!! Can anyone see why?

View Replies !    View Related
Whats Wrong With My Function? :(
Nothing seems to work today!!

On my button I have this AS:
on (release) {scroll();
}

And in my actions layer I have this:
myFunction = scroll(); {
if (_root.SUB._x>440) {
_root.SUB._x += -30;
} else if (_root.SUB._x>-30) {
_root.page._x += (-40-_root.page._x)/8; _root.SUB._x += (0-_root.SUB._x) /2;
}
};

I'd be truly greatful if someone could prevent me from pulling my hair out and having to spend the entire day trying to find out why this wont work...or at least what i'm doing wrong!

View Replies !    View Related
Function With Properties What's Wrong?
Hi,

What am I doing wrong

Code:
function setNavTxt(name_mc:MovieClip, i:Number, navArray:Array) {
trace(name_mc);
trace(i);
trace(navArray);
}
setNavTxt(test,2,testArray);
gives me

Quote:




undefined
2
undefined

View Replies !    View Related
Whats Wrong With This Function?
ActionScript Code:
</p>
<p>function boatdrag() {</p>
<p> i++</p>
<p> _root[båter[i]].onPress = function() {</p>
<p> pressed = true</p>
<p> }</p>
<p> if(i > båtNR) { i = 1 }</p>
<p>}</p>
<p>



båter = an array with movieclip names
båtNR = length of båter-array
i = counter
problem = when i click one of the movieclips in the array, the counter continiues, and that function is only run when pressed == false

View Replies !    View Related
Whats Wrong With This Function?
ActionScript Code:
function moveArrows() { for(var i:Number = 1; i <= 20; i++) {  if(_root[arrows[i]]._y < arrowsGround[i] + 25) {   for(var j:Number = 1; j <= 200; j++) {    if(_root[arrows[i]].hitTest(_root[enemys[j]].Hhitbox_mc)) {     enemysHP[j] -= 100    } else if(_root[arrows[i]].hitTest(_root[enemys[j]].Bhitbox_mc)) {     enemysHP[j] -= 50    } else {     //rotation formula     trace(i)     AX = _root[arrows[i]]._x     AY = _root[arrows[i]]._y     OAX = _root[arrows[i]]._x - arrowsXdir[i]     OAY = _root[arrows[i]]._y - arrowsYdir[i]     if(AX - OAX >= 0) {      grad = 1/(Math.PI/180/Math.atan((AY - OAY)/(AX - OAX)))     }     if(AX - OAX < 0) {      grad = 1/(Math.PI/180/Math.atan((AY - OAY)/(AX - OAX))) + 180     }     //movement     _root[arrows[i]]._x += arrowsXdir[i]     _root[arrows[i]]._y += arrowsYdir[i]     arrowsYdir[i] += gravity     _root[arrows[i]]._rotation = grad         }   }     } else {   if(arrowsOldTime[i] == 0) {    arrowsOldTime[i] = Math.round(getTimer() / 1000)   }   if(arrowsOldTime[i] - (Math.round((getTimer()/1000))) == -2) {    removeMovieClip(_root[arrows[i]])   }  } }}


it traces i, however, the arrow wont move :S, the path is right too, i dont det it...

View Replies !    View Related
Problem With Function, Whats Wrong?
sup all..
im new to flash mx 2004 and do not use actionscript 2.0 (yet)..
im makin a website for my county (monaghan, in ireland) community games..
im workin on a page that has a map in it with all the parishes (teams) in it and also displays some info in it..
i created a function (the first function i ever made before) that SHOULD copy a movie clip from the library (ID = "area") and onto the map..
the clip contains a dynamic text box that SHOULD displays the name of the team..
when i run the script, the clip is coppied from the library to the left side of the screen, but not to the position i asked it to go to..
i get an error msg
Target not found: Target="_level0.monaghan.Bawn/Latton" Base="_level0"
printed to the output screen..
(i only have one team put in so far, until i get the script goin)
here is the code that i am using:::

function create_area(area_name, posx, posy, chair, chair_phone, chair_address, chair_email, sec, sec_phone, sec_address, sec_email, clip_depth) {
_root.monaghan.attachMovie("area", area_name, clip_depth);
tellTarget (_root.monaghan[area_name]) {
this.area_display_name = area_name;
this.posx = posx;
this.posy = posy;
this.chair = chair;
this.chair_phone = chair_phone;
this.chair_address = chair_address;
this.chair_email = chair_email;
this.sec = sec;
this.sec_phone = sec_phone;
this.sec_address = sec_address;
this.sec_email = sec_email;
this.clip_depth = clip_depth;
this._x = posx;
this._y = posy;
}
}
bawn_latton = new create_area("Bawn/Latton", 100, 100, "Gerry Naughton", "0429741475", "Bowelk, Ballybay", "gjnaughton@hotmail.com", "Margaret McElroy", "0872911431", "7 Lisdrumclave, Latton, Casstleblayney", "N/A", 2);

could somebody please tell me why the script wont work??

thanks,
-declan

View Replies !    View Related
Whats Wrong With This Simple Function?
using this code to look for instances around a depth


Code:
function systemHalt() {
for (i=300; i>=401; i++) {
item = _root.getInstanceAtDepth(i);
trace (item)
}
}


with this
Code:
onEnterFrame = function () {
systemHalt()
}
to call it, but all it returns is undefined, once. not continously as you would expect

where is going wrong?

View Replies !    View Related
Function Called At Wrong Time?
I'm trying to call a function (loadLevel()) from within another function (Incarnate()), the problem is, the function loadLevel that I'm calling is executing after the rest of the Incarnate function, so I can't access the array created by the loadLevel function in the Incarnate function!

This is the code:

ActionScript Code:
package {
   
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.net.*;
    import flash.events.*;
    import flash.text.*;
   
    public class Incarnate extends Sprite {
        // Create a bitmapData object which will hold the bitmap data for the currently displayed world
        private var world_bmpData:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x666666);
        // Create a bitmap display object to hold the bitmapData object! [Otherwise we can't display it on screen!]
        private var worldBitmap:Bitmap = new Bitmap(world_bmpData);
        // This is used to load the XML level data.
        private var xmlLoader:URLLoader;
        //This variable is used for storing XML level data.
        private var tileData:XML;
        // This array holds the locations/types of all tiles in the world map.
        private var aLevelMap:Array=new Array();
        // This variable brings in and holds the Bitmap Data from our library tilesheet image.
        // The arguments are width, height.
        private var tile_bmpData:BitmapData = new tileSheet(80,40);
        // This rectangle is used to select the tiles for copying pixels to the world bitmap
        private var tileType:Rectangle;
       

        public function Incarnate():void {
            loadLevel();
            trace ("aLevelMap after loadLevel called is " + aLevelMap[1]);
           
            // add the main bitmap
            //addChild(worldBitmap);
        }
       
       
        private function loadLevel():void {
            // Load the XML file and call the loadComplete function to create a 2-dimensional array of tile locations.
            xmlLoader = new URLLoader();
            xmlLoader.addEventListener(Event.COMPLETE,loadComplete);
            xmlLoader.load(new URLRequest("level1.xml"));
           
        }

        private function loadComplete(evt:Event):void {
            tileData = new XML(xmlLoader.data);
            //For every column in the XML file
            for each (var vCount:XML in tileData.tilecol) {
                // Grab the values of the rows, convert the list to an XML string, and split them into an array,
                // then append this array to the end of aLevelMap array, making a 2-dimensional array.
                // This means Tiles can be accessed by their x,y coordinates by calling aLevelMap[x][y]
                aLevelMap.push( vCount.tilerow.text().toXMLString().split("
") );
            }
            trace("aLevelMap at end of function is " + aLevelMap[1]);
        }
    }
}

The array I'm trying to access is called aLevelMap, and the two traces come up in this order:

aLevelMap after loadLevel called is undefined
aLevelMap at end of function is 5,5,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0

so it is clearly running the trace in loadLevel() after the one in Incarnate(), which is causing big problems

Any help would be greatly appreciated!

Thanks in advance!

Edit: Removed non-essential/commented out code for easier legibility

View Replies !    View Related
Choose From Array Function ,whats Wrong?
hello everybody,

here is what i wanna make, i have an array of objects
i want to display this array randomly at certain condition ,
and display only certain objects from the array at another condition, so i have used this code 4 random display
---------------------------------------------------
if(rand==1)
{index = Math.floor(Math.random()*quiz.length);}
---------------------------------------------------
and it worked good

&&&& i used this code for choosing only no. of objects to display.

----------------------------------------------------
if(choose==1)
{
indexarray=quno.split(",");
numQuestions =Number(choosearray.length);

for (j=0;j<indexarray.length+1;j++)
{
choosearray =new Array (indexarray.length);
choosearray[j]=quiz[Number(indexarray[j])];
}//end of for


index = Math.floor(Math.random()*choosearray.length);
}//end of if

//-------------------------------------------------
where quno is a variable loaded from a txt file
quno=1,2;

but with sorrow it didnt work , so plz help me to pick what is going wrong, thanks in advance.
[Edited by rasha ali on 06-16-2002 at 01:42 PM]

View Replies !    View Related
Function Doesn't Work... Whats Wrong?
I don't know if flash allows this but I'm calling the function:

_root.frameEASE(_root.easefade(100,0));

I don't know what the things inside the parenthesis are called (function variables?). _root.frameEASE is a function, and in it's parenthesis is the callback, and in the parenthesis of the callback function is (alpha value to fade to, callback).

Each of these functions work fine when alone, but when i put the easefade function in as the callback for the other function then it is executed right away. Does flash allow having two or more layers of function variables (IE function variables within function variables like im trying to do).

View Replies !    View Related
Flash XML Function OnLoad Reports Wrong Document Lenght
Dear all,

I am building an application using flash that reads XML documents that contain information such as date/course/file-type/file-text about a set of documents. The content of these text documents could be in spanish, english, french, etc., in the xml document, the content is copied in a <![CDATA[ ]] tag.

The function onLoad behaves incorrectly when the text contained in the <![CDATA[ ]> tag has spanish characters such as accented vowels, or – or “ ...
onLoad stops reading the xml file and reports a wrong document length. This function stops counting the xml document nodes when it encounters text that has any of the characters mentioned above.

The following encoding is used:
<?xml version="1.0" encoding="ISO-8859-1" ?>

An example of one node of an xml document that causes the onLoad function to stop counting is copied here:

- <text>
- <![CDATA[
AutoevaluaciónAprendí muchísimo en esta clases de español. Primero, me gusta que la clase fue muy íntima porque no había demasiados estudiantes en la clase. También, los estudiantes que asisten la clase estuvieron confiados a aprender la lengua y convertirse en hablantes fluidos. Además, usted estaba muy dedicada a ayudándonos a alcanzar estas metas. He visto una mejora en casi toda parte de mi sistema de habilidad español. Puedo escribir ensayos largos de varios tipos y temas. Puedo hacer proyectos de investigación totalmente en español. Aprendí como dar presentaciones largas en español enfrente de una clase. También, empecé a escribir más poesía en español este cuatrimestre. Yo había esperado que mis destrezas orales habría mejoradas más. Es obvio que yo necesito practicar más. En el futuro, espero que yo continuo a mover más cerca y más cerca de mis metas. Mil gracias para una clase fenomenal.
]]>
</text>

Can someone explain what is wrong with the text? I have read that using the encoding="ISO-8859-1" extends the character set to include spanish, french and other languages.

Thanks all for your help,
mari

View Replies !    View Related
Creating A Function
Hi,

I'm a bit stuck here. I have a flash movie which contains lots of separate movie clips they all have this code attached:

onClipEvent (load) {



x = Math.random();



this._quality = "high";
this._x = random(250) + 25;
this._y = random(250) + 25;
speed = random(10) + 10;
diff = 250;
}
onClipEvent (enterFrame) {
rand = random(20);
if (rand == 1) {
overshootx = random(diff) - diff/2;
}
if (rand == 2) {
overshooty = random(diff) - diff/2;
}
// chase
target_x = _root.lead._x + overshootx;
target_y = _root.lead._y + overshooty;
this_x = GetProperty(/:this,_x);
this_y = GetProperty(/:this,_y);
distance_x = target_x - this_x;
distance_y = target_y - this_y;
setProperty (/:this, _x, this_x + (distance_x/speed));
setProperty (/:this, _y, this_y + (distance_y/speed));

_xscale = _yscale = 35*(Math.sin(x)+3);
x+=0.025
}



However, when played back on a PC of a lower spec than mine it is very slow. I know that this is because the player is having to read the same code again and again on every MC. Is there a way I could incorporate this code and use it only once, thus speeding everything up????????? Could you explain it fairly simply as I'm quite new to Flash.

Thanks.

View Replies !    View Related
Creating A Function
This function is on Frame 1 of my main timeline
Code:
function sceneryMotion() {
k += .2;
currentX = getProperty(this, _x);
currentY = getProperty(this, _y);
this._x = currentX-(k*20);
this._y = currentY+(k*3);
thisWidth = getProperty(this, _width);
this._width = thisWidth*1.18;
thisHeight = getProperty(this, _height);
this._height = thisHeight*1.18;
if (this._y>=+400) {
this.removeMovieClip();
}
}
This is on the first frame of a MC that gets attached to the _root
Code:
onEnterFrame = function () {
sceneryMotion();
}
Why is this not working?

View Replies !    View Related
Creating A Function?
I am a beginner at actionscript but wanting to "know" more
I have a set of varirables that I repeatedly check and attach an action to based on the condition
I have placed this list of actions on different "labeled" frames through out my movie
or in this case, different key places on a website

for example: each loaded movie has a "status" that is declared on it's own 1st frame, and I check it per level that it is loaded on to control that level.

if (_level1.status=="loaded"){
unloadMovieNum(1);
}

I was thinking it might be better to put this list of script into a function, so that when I need to check for these conditions I just call up the function (and when I need to add an additional condition I just add to the function or "master list of variable")

not sure how to do this and then call it up
the following is my attempt at defining a function named "checkvars"

function checkvars() {
if (_level0.mc04loaded=="yes"){
_level4.gotoAndStop("Blank");
}
if (_level0.mc03loaded=="yes"){
_level3.gotoAndStop("Blank");
}
if (_level0.mc02loaded=="yes"){
_level2.gotoAndStop("Blank");
}
if (_level0.mc01loaded=="yes"){
_level1.gotoAndStop("Blank")
}
if (_level5.status=="loaded"){
unloadMovieNum(5);
}
if (_level6.status=="loaded"){
unloadMovieNum(6);
}
}

How do I call up the function in a later frame in the movie
so that I can check for all these conditions at once

View Replies !    View Related
Help With Creating A Function?
Right now I have three MC's on the stage. One is the main window, and there is another that sits behind it as a frame. When a user clicks a button they scale to certain size. My nav is directly below the main window and stays 15 px below it at all times sliding around with it. So right now I have this onClipEvent on my main MC, and the frame MC that waits for the user to click a button before scaling.
code:
onClipEvent (load) {
a = 1;
d = .30;
_x = 300;
_y = 300;
newFrameWidth = 306;
newFrameHeight = 306;
}
onClipEvent (enterFrame) {
ax = (newFrameWidth-_width)*a;
ay = (newFrameHeight-_height)*a;
vx += ax;
vy += ay;
vx *= d;
vy *= d;
_width += vx;
_height += vy;
_root.nav_mc._y = this._y+this._height/2+15;
//_root.navBg_mc._x = this._x-_root.navBg_mc._width/2;
}


My button actions look like this.
code:
nav_mc.mainNav_mc.button1_btn.onRelease = function(){
_root.bg_mc.newWidth = 550;
_root.bg_mc.newHeight = 400;
_root.frame_mc.newFrameWidth = 556;
_root.frame_mc.newFrameHeight = 406;
_root.nav_mc.bg_mc.newWidth = 550
_root.nav_mc.bgFrame_mc.newFrameWidth = 556;
}
I need to create a function that does this scaling instead of a clipEvent. I have a MC on the stage called content_mc where all my content will be loaded. So I want the scaling to be done, then if the scaling is complete want content_mc to move to the proper place to be able to display the new content. I've attached a source file of what I have so far. I appreciate help with this, i'm no good at writing functions with multiple purposes. the source file is from a Mac, MX04 pro. Thanks again.

View Replies !    View Related
Creating Function
I have a particular series of events that I want to include in the actionscript of several different movie clips so I assumed the best way to do this would be to define a function on the main timeline of the flash document, but I'm running in to some problems, probably because I don't quite know the ins and outs of functions regardless I was hoping someone might help educate me. So far I have tried the following code

code: _global.zoomFunction = function(totalPanels:Number):Void{
for (var i:Number = 1; i<=totalPanels; i++){
this.attachMovie("dummyHit","dummy_"+i,i);
this["dummy_"+i]._x=this["panel_"+i]._x;
this["dummy_"+i]._xscale=this["panel_"+i]._xscale;
this["dummy_"+i]._y=this["panel_"+i]._y;
this["dummy_"+i]._yscale=this["panel_"+i]._yscale;
this["dummy_"+i].onRelease = function () {
_root.panel_0._x=totalWidth/this._width*(_root.current_x-this._x);
_root.panel_0._xscale=_root.current_xscale*totalWi dth/this._width;
_root.panel_0._y=totalHeight/this._height*(_root.current_y-this._y);
_root.panel_0._yscale=_root.current_yscale*totalHe ight/this._height;
_root.current_x=_root.panel_0._x;
_root.current_xscale=_root.panel_0._xscale;
_root.current_y=_root.panel_0._y;
_root.current_yscale=_root.panel_0._yscale;
this.removeMovieClip();
}
}
}

And then within the movie clips that should have this code I have tried both:

this.zoomFunction(4);
&
zoomFunction(4);

I have also tried defining the function without totalPanels since this is a local variable that each movie clip contains.

Please let me know what I am doing wrong.

Thanks

View Replies !    View Related
Creating A Function
I have this script that loads externals swf, tell them to stop and hide, and then it tells flash that as each externals swf are fully loaded, visible = true and it plays them on the order they finish loading.


Code:
var MasterLoader:MovieClipLoader = new MovieClipLoader();
var MasterListener:Object = new Object();

MasterLoader.addListener(MasterListener);

// when the movie starts loading, stop it, and hide it
MasterListener.onLoadStart = function(target_mc){
target_mc._visible = false;
target_mc.stop();
};

// when the movie has loaded, play and show it


MasterListener.onLoadInit = function(target_mc){

target_mc._visible = true;
target_mc.play();
};

//---Loading external swf----\
MasterLoader.loadClip("swf1.swf", 47);
MasterLoader.loadClip("swf5.swf", 46);
MasterLoader.loadClip("swf6.swf", 45);
MasterLoader.loadClip("swf7.swf", 44);
MasterLoader.loadClip("swf4.swf", 43);
MasterLoader.loadClip("swf3.swf", 42);
MasterLoader.loadClip("swf8.swf", 41);
MasterLoader.loadClip("swf2.swf", 40);
MasterLoader.loadClip("swf9.swf", 39);
MasterLoader.loadClip("swf10.swf", 38);
MasterLoader.loadClip("swf11.swf", 37);
MasterLoader.loadClip("swf12.swf", 36);
MasterLoader.loadClip("swf14.swf", 35);
MasterLoader.loadClip("swf13.swf", 34);



But I want to control the visible and playing part of the script, by putting that part inside a function, passing a parameter "nextSWF" that I could later give it a value or name (outside the function) of one of the already loaded swf of my choice and tell it to play, so in that way the already loaded swf will play in the order I choose to. Example: nextSWF = “swf1.swf”

This is the visible = true and play part of the script that I want to put into a function


Code:
MasterListener.onLoadInit = function(target_mc) {
target_mc._visible = true;
target_mc.play();
};



thanks

Alex

View Replies !    View Related
Creating A Function
hi all,

I have for like 10 mc's in my scene (there will come more, about 270 finally)
now i have this code ( darzak helped me to make it :P, on this same forum ):


ActionScript Code:
onClipEvent (enterFrame)
{
    var bHit = this.hitTest(_root.area);
    if (bHit && picture_mc1 == undefined)
    {     
   
    xwidth = this._width;
    yheight = this._height;
   
   
this.createEmptyMovieClip("picture_mc1",this.getNextHighestDepth());
preload_resize("tiles/r01/001.jpg", picture_mc1, xwidth, yheight);

());

    } else if (!bHit && picture_mc1 != undefined){
        this.picture_mc1.removeMovieClip();
    }
}


now i have to add this whole script to EACH mc, i was thinking of make a function of it and put this in the main layer and then in each moveclip type in something like:

getimg("tiels/r01/001.jpg", "picture_mc1")

but dunno how to create this fuunction??
does someone have a clue?

ur help will be really really appreciated

View Replies !    View Related
Help With Creating A Function
Hello all

I am trying to change some code to work a little more efficiently and need some help.

scenerio:

I have an interactive quiz. There are five sentences with blanks and an answer bank on the page. The user, clicks on the word and drops it into the appropriate sentence. Everything is fine, except within the coding, I am finding myself duplicating inline functions more and more when I want to transfer the code into another quiz with more options. And I know the same thing can be accomplished more effeciently with maybe an array and a user-defined function.

Here is basically the snippet of code I am referring to:

Code:
// Answer Sheet //
answer1.answer = "answer1";
answer2.answer = "answer2";
answer3.answer = "answer3";
answer4.answer = "answer4";
answer5.answer = "answer5";


// in-line functions to control drag and drop from answer bank

answer1.onPress = function() {
_parent.currentDrag = "answer1";
saveX = answer1._x;
saveY = answer1._y;
startDrag(answer1);
};
answer1.onRelease = function() {
stopDrag();
dropClip = eval(this._droptarget);
if (dropClip.answer == _parent.currentDrag) {
dropClip.gotoAndPlay("correct");
duplicateMovieClip(answer1, "answer1"+completedNum, _root.getNextHighestDepth()+completedNum);
setProperty("answer1"+completedNum, _x, dropClip._x+2);
setProperty("answer1"+completedNum, _y, dropClip._y+2);
} else {
dropClip.gotoAndPlay("wrong");
}
answer1._x = saveX;
answer1._y = saveY;
checkCompleted();
};
answer2.onPress = function() {
_parent.currentDrag = "answer2";
saveX = answer2._x;
saveY = answer2._y;
startDrag(answer2);
};
answer2.onRelease = function() {
stopDrag();
dropClip = eval(this._droptarget);
if (dropClip.answer == _parent.currentDrag) {
dropClip.gotoAndPlay("correct");
duplicateMovieClip(answer2, "answer2"+completedNum, _root.getNextHighestDepth()+completedNum);
setProperty("answer2"+completedNum, _x, dropClip._x+2);
setProperty("answer2"+completedNum, _y, dropClip._y+2);
} else {
dropClip.gotoAndPlay("wrong");
}
answer2._x = saveX;
answer2._y = saveY;
checkCompleted();
};

// The same inline function is written up to answer5
Wouldn't it be better to create an array for the first part of this code [answers 1-5] and then a user-defined function "dragAndDrop();" to run the drag and drop code based on a variable defined by the array?

I don't have a lot of experience in writing arrays so I can't logically think how this should be written. If anyone can help, I'd appreciate it.

thanks!

View Replies !    View Related
Help With Creating A FUNCTION
I'm creating a menu using MC for each menu item. Each menu item MC consits of two frames. One for when the selection isn't clicked on, and one for when the selection has been clicked. Basically, I figure I need to write a function to decide what button has been clicked on and also which one was the last that was clicked on so I know which one to send back to it's first frame (I know it sounds confusing).

I could really use the help with writing a function. I checked out the tutorial, but it didn't seem to explain what type I should use and how to code it.
All I want is when you click on a text button that it goes to BOLD and the last button that was clicked on goes from BOLD to normal.

View Replies !    View Related
>>> Creating A Search Function?
Please, Please could someone help me out here! How do you create a search function which i want to put at the corner of my html site, i can't use a html search engine due to cgi and php etc are'nt enambled on my ISP So FLASH is the only way i can do it really.

But i know theres a tutorial on how to do it like the "Active search list" tutorial found in the "interactivity" section of Flash Kit. But to be honest that isn't really good enough basically its a bit to big i want a search box and a GO button at the corner of my site (a-bit like the search site thing on this forum on the orange strip near flash jobs!) but when you clcik on go on that it takes you to a new page well, what i would love to have and i would be gratefull if someone could tell me how to do it! is sarch box normal like the one i just mentioned but when the user clciks on go it appears in a flash pop-up window (like the flash ad's you know) but instead showing the results plus a scroller would be nice together with of course a 'close' button...

... can that be done??? it would really work well for what i'm doing!!!

Thanks
Soniccc

View Replies !    View Related
A Question Regarding Creating A Function
Hello Everybody!


I am looking for a way to create a function within an EmptyMovieClip.

I created a function that its parameter is an MC, and
when I want to enter a parameter inside, I have to enter the path of the MC I want to control, I mean:

if I want to control "solo1" and it is within the emptyMovieClip called ePhotos, I have to enter the parameter:

ePhotos.solo1

so flash will recognize the MC.

what I want to do is to enter ONLY "solo1" as the parameter, and the function will already be in ePhoto.
but the thing is that I don't know how to declare the function inside the ePhoto because it is an emptyMovieClip that I created in AS.


can anyone help me with that?


THANKS!!!!!!

View Replies !    View Related
Creating A Fade In Function
I'm using this fade in function. I have seen it used other times in photo galleries. Fading in by alpha each .jpg loaded into a MC. The problem I am having is working it into my existing movie. I have a main movie that loads another swf. Inside that swf it loads three diffrent .as files. So I am getting loast with the paths. I have tried everything. Putting the call to the fadeIn(); function on the first frame and putting it on the button. I'm so confused. If someone can help I can email you a zip of the files. Just send me a message. Thanks.

MovieClip.prototype.fadeIn = function() {
this.onEnterFrame = function() {
if (this._alpha<100) {
this._alpha += 5;
} else {
delete this.onEnterFrame;
}
};
};

View Replies !    View Related
Creating An Empty Mc Within A Function
I'm trying to write a function that will dynamically create an empty mc with a rectangle. The instance name will be a parameter. However, I can't figure out how to get variables on the left side, i.e. variable.border.

Here is my current function :

Code:
function create_menu_button (instanceName, depth, txt, x, y) {
textname = instanceName+'Text';
_root.createEmptyMovieClip(instanceName, depth);
instanceName.beginFill (0xFFFFFF, 100);
instanceName.lineStyle (2, 0x000000, 100);
instanceName.moveTo (0, 0);
instanceName.lineTo (100, 0);
instanceName.lineTo (100, 50);
instanceName.lineTo (0, 50);
instanceName.lineTo (0, 0);
instanceName.endFill();
instanceName._x = x + 100;
instanceName._y = y;

instanceName.createTextField(textname,2,0,0,100,50);
instanceName.textname.text = txt;


};
it makes the emptymovieclip alright, but all the changes to that instance don't work, so I don't get the rectangle or the textbox.

Any help?

View Replies !    View Related
Creating In One Function, Accessing From Another
i guess it's simple, but i just can't do it. I create some controls in a function (eg. a slider and a textField) and then i want to access their properties from another function.

The way to go around it is to call the 2nd function from the first and pas the objects as arguments. But that's not pretty. There has to be some other, simpler way. Right?

View Replies !    View Related
Creating A General Function
Hi,

I have some math functions which I want to use all over my app,
for example I created a PolarToCartesian function.
How do I use it like the various math functions?

Thanks,
Guy.

View Replies !    View Related
Creating A Replay Function
Can anybody advise me on how I get a piece of text to work as a replay function?

Regards,

Coxdabd.

View Replies !    View Related
Dynamically Creating A Function
I need to give a movieclip a function during runtime. I have done this before got have forgotten. Hopefully the code below will highlight what I am doing although it is incorrect syntactically speaking.







Attach Code

this.ball_mc = function(){ trace("Ball_mc reset method was invoked.") };

this.ball_mc.reset() = function { trace("Ball_mc reset method was invoked.") };

reset();

View Replies !    View Related
Creating A Download Function
Hi guys,

I'm wondering is it possible to create a function that allows user to download something.

This is the situation, I have a bunch of pictures, i want to create a button so that, when someone click on it, there will be a pop-up (similar to those in Internet Explorer when you download something ) with the "open", "save as", and "cancel" function.

View Replies !    View Related
Creating A Function And Calling It.
How do i create a function with a set of properties for arrayed items( myBtns[i] )?-- and how to call the function for execution

View Replies !    View Related
Creating LoadMovie Function (resizing)
Hi,

I'm trying to create a function that allows me to pop up a window, specifying three things:

the xscale of the window
the yscale of the window

a swf to load into the window

this will allow me to load relevant images into my module at will, just knowing the percentage size that I need my window to be.

this is how it's structured:

function popWin (swf, xLength, yHeight) {
_root.attachMovie("popUp", "newWin", 0);
_root.newWin.border._xscale = xLength;
_root.newWin.border._yscale = yHeight;
loadMovie (swf, _root.newWin.target);
}

border is within newWin, and the target for the loaded MC is on the layer below.

My problem is this:

I cannot get the loaded mc to stay within the window, as the xscale and yscale adjust the xpos and ypos. If I try setting them all to 0 I get some strange results also, I'm loading my swf onto a mask layer - is this not possible?

all help as always will be much appreciated,
thanx tom

View Replies !    View Related
Creating A 'History' Function In Flash
Hi People!

I'm looking to create a 'History' function within the a website that I am producing for a client.

The whole site is created in Flash

I'm thinking that it will be case of assigning variables to MovieClips (that hold the content sections), and then use these variables to build a history section that will be displayed in the form of a 'tab' on the side of the page.

However, although I can guess that it uses variables, I'm not quite sure how to go about it.

Does anybody have any ideas.

They will be much appreciated

Cheers

Deadhands

View Replies !    View Related
Creating A Function For Dynamic Content
hi,

I ve got a question and hopefully someone can answer this, i am working on a photoablum newsletter thingy and after spending much of the night hard coding the values, i am sure that there is something amiss with the way i am doing this. I have read bits and pieces about creating functions to handle some of the repetative stuff and dynamically populating content on the stage.
So my questions come down to this:

1) i want to be able to have flash read a text/xml/db file to
determine how many images are going to be added to the
movie.

2) I need to have flash populate my stage with the appropriate
number of movie clips and assign the appropriate image to
load once the thumbnail btn has been clicked.

That should just about do it. If you would like to see what i am trying to do please point your browser here

Once again i have hard coded all of this and my movie is way tooooo big for the dial up audience that i am sure to have for this. I appreaciate any and all help!

cheers!

View Replies !    View Related
Creating A History.back Function In AS ?
Sorry,

this might be real easy but im not thinking too straight at the momment, im rushed to get this darn site done . How would one create a function which remembers the previous frame and even movie the user was on (in actionscript) ?? Oh and not just _currentframe-1 as the user is going to be jumping frome various frames

Its for a flash website, im essentially just trying to create the equivalent of the JavaScript history.back(-1) function..

I thought of using the watch() object and continually storing the oldVal in a var in the callback function but for some darn reason the value of oldVal is undefined!? Im up for any other solutions !

View Replies !    View Related
Question About A Creating Global Function
Hello

I want to create a function that I will write it on the first frame of my movie, and than I will be able to call it from any frame or MC that I want in my entire movie.

I think it is called prototype or something like that, but even so I don't understand exactly how to do that.

can anyone help me???

Thank You!

View Replies !    View Related
Creating Rollover Function Dynamically
Hi all,
Here I am again with another problem. I've managed to get it to work to load in a XML file that contains image names. So once the XML file has been read I will load those images dynamically into an empty movie clip which on it's turn is located in another movieclip . Every image has it's own name for a movieclip like (holder_mc1, holder_mc2 etc. etc). All those movieclips are loaded into 1 main movieclip called MainClip. Sofar it works perfectly. Now I need to create a rollover effect for each movieclip contained in MainClip, so I figured I would create a loop (as I also use it for loading the images) but that's when it gets messy. It doesn't create a rollover effect for all the images. Only just one. Here's a bit of my code (dest_movie_clip contains for example the movie clip the images are added to like _root.image_mc):


Code:
for (i=0;i<4;i++)
{
eval(dest_movie_clip).onEnterFrame = function()
{
eval(dest_movie_clip+".holder_mc"+i).onRollOver = function ()
{
_root.test_text.text = "aaa";
}
eval(dest_movie_clip+".holder_mc"+i).onRollOut = function ()
{
_root.test_text.text = "";
}
}
}
This piece of code is also used for loading the images dynamically, but it doesn't seem to work for the onEnterFrame, I think it has something to do with the onEnterFrame = function(). But I am hoping someone solved this problem.

Thanks for any help..


Edit: Solved the problem once again with some help of a good dynamic image tutorial.

View Replies !    View Related
Creating A Global Function In A Class
I want to create a function inside a class that can be accessed globaly. I have tried this:


Code:
public function myFunction(){
//do stuff
}
I have created some code for a button:

Code:
btn_theButton.onRelease = function() {
myFunction()
}
It does not work. I tried to add _global to the front of the function too, but it caused a syntax error.

View Replies !    View Related
Creating A Function In A Movie Clip.
OK - so i have this method (which is in a class, if that matters) that receives a MovieClip. I want the method to create a function inside this movie clip and link it to the onEnterFrame even of the movie clip.

What kind of syntax can i use for this? I'm familiar with creating and deleting events, but not familiar with creating functions dynamically.

Thanks for your help!

View Replies !    View Related
Creating A Search Function In Flash
Hi

I have this long list of video files(some 500 of them) to be linked to my flash interface. I am looking at the option of creating a search engine such as that when the user key in some keywords, it will search thru my list of video files and bring up the appropriate files. (results will show names of files first then user can choose to click on those that they want to view)

Could this be possibly be done in flash? Anyone can give me some suggestions? thanks!

View Replies !    View Related
Creating A Simple Mc Rollover Function
hey guys,

i do AS so rarely that i forgot how to do this...

basically i have a mc that i want to use as a button.

frame 1 is the initial state with a stop() action on it. frame 10 is the full rolled over state, also with a stop() action on it, and frame 20 matches frame 1.

so basically i want the button to animate frame 1-10 if they rollover, and animate frame 11-20 when they roll off. i would also like it to detect the current frame, so like if the user rolls off and rolls back on at frame 15, it will play backwards to the mouseover state (frame 10).

i hope im making myself clear. thanks!

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved