Function Argumet Needed?
I've got this external as file on a folder called myClass:
Code: package myClass{
import flash.display.MovieClip; //importo il costrutto che mi serve per usare l'embed font sullo stage import flash.display.*; // importo i costrutti per la visualizzazione degli oggetti import flash.events.*; // importo i costrutti per gli eventi import flash.net.*; // importo i costrutti per l'xml import flash.display.Sprite; // importo il costrutto per lo sprite import flash.display.Shape;// importo il costrutto per disegnare forme import flash.filters.DropShadowFilter;// importo il costrutto per il filtro ombra
public class Attachmovie extends MovieClip {
//--------------------------------------------------------------Constructor----------------------- public function Attachmovie() {
var alt = 150;//dichiaro la variabile per settare l'altezza delle thumbs var larg = 300;//dichiaro la variabile per settare la larghezza delle thumbs var index:Number;//dichiaro la variabile indice per caricare le foto da xml
var filtro = new flash.filters.DropShadowFilter;//imposto la variabile filtro per l'effetto ombra filtro.color = 0x3C3C3C;//imposto il colore dell'effetto ombra filtro.distance = 5;//imposto la distanza dell'effetto ombra //----------------------------------------------------------Create a Sprite object--------------- var s:MovieClip = new MovieClip();//imposto il contenitore totale sprite s.x = 10;//imposto la coordinata x del contenitore s.y = 10;//imposto la coordinata y del contenitore addChild(s);//visualizzo il contenitore
//----------------------------------------------------------create loader object-------------------- var ldrLarg = 0;//setto la larghezza della foto centrale var ldrLung = 0;//setto la lunghezza della foto centrale
//--- Funzione che richiama l'evento al caricamento della foto centrale per poter modificarne le dimensioni ---// function completeHandler(event:Event):void { event.currentTarget.width = ldrLarg;//imposto la larghezza della foto centrale da variabile event.currentTarget.height = ldrLung;//imposto la lunghezza della foto centrale da variabile }
var ldrContainer:MovieClip = new MovieClip();//creo una movie clip che contenga la foto centrale caricata var ldr:Loader = new Loader();//creo il loader della foto centrale
addChild(ldr);//visualizzo il loader
firstimg(1);//e ne carico la prima immagine della lista
ldrContainer.addChild(ldr);//inserisco il loader dentro il suo contenitore
ldrContainer.x = s.x + larg + 100;//setto la coordinata x della foto centrale ldrContainer.y = s.y;//setto la coordinata y della foto centrale ldrContainer.filters = [filtro]; //imposto il filtro della foto centrale da variabile s.addChild(ldrContainer);//metto il contenitore della foto centrale dentro il contenitore sprite totale
// ---------------------------------------------------------load an xml------------------------ //--------------------------------------------load XML-----------------
var xmlLoader:URLLoader = new URLLoader();//imposto una variabile che carichi un file esterno var xmlData:XML;//creo una variabile che legga i dati XML xmlLoader.addEventListener(Event.COMPLETE, LoadXML);//creo il listener che iposti una funzio e al completamento del caricamento XML xmlLoader.load(new URLRequest("gallery.xml"));//carico il file gallery.xml
//---Funzione collegata al listener di caricamento XML---// function LoadXML(e:Event):void { xmlData = new XML(e.target.data);//carico la foto nel thumbnail }
//--------------------------------------------------------Creating a loop for multiple addChild-- var j = 0;//imposto la variabile j per distanziare i thumbs for (var i=1; i<5; i++) {//mando un altra variabile i da 1 al numero massimo di item nel file xml var newLdr:Loader = new Loader();//creo un loader per i thumbs var new_Mc: MovieClip = new MovieClip();//creo un contenitore per il loader di thumbs var thumb:URLRequest = new URLRequest("images/pic_"+i+".jpg");//imposto la richiesta di caricamento dei file esterni
//---//creo una maschera per definire i thumbs---// var thumbMask: MovieClip = new MovieClip();
var forma:Shape = new Shape(); forma.graphics.beginFill(0x000000); forma.graphics.drawRect(0, 0, larg, alt); forma.graphics.endFill(); //--------------------------------------------//
thumbMask.x = 10;//imposto la coordinata x della maschera dei thumbs thumbMask.y = j + (i*5);//imposto la coordinata y della maschera dei thumbs
j = j + alt; // definisco la distanza della prossima thumb
thumbMask.addChild(forma);//inserisco la forma dentro la MC maschera
newLdr.load(thumb);//carico la thumb esterna newLdr.scaleX = 0.8;//scalo la thumb sull'asse X newLdr.scaleY = 0.8;//scalo la thumb sull'asse Y new_Mc.addChild(newLdr);//metto il caricatore di thumb dentro la movie clip
s.addChild(new_Mc);//metto la movie clip delle thumbs dinamiche dentro il visualizzatore sprite totale
new_Mc.y = thumbMask.y/2;//centro le thumbs in base alla maschera sull'asse Y new_Mc.x = thumbMask.x/2;//centro le thumbs in base alla maschera sull'asse X new_Mc.buttonMode = true;//rendo le thumbs simili ad un bottone
new_Mc.mask = thumbMask;//maschero le thumbs
new_Mc.I_value=i;//collego il mc delle thumbs dinamiche al valore della i new_Mc.addEventListener(MouseEvent.CLICK, clickHandler); //setto il listener delle mc delle thumbs dinamiche all'evento click del mouse
new_Mc.filters = [filtro];//aggiungo il filtro ombra al mc delle thumbs }
//---Funzione collegata al click del mouse delle thumbs---// function clickHandler(e:MouseEvent):void { index= e.currentTarget.I_value;//la funzione prede come target la thumb cliccata var urlReq:URLRequest = new URLRequest("images/pic_"+index+".jpg");//carico nella foto centrale l'immagine della thumb ldr.load(urlReq); //imposto il loader della foto centrale
if(e.currentTarget.width>e.currentTarget.height){//se la larghezza della thumb cliccata è maggiore della sua lunghezza ldrLarg = 500;//setto la larghezza della foto centrale ldrLung = 250;//setto la lunghezza della foto centrale ldrContainer.addEventListener(Event.ADDED, completeHandler); //richiamo la funzione che setta le dimensioni della foto centrale } else{//altrimenti ldrLarg = 300;//setto la larghezza della foto centrale ldrLung = 350;//setto la lunghezza della foto centrale ldrContainer.addEventListener(Event.ADDED, completeHandler);//richiamo la funzione che setta le dimensioni della foto centrale }
}
//---Funzione che carica la foto della prima thumb sulla foto centrale---// function firstimg(index) { var urlReq_first:URLRequest = new URLRequest("images/pic_"+index+".jpg"); //carico l'immagine estera ldr.load(urlReq_first);//e la visualizzo sulla foto centrale ldrContainer.addEventListener(Event.ADDED, completeHandler);//richiamo la funzione che setta le dimensioni della foto centrale ldrLarg = 500;//setto la larghezza della foto centrale ldrLung = 250;//setto la lunghezza della foto centrale }
} } } On the flash file I write this:
Code: import myClass.Attachmovie;
Attachmovie(); But it asks me to write an argument...I don't pass any one of them...what can I do??
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 07-16-2008, 09:33 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Function Help Needed
Can you use a variable to target a property of a movie clip? What I wish to do is have my functions on the main timeline, and when I invoke my functions I will supply parameters. These parameters will tell the function how to find the _y property for instance. I.e. (_root.newsDisplay.scrollBar._y). What would be the best is if I can make the newDisplay instance name a variable as well. That way everything that I need scrolled will use the one function and I can supply the instance name as a parameter of the function.
Thanks in advance.
Function Help Needed
onClipEvent (load) {
function angle(){
(n+1)*90;
n=a;
a=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
a=1;
this._rotation=angle();
}
}
Doesent want to work. I am just trying to play around with functions.
I need the characters _rotation=180 when i press DOWN. I dont want any other version of making the thing rotate, i need this working!
Great thanks for the help!!!
Using flash 5
[F8] Function Help Needed
Ive been working on something And hit a snag How could I call a function from inside a frame inside a movieclip?
Any help is appreciated
Function Help Needed
I have a function in the first frame of my main timeline. This is the function.
function DropArea() {
if (_root.Level == 1) {
_x = (Math.floor(Math.random()*20)+13)*10;
_y = (Math.floor(Math.random()*15)+18)*10;
}
}
I am calling the function from a movie clip on the main timeline but for some reason it is moving the whole flash movie's x,y cords, not the movie clip that is calling the function.
How do I make my function move the movie clip that calls it instead of the location the function resides?
Help Needed W/ Javascript Function
I am doing this using javascript inside an html doc., but I thought someone here may be able to help me. Thank you.
I am trying to calculate the square feet of carpet that is required to carpet a room. I have one text box for the width, another for the length, and another for the cost per square feet. The names of the these text boxes are width, length, and cost. When I click on the button to calculate the cost I want it to add 25% to the total number of square feet to account for closests etc, and display this info. in an alert box. Here it was I have so far. I need some help with how to figure out this calculation and the syntax that would make up this function...
function calsqft () {
var carpet = (document.calculate.width.length.cost.value);
alert("The total cost for the carpet is " + carpet + "");
}
Then I call the funtion on the submit button...
value="Submit" onClick="calsqft();"
Thank you for your help
jhb
More Help Needed With An Array/for Function
Right...
for (i=0; i<posts; i++) {
duplicateMovieClip(_root.sectionholder.newssystem. newscon, "newscon"+i, i);
setProperty("newscon"+i, _x, 0);
setProperty("newscon"+i, _y, i*20);
newscon[i].title = title[i]+" - POSTED BY"+postedby[i];
newscon[i].date = "aa";
newscon[i].post = post0;
}
This is the code in question. The problem is the '[i]'. I need it to set variables in newscon0, newscon1, etc, but the [i] thing doesn't do it.
What will? Thanks in advance
Help Recursive Xml Function Needed
Hi there, can anyone help in building in a recursive function that will go through all the nodes in my xml file looking for a particular attribute?
thanks
frank
Language Function Help Needed
Hello,
I am very new to Flash MX actionscripts. What I'm trying to create is a function that can switch between two languages (english and swedish) without any delays and glitches.
What I need is a button that says "Svenska" that when pressed changes different movieclips throughout the scene to swedish as well as itself to "English" as to be able to change back to english.
When the language button is pressed, all of the movieclips displayed at that given moment should be switched instantly to the correct language (i.e. in a movieclip there is a switch taking place between the movieclips welcome_en and welcome_sv).
Also, the scene should be able to remember what language that is the active one so that when a new language specific movieclip enters the stage the correct language is displayed.
I've tried a couple of different ways but can't get the codes to work or get really bad results. Please assist!
Multiple MC - One Function Help Needed
ok
i have mc. they are called Tile0_0 Tile0_1....Tile9_9
now i neet to attach to everyone of them a function which is called on mc press.
i did like this
for(i=0;i<10;i++){
for(j=0;j<10;j++){
_root.["Tile" + i + "_" + j].onPress = function():Void{
if(grid2[i][j] == 0)
trace("OK");
}
}
}
but this is wrong code. I does not work as i want it t0
help anyone?
_global. Function Help Needed
Hi Everyone,
CS3/AS2
I am attempting to use the TextMetrics class in a _global. function, but I'm unsure as to the relationship between the function and the mc layer calling it. If you could take a quick peek at my code it would be greatly appreciated.
A side note: if you have time...... i believe that there will be a conflict if this function is called multiple times from the same mc, any heads up on preventing this would be awesome.
The Class used can be found here: http://blog.greensock.com/textmetrics/
My test Movie: http://drop.io/textmetrics
Thanks everyone,
Martha
GotoAndPlay Function.....help Needed
Hi,
I am trying to make a televison that when a combination of numbers are pressed, and enter is pushed, it will go to a specific scene depending on what numbers were pushed.
Here is the script i have so far
Code:
Button_Enter.onPress = function()
{
scene = "Website_" + channel.text;
gotoAndPlay("scene", 0);
}
That is the script for the Enter button.
Website_ is the name of the scene + channel.text which is the number
For example, when i punch in 8 and press enter, it takes me to the next slide which is Website_1, insead of Website_8.
Any help would be greatly apreciated.
Help Needed With Time Function
Hi, I'm trying to make a clock that shows different times for different countries. here is the code for the clock but how do I make it show the time x hours forward or back?
onClipEvent (enterFrame) {
time = new Date();
mil = time.getMilliseconds();
s = time.getSeconds();
m = time.getMinutes();
h = time.getHours();
seconds._rotation = s*6+(mil/(1000/6));
minutes._rotation = m*6+(s/10);
hours._rotation = h*30+(m/2);
}
cheers
Xml Update Function Help Needed
Hello everybody,
I am new at this site and I am from the Netherlands so if I don't speak your language very well, excuse me for that.
Now I have a problem that I can't fix. So I'll explain it to you.
I have this kind of xml update function so that an xml file is automatically updated at a website instead of the user have to push the refresh button.
This part works fine and the xml really gets up te date everytime the animation is het number 1.
Another story is the animation itself. After a while playing the entire animation, it will "forgets" the order of the xml file and it will play soms of the items for the half and some don't show at all.
Can you please help me cause I have done everything I can do. Here is my actionscript code:
Code:
//speed is de snelheid van de beweging; Hoe kleiner hoe sneller.
var speed = 4;
//
var xmlFile = "http://www.informatiescherm.com/SWF/test.xml";
var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(xmlFile+"?"+new Date().getTime());
//
resetXML = function(xmlData){
var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(xmlFile+"?"+new Date().getTime());
}
//
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
caption = [];
url = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
caption[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
url[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
first_item();
} else {
content = "XML Bestand niet geladen!";
}
}
//
function first_item() {
delay = 3000; // Tijd voordat een nieuwe regel wordt geladen.
p = 0;
display(p);
p++;
}
function timer() {
myInterval = setInterval(ticker, delay);
function ticker() {
clearInterval(myInterval);
if (p == total) {
p = 0;
resetXML(xmlData);
}
verkleinen();
}
}
function display(pos) {
over = new TextFormat(); //Effecten voor mouse-over
over.underline = true;
//
out = new TextFormat(); // Effecten voor mouse-out
out.underline = false;
//
newsMC.newsText.text = caption[pos];
newsMC.onRelease = function() {
getURL(url[pos], "_blank");
};
newsMC.onRollOver = function() {
this.newsText.setTextFormat(over);
};
newsMC.onRollOut = function() {
this.newsText.setTextFormat(out);
};
timer();
}
function verkleinen() {
this.onEnterFrame = function() {
if(newsMC._height <= 22 and newsMC._height > 0){
newsMC._yscale += (0 - newsMC._yscale) / speed
}
else if(newsMC._height == 0){
vergroten();
display(p);
p++;
}
};
}
function vergroten() {
this.onEnterFrame = function() {
newsMC._yscale += (100 - newsMC._yscale) / speed
};
}
_global. Function Help Needed
Hi Everyone,
CS3/AS2
I am attempting to use the TextMetrics class in a _global. function, but I'm unsure as to the relationship between the function and the mc layer calling it. If you could take a quick peek at my code it would be greatly appreciated.
A side note: if you have time...... i believe that there will be a conflict if this function is called multiple times from the same mc, any heads up on preventing this would be awesome.
The Class used can be found here: http://blog.greensock.com/textmetrics/
My test Movie: http://drop.io/textmetrics
Thanks everyone,
Martha
Function And Actionscript Buttons Help Needed
ok hey guys...I am having a problem with these actionscript buttons that are using function()
I have two movies... shell.swf which is my timeline. on the first frame i am loading another swf named framework.swf into _level100. the buttons i want to control the main timeline are inside the framework.swf in a mc called frame they are named next_btn and prev_btn
I have this code on the 25th frame of the shell.swf...
// _level 100 next/prev button script
_level100.frame.next_btn.onPress = function(){
this.gotoAndPlay("section_2_slide_1");
}
thanks for any help you an give me
Mike
Help Needed With Math.round Function....
Hi,
I have this piece of code :
var c4 = Math.sqrt ((c3*(1-c3)/(num1+num2))+(c3*(1-c3)/(num3+num4)));
When I run my program I get values upto several decimals. How do I use the Math.round to the above piece of code to truncate to say 4 decimal places.
Please suggest.
Thanks.
Help Needed - Simple XML Function..[Flash8]
Hi
I’ve been wondering for a while now why this function I have created won’t work.
Any help would be much appreciated
I’m loading text from an XML file into a dynamic text-box in my swf.
I then created a function:
_gloabal.signalCheck = function(){
if (mysignal == "1") {
//mysignal is a dynamic text-box where “1” is loaded from XML
gotoAndPlay("win");
}
}
and added this function to a button on the same frame:
on (release){
signalCheck();
}
The XML works fine, as the number “1” is displayed inside in the swf. However, the function doesn’t see “mysignal” as a typical dynamic text-box as it does not respond to it.
Could anybody tell me a work-around for this, or a method that responds to the actual text sent from XML.
Much obliged…
Actionscript Function Help, Needed Badly
CODE_root.Labeler.PickStatus = function() {
_root.Labeler.rectype = _root.Labeler.rectype.toLowerCase()
_root.Labeler.lblPrinted._visible = false;
_root.Labeler.lblReceipt._visible = false;
_root.Labeler.lblCleared._visible = false;
_root.Labeler.lblVoid._visible = false;
if (_root.Labeler.rectype == "receipt") {
_root.Labeler.lblPrinted._visible = false;
_root.Labeler.lblReceipt._visible = true;
_root.Labeler.lblCleared._visible = false;
_root.Labeler.lblVoid._visible = false;
}
if (_root.Labeler.rectype == "already printed") {
_root.Labeler.lblPrinted._visible = true;
_root.Labeler.lblReceipt._visible = false;
_root.Labeler.lblCleared._visible = false;
_root.Labeler.lblVoid._visible = false;
}
if (_root.Labeler.rectype == "cleared") {
_root.Labeler.lblPrinted._visible = false;
_root.Labeler.lblReceipt._visible = false;
_root.Labeler.lblCleared._visible = true;
_root.Labeler.lblVoid._visible = false;
}
if (_root.Labeler.rectype == "void") {
_root.Labeler.lblPrinted._visible = false;
_root.Labeler.lblReceipt._visible = false;
_root.Labeler.lblCleared._visible = false;
_root.Labeler.lblVoid._visible = true;
}
}
If Function To Fade A Level In Or Out As Needed.
On my stage i have buttons.swf(9 buttons) loaded into level 4.
I also have an animation.swf playing in level 7.
When I press some of the buttons I need the animation.swf to slowly fade away and stop playing if it is already playing.
When I press some of the buttons I need the animation.swf to fade in and start playing if it isn't already playing or continue playing if it already playing.
It all depends on which buttons are pressed and the order they are pressed as to whether the animation is already playing and whether the animation is told to fade away and stop or told to reappear and continue playing. ie. some button options require the animation to stay or reappear and some require it to go away.
I need to use a Function and If commands.
Any idea how you would script this please?
would you use something like - if level7._alpha>0 then _level7.gotoAndPlay(fadeout) and if _level7._alpha<1 then loadMovie animation.swf into level7.
Just need an efficient way that you would script this. I think I can work out the actual syntax - if you could just point me to the most logical way please.
Thanks for the advice.
HELP NEEDED With Query And Array Search Function
Hi,
im havin trouble when im searching for a value from an array (all of it). The array is determined by a query string which follows:
order.swf&LOCT0=bedroom&LOCT1=dwelling&LOCT2=kitch en&LOCT3=landing
Below is the script i am using. It works but it only searches the first array instead of the whole set?? what is wrong with it??
PHP Code:
Location = new Array();
for (i=0; i<numLocs; i++) {
Location[i] = eval("LOCT"+i);
}
for (i=0; i<numLocs.length; i++) {
if (Location[i] == "bedroom") {
_root.mc_list.bedroom._visible = true;
} else {
_root.mc_list.bedroom._visible = false;
}
}
Please help!
thanks,
Shahid
Trig. Function Needed, Not In Math Object
Calling all math club wizards, your help would be much much appreciated.
The Math object doesn't have a "secant", and I'm not math savvy enough to find its equivilant formula, nor have I found one in an exaustive tutorial search.
The problem I have I can't find anywhere online.
I need flash to trace an angle in a right triangle when only the hypotenuse and adjacent sides are known, translated into nice and neat actionscript.
(The pen and paper version is sec(Angle) = hypotenuse/adjacent. I need to solve for "Angle"). Any takers? Much much thanks.
FLV Player Script - Clear Function Needed
Aloha everyone, I am working on a film company website, experiencing some issues with the flv player. I am urgently seeking some help on creating the "clear function" to initialize the process, could anyone help me what please? Thanks in advanced. Karo
Switching Levels Of Swf:s Or Similar Function Needed
Hey guys,
I'm putting together a quite large site for school based in Zanzibar and, obviously, they want to show of the beauty of the country with
a large selection of images, used as backgrounds for the more than 20 seperate pages on the site.
To make it as smooth as possible to navigate through the site, I've put every single background in a separate SWF and I've made them load in a low level only when needed. This works smoothly, except for one, pretty big, problem.
The structure is basically this as of now:
I have a first SWF in _level0 which loads the first background SWF in _level1 on Frame1 and it also loads the menu in _level200.
In the menu, the second button loads the second background in _level2 and so far everything works fine, but as you might have figured out, this is not a solution that will hold up, since I can't just go on loading the rest of the 20 backgrounds on top of each other.
So my question is this:
is it some how possible to switch the levels of an active swf, i.e. on load completion move the second background SWF from _level2 down to _level1 (and of course unload the first SWF)?
It might be obvious to maybe everyone except me, that this is not possible, and if that is the case, I'd be very grateful for any suggestions on how to solve the issue of 20+ heavy background images on one site.
Best regards!
/Carl-Johan
Switching Levels Of Swf:s Or Similar Function Needed
Hey again guys,
I posted this thread under actionscript but with no luck so maybe one of guys can help me out.
@ Admins: I hope its alright to post the thread again, otherwise feel free to delete either one, which ever you think is better.
I'm putting together a quite large site for school based in Zanzibar and, obviously, they want to show of the beauty of the country with
a large selection of images, used as backgrounds for the more than 20 seperate pages on the site.
To make it as smooth as possible to navigate through the site, I've put every single background in a separate SWF and I've made them load in a low level only when needed. This works smoothly, except for one, pretty big, problem.
The structure is basically this as of now:
I have a first SWF in _level0 which loads the first background SWF in _level1 on Frame1 and it also loads the menu in _level200.
In the menu, the second button loads the second background in _level2 and so far everything works fine, but as you might have figured out, this is not a solution that will hold up, since I can't just go on loading the rest of the 20 backgrounds on top of each other.
So my question is this:
is it some how possible to switch the levels of an active swf, i.e. on load completion move the second background SWF from _level2 down to _level1 (and of course unload the first SWF)?
It might be obvious to maybe everyone except me, that this is not possible, and if that is the case, I'd be very grateful for any suggestions on how to solve the issue of 20+ heavy background images on one site.
Best regards!
/Carl-Johan
Function Doesn't Work According To Path - Help Needed
ok, I've been fighting this since yesterday with no results and by now I'm going a bit desperate... if anyone out there knows of any info on this available through the web or have dealt with and cracked a similar problem, please, please, please, I could desperately use some advice.
I've searched for related issues, but none of them seems to cover this and I guess that's partly because, for absurd as it might sound, there's nothing wrong... let me make it clearer:
I'm programming a dinamic flash/xml website. up until now I've kept the info for the menus and the one for the gallery (the site has a gallery that displays both text and images) in separate xml files. but I'm trying to make all of it work out of a single xml file. I've managed to make the menus and the gallery all go get the info correctly to the xml (text and images), but then I came up with a problem that jeopardizes the whole show: a path inside the xml's onLoad function refuses to work! the code that bears the function has to be placed into the same clip as the clips that contain the text fields to wich info will be passed or it won't do a thing.
supose this is my actionscript code:
Code:
var contentSubMenu = new XML();
contentSubMenu.ignoreWhite = true;
contentSubMenu.load("example.xml");
//--------------------------------------------------
_root.contentSubMenu.onLoad = function() {
/* code */
//path to where the clips that bear the text fields to be filled are contained
var buttonList = _root.listSubMenu_mc.listWindow_mc.buttonListSlide_mc;
//example of buttonList usage:
//1) category loop
for (a=0; a<categories.length; a++) {
var category = categories[a];
//duplicates the clip that contains the category text field, assigns the proper category to that text field and adjusts the clips y position
buttonList.category_mc.duplicateMovieClip("category"+a+"_mc", getNextHighestDepth());
buttonList["category"+a+"_mc"].category_txt.text = category.toLowerCase();
...
...
/* loads of code */
}
unless _root.contentSubMenu.onLoad = function() and the code from there on is placed into _root.listSubMenu_mc.listWindow_mc.buttonListSlide _mc (right above category_mc),
no information is passed to that clip. If the path targets that clip one should expect it to, right? even if all this code is placed on _root, right? well, it doesn't happen...
I tried tracing for info that comes from the xml, but nothing is displayed in the output window.
I've attached a zip file that contains a fla file, an xml file, a txt file with the full chunk of actionscript code and the fonts you'll be needing should you decide to take a look (they're only two).
The fla file has been built in the following manner:
_on the right side, the clips that hold the text fields to wich the contentSubMenu.onLoad function will pass info to are directly placed upon _root (so, following the code example from above, it would be like having var buttonList = _root;)
_on the left side, the clips that hold the text fields are down into buttonListSlide_mc and the contentSubMenu.onLoad function is there as well, only commented so it doesn't display anything.
that way one situation is compared with the other more easily.
I have no idea why this is and if it should work it would make my code and website a lot more cleaner and effective, so if anyone would like to help I'd be deeply thankful.
Function Doesn't Work According To Path - Help Needed
ok, I've been fighting this since yesterday with no results and by now I'm going a bit desperate... if anyone out there knows of any info on this available through the web or have dealt with and cracked a similar problem, please, please, please, I could desperately use some advice.
I've searched for related issues, but none of them seems to cover this and I guess that's partly because, for absurd as it might sound, there's nothing wrong... let me make it clearer:
I'm programming a dinamic flash/xml website. up until now I've kept the info for the menus and the one for the gallery (the site has a gallery that displays both text and images) in separate xml files. but I'm trying to make all of it work out of a single xml file. I've managed to make the menus and the gallery all go get the info correctly to the xml (text and images), but then I came up with a problem that jeopardizes the whole show: a path inside the xml's onLoad function refuses to work! the code that bears the function has to be placed into the same clip as the clips that contain the text fields to wich info will be passed or it won't do a thing.
supose this is my actionscript code:
Code:
var contentSubMenu = new XML();
contentSubMenu.ignoreWhite = true;
contentSubMenu.load("example.xml");
//--------------------------------------------------
_root.contentSubMenu.onLoad = function() {
/* code */
//path to where the clips that bear the text fields to be filled are contained
var buttonList = _root.listSubMenu_mc.listWindow_mc.buttonListSlide_mc;
//example of buttonList usage:
//1) category loop
for (a=0; a<categories.length; a++) {
var category = categories[a];
//duplicates the clip that contains the category text field, assigns the proper category to that text field and adjusts the clips y position
buttonList.category_mc.duplicateMovieClip("category"+a+"_mc", getNextHighestDepth());
buttonList["category"+a+"_mc"].category_txt.text = category.toLowerCase();
...
...
/* loads of code */
}
unless _root.contentSubMenu.onLoad = function() and the code from there on is placed into _root.listSubMenu_mc.listWindow_mc.buttonListSlide _mc (right above category_mc),
no information is passed to that clip. If the path targets that clip one should expect it to, right? even if all this code is placed on _root, right? well, it doesn't happen...
I tried tracing for info that comes from the xml, but nothing is displayed in the output window.
I've attached a zip file that contains a fla file, an xml file, a txt file with the full chunk of actionscript code and the fonts you'll be needing should you decide to take a look (they're only two).
The fla file has been built in the following manner:
_on the right side, the clips that hold the text fields to wich the contentSubMenu.onLoad function will pass info to are directly placed upon _root (so, following the code example from above, it would be like having var buttonList = _root;)
_on the left side, the clips that hold the text fields are down into buttonListSlide_mc and the contentSubMenu.onLoad function is there as well, only commented so it doesn't display anything.
that way one situation is compared with the other more easily.
I have no idea why this is and if it should work it would make my code and website a lot more cleaner and effective, so if anyone would like to help I'd be deeply thankful.
Function Doesn't Work According To Path - Help Needed
ok, I've been fighting this since yesterday with no results and by now I'm going a bit desperate... if anyone out there knows of any info on this available through the web or have dealt with and cracked a similar problem, please, please, please, I could desperately use some advice.
I've searched for related issues, but none of them seems to cover this and I guess that's partly because, for absurd as it might sound, there's nothing wrong... let me make it clearer:
I'm programming a dinamic flash/xml website. up until now I've kept the info for the menus and the one for the gallery (the site has a gallery that displays both text and images) in separate xml files. but I'm trying to make all of it work out of a single xml file. I've managed to make the menus and the gallery all go get the info correctly to the xml (text and images), but then I came up with a problem that jeopardizes the whole show: a path inside the xml's onLoad function refuses to work! the code that bears the function has to be placed into the same clip as the clips that contain the text fields to wich info will be passed or it won't do a thing.
supose this is my actionscript code:
Code:
var contentSubMenu = new XML();
contentSubMenu.ignoreWhite = true;
contentSubMenu.load("example.xml");
//--------------------------------------------------
_root.contentSubMenu.onLoad = function() {
/* code */
//path to where the clips that bear the text fields to be filled are contained
var buttonList = _root.listSubMenu_mc.listWindow_mc.buttonListSlide_mc;
//example of buttonList usage:
//1) category loop
for (a=0; a<categories.length; a++) {
var category = categories[a];
//duplicates the clip that contains the category text field, assigns the proper category to that text field and adjusts the clips y position
buttonList.category_mc.duplicateMovieClip("category"+a+"_mc", getNextHighestDepth());
buttonList["category"+a+"_mc"].category_txt.text = category.toLowerCase();
...
...
/* loads of code */
}
unless _root.contentSubMenu.onLoad = function() and the code from there on is placed into _root.listSubMenu_mc.listWindow_mc.buttonListSlide _mc (right above category_mc),
no information is passed to that clip. If the path targets that clip one should expect it to, right? even if all this code is placed on _root, right? well, it doesn't happen...
I tried tracing for info that comes from the xml, but nothing is displayed in the output window.
I've attached a zip file that contains a fla file, an xml file, a txt file with the full chunk of actionscript code and the fonts you'll be needing should you decide to take a look (they're only two).
The fla file has been built in the following manner:
_on the right side, the clips that hold the text fields to wich the [i]contentSubMenu.onLoad[i] function will pass info to are directly placed upon _root (so, following the code example from above, it would be like having var buttonList = _root;)
_on the left side, the clips that hold the text fields are down into buttonListSlide_mc and the contentSubMenu.onLoad function is there as well, only commented so it doesn't display anything.
that way one situation is compared with the other more easily.
I have no idea why this is and if it should work it would make my code and website a lot more cleaner and effective, so if anyone would like to help I'd be deeply thankful.
Attached Files
Timer Function Needed To Goto And Play Frame 1
Hi i need some sort of timer function, i am a newbie at flash, and would love some input.
I made a dynamix txt box which gets its data from an external source (http://radio.megamixers.net/flash.txt) i need that txt file reloaded every 60 seconds or so, so i can keep it showing whats played on the radio now.
Hope someone can help me out
My .FLA is here
http://www.codes.dk/titleupdater.fla
Hope to get some help - ive been all over the net looking for a function to handle this but no luck..
Kind regards
Cosmo
Help Needed: Buttons And StartDrag Not Working Through A LoadMovie Function
Can anyone out there help with this?
I'm trying to solve this (probably simple) path issue, and am not having much luck.
I've got 2 files (see attached):
File 1 (ex2mainfile.fla) has one button only that, when clicked, should load File 2 (ex2.swf) into a movie holder. It's not working (see attached)
File 2 (ex2.fla) is a drag and drop activity in which:
- Users listen to each of 5 audio files, then
- Drag the accent name on the right (American, Irish, etc) to the correct drop zone on the left
PROBLEM
1. When you test ex2.fla by itself the drag and drop work fine. BUT, when you test (ex2mainfile.fla), the startDrag function won't work
2. I have a number of different files which are causing similar problems. Sometimes it's the startDrag which won't work, other times it's the cursor which won't work / won't change into whatever it's supposed to change into. (Is this the same pathing issue as the startDrag? Or is it a completely separate issue?
Can anyone help?
(See attached files)
Thanks in advance for your time
Rob
Expert Help Needed - Motion Function With Dynamic Parameters
I must admit that i am slightly out of my depth when it comes to functions with dynamic parameters and cycle statements, but i have produced a script that i feel i am so close to cracking (and need to before thursday!).
I have a groundfloor plan (gf_mc), within which is many departments (dep_1, dep_2 etc). Upon rolling on each department, the department rises slightly in scale, whilst a roll out causes them to retract to normal. When the department is released, the x and y scales of the gf_mc increase, whilst the x and y co-ordinates alter, so that the screen has effectively zoomed in on the department. When a department is in focus, all others reduce in alpha to make them near transparent.
Code:
function motionTween (target, newX, newY, newXscale, newYscale, newAlpha) {
currentX = target._x
currentY = target._y
currentXscale = target._xscale
currentXscale = target._yscale
currentAlpha = target._alpha
speed = .1;
if (newX = undefined) {
newX = currentX
}
if (newY = undefined) {
newY = currentY
}
if (newXscale = undefined) {
newXscale = currentXscale
}
if (newYscale = undefined) {
newYscale = currentYscale
}
if (newAlpha = undefined) {
newAlpha = currentAlpha
}
this.onEnterFrame = function() {
var dx = newX - currentX;
var dy = newY - currentY;
var dxs = newXscale - currentXscale
var dys = newYscale - currentYscale
var da = newAlpha - currentAlpha
if ((dx < 1) && (dy < 1) && (dxs < 1) && (dys < 1) && (da < 1)) {
currentX = newX
currentY = newY
currentXscale = newXscale
currentYscale = newXscale
currentAlpha = newAlpha
delete this.onEnterFrame;
} else {
currentX += dx*speed;
currentY += dy*speed;
currentXscale += dxs*speed;
currentYscale += dys*speed;
currentAlpha += da*speed;
}
}
}
//groundfloor department array
gf_ar = new Array ()
gf_ar[1] = gf_mc.dep_1 //department 1
gf_ar[2] = gf_mc.dep_2 //department 2
gf_ar[3] = gf_mc.dep_3 //department 3
gf_ar[4] = gf_mc.dep_4 //department 4
// etc...
for (i=1; i<= gf_ar.length; i++) {
var iDep = _root.gf_mc["dep_"+i]
iDep.onRollover = function () {
this.motionTween (this, undefined, undefined, 120, 120, 90)
}
iDep.onRollout = function () {
this.motionTween (this, undefined, undefined, 100, 100, 60)
}
// on release of gf_mc.dep_?, this department is the focused department & perform the function with its set parameters
iDep.onRelease = function () {
this = focusdep
this.motionTween (gf_mc, this.newX, this.newY, this.newXscale, this.newYscale, 70)
}
}
//department perameters
with (_root.gf_mc.dep_1) {
newX = 16
newY = 690
newXscale = 350
newYscale = 350
}
with (_root.gf_mc.dep_2) {
newX = -620
newY = -796
newXscale = 432
newYscale = 432
}
with (_root.gf_mc.dep_3) {
newX = -70
newY = -520
newXscale = 365
newYscale = 365
}
with (_root.gf_mc.dep_4) {
newX = -455
newY = -335
newXscale = 315
newYscale = 315
}
Primarily, the problem is that the motion functions are not performed. I cannot figure out why.
Additionally, i have a few extra questions:
1. In the function Itself, i have nabbed the coding:
Code:
this.onEnterFrame = function () {
What is 'this' in this instance?
similarly, later i used
Code:
delete this.onEnterFrame;
am i right in thinking that that peice of coding is re-usable, and that it is not permanently deleted, only telling the motion function to stop?
2. Whenever i trace the focusdep, it is always undefined. So although the output bar updates when i release a department, it only displays 'undefined' again.
Code:
iDep.onRelease = function () {
this = focusdep
this.motionTween (gf_mc, this.newX, this.newY, this.newXscale, this.newYscale, 70)
}
trace(focusdep)
3. Finally, i have made an attempt at causing the unfocused (not zoomed in on) departments to fade when another department is selected.
Code:
iDep.onRelease = function () {
this = focusdep
this.motionTween (gf_mc, this.newX, this.newY, this.newXscale, this.newYscale, 70)
if ((iDep != focusDep) && (focusDep != undefined) {
this.motionTween (this, undefined, undefined, undefined, undefined, 40)
}
I have a feeling this is horribly inaccurate. I am trying to say:
"if gf_mc.dep_? is not the focused department and the focused department is not undefined, fade gf_mc.dep_? to 40 alpha"
Thank you for any help!
[MX04] Function Doesn't Work According To Path - Help Needed
ok, I've been fighting this since yesterday with no results and by now I'm going a bit desperate... if anyone out there knows of any info on this available through the web or have dealt with and cracked a similar problem, please, please, please, I could desperately use some advice.
I've searched for related issues, but none of them seems to cover this and I guess that's partly because, for absurd as it might sound, there's nothing wrong... let me make it clearer:
I'm programming a dinamic flash/xml website. up until now I've kept the info for the menus and the one for the gallery (the site has a gallery that displays both text and images) in separate xml files. but I'm trying to make all of it work out of a single xml file. I've managed to make the menus and the gallery all go get the info correctly to the xml (text and images), but then I came up with a problem that jeopardizes the whole show: a path inside the xml's onLoad function refuses to work! the code that bears the function has to be placed into the same clip as the clips that contain the text fields to wich info will be passed or it won't do a thing.
supose this is my actionscript code:
Code:
var contentSubMenu = new XML();
contentSubMenu.ignoreWhite = true;
contentSubMenu.load("example.xml");
//--------------------------------------------------
_root.contentSubMenu.onLoad = function() {
/* code */
//path to where the clips that bear the text fields to be filled are contained
var buttonList = _root.listSubMenu_mc.listWindow_mc.buttonListSlide_mc;
//example of buttonList usage:
//1) category loop
for (a=0; a<categories.length; a++) {
var category = categories[a];
//duplicates the clip that contains the category text field, assigns the proper category to that text field and adjusts the clips y position
buttonList.category_mc.duplicateMovieClip("category"+a+"_mc", getNextHighestDepth());
buttonList["category"+a+"_mc"].category_txt.text = category.toLowerCase();
...
...
/* loads of code */
}
unless _root.contentSubMenu.onLoad = function() and the code from there on is placed into _root.listSubMenu_mc.listWindow_mc.buttonListSlide _mc (right above category_mc),
no information is passed to that clip. If the path targets that clip one should expect it to, right? even if all this code is placed on _root, right? well, it doesn't happen...
I tried tracing for info that comes from the xml, but nothing is displayed in the output window.
I've attached a zip file that contains a fla file, an xml file, a txt file with the full chunk of actionscript code and the fonts you'll be needing should you decide to take a look (they're only two).
The fla file has been built in the following manner:
_on the right side, the clips that hold the text fields to wich the contentSubMenu.onLoad function will pass info to are directly placed upon [i]_root (so, following the code example from above, it would be like having var buttonList = _root;)
_on the left side, the clips that hold the text fields are down into buttonListSlide_mc and the contentSubMenu.onLoad function is there as well, only commented so it doesn't display anything.
that way one situation is compared with the other more easily.
I have no idea why this is and if it should work it would make my code and website a lot more cleaner and effective, so if anyone would like to help I'd be deeply thankful.
Creating A Kind Of Tricky Recursive Function - Help Needed
Hello everybody. I'm in a big big mess, trying to figure out how to do this for the last couple of days. I finaly came to the conclusion that I need a recursive function for what I'm trying to do.
Because it's a little hard to explain what I need.. I'll make an example.
So.. I have the figure below. I mean.. that's what I'm trying to achieve. For that figure I have data stored in the folowing way.
_root.marc is an Array.
All the paths that leave a square ... like From M0 if you choose 1 you'll get M1,
From M0 through 5 you'll get to M3.. and so on.
this is stored like
_root.marc[0].p - the paths. If _root.marc[x].p.length is 0.. that means that Mx is the last one.. and has no paths assigned, like shown in the figure.
My very big problem is that I need to position that MC's.. M3,M4.. all of them, according to the paths above them.
So, to position M2, i need to take a look at M1, and if it has any paths, more than one path, I need to move it further down. But this is not the end of it. If M1 has more paths that lead to other MC-s.. i need to take in considerations their paths too . This drove me mad for the last couple of days, and my time is slowly running out for my diploma
What I've tryed till now was to build a function let's say... getNextY(m) that should return a number. A "ponder"?..
like...to use it in a line like
M2._y = (currIndex + getNextY(1))*dy;// here it should return 5 for instance
M3._y = (currIndex + getNextY(2))*dy;// here getNextY should return 1
Why 5 or one? because it needs to take into account only if the paths are greater than 1.
CRAZY
If any one could help me with this I would be .... I would... I would cry and be greatfull for eternity .. I guess.
Stopping A Function And Return Back To Same Position - Help Needed
Any one pls help ,
Friends i have a function in that movieclips color will change according to time
what i need is if a specific action occurs say pressing a button (poweroff) or if the value of x==1; the function should be stopped where it is .....
if i press some other button say poweron the function should start again from the same place.....
Note: there is only one frame and stoping the movieclip like mc.stop(); not working in this case, return and killfunction completely get me out from the function.
function fadeArrayTrans(){
//trace("hai");
myCO = new Color(_root.lightsholder1.examplered1.SomeImageCli p);
myCO.fadeTransform(transArray[lastTransArray], 3750, fadeArrayTrans);
lastTransArray++;
//return;
lastTransArray%=transArray.length;
}
transArray = [];
transArray[0]={ra:100, rb:255, ga:100, gb:255, ba:100, bb:255, aa:100, ab:0};
transArray[1]={ra:100, rb:0, ga:100, gb:255, ba:100, bb:100, aa:100, ab:0};
transArray[2]={ra:100, rb:0, ga:100, gb:255, ba:100, bb:0, aa:100, ab:0};
transArray[3]={ra:100, rb:0, ga:100, gb:255, ba:100, bb:255, aa:100, ab:0};
transArray[4]={ra:100, rb:0, ga:100, gb:0, ba:100, bb:255, aa:100, ab:0};
transArray[5]={ra:100, rb:255, ga:100, gb:0, ba:100, bb:255, aa:100, ab:0};
transArray[6]={ra:100, rb:255, ga:100, gb:0, ba:100, bb:70, aa:100, ab:0};
transArray[7]={ra:100, rb:255, ga:100, gb:40, ba:100, bb:100, aa:100, ab:0};
lastTransArray = 0;
i have pasted small part of the code which may give idea about my problem. if you insist friends , i will post full script
Thanks in Advance
Creating A Kind Of Tricky Recursive Function - Help Needed
Hello everybody. I'm in a big big mess, trying to figure out how to do this for the last couple of days. I finaly came to the conclusion that I need a recursive function for what I'm trying to do.
Because it's a little hard to explain what I need.. I'll make an example.
So.. I have the figure below. I mean.. that's what I'm trying to achieve. For that figure I have data stored in the folowing way.
_root.marc is an Array.
All the paths that leave a square ... like From M0 if you choose 1 you'll get M1,
From M0 through 5 you'll get to M3.. and so on.
this is stored like
_root.marc[0].p - the paths. If _root.marc[x].p.length is 0.. that means that Mx is the last one.. and has no paths assigned, like shown in the figure.
My very big problem is that I need to position that MC's.. M3,M4.. all of them, according to the paths above them.
So, to position M2, i need to take a look at M1, and if it has any paths, more than one path, I need to move it further down. But this is not the end of it. If M1 has more paths that lead to other MC-s.. i need to take in considerations their paths too . This drove me mad for the last couple of days, and my time is slowly running out for my diploma
What I've tryed till now was to build a function let's say... getNextY(m) that should return a number. A "ponder"?..
like...to use it in a line like
M2._y = (currIndex + getNextY(1))*dy;// here it should return 5 for instance
M3._y = (currIndex + getNextY(2))*dy;// here getNextY should return 1
Why 5 or one? because it needs to take into account only if the paths are greater than 1.
CRAZY
If any one could help me with this I would be .... I would... I would cry and be greatfull for eternity .. I guess.
Adding A GoTo Command To A Function When Its Finished...? Plz Urgent Help Needed.
hi guys,
i have this function of a countdown timer, and im using it for a game. i dont know how to set up the actionscript of this function so that when the timer reaches 00, it will jump from the current scene, to my 'game-over' scene?
this is what i have in the script for the countdown timer:
howLong=100;
max = bar._x;
min = max - bar._width;
total = max-min; bar._x = max;
//initialize the text display
display_txt.text=howLong;
start_btn.onPress=function(){countDown()}
function countDown(){
var totalTime = howLong*1000;
var startTime = getTimer();
this.onEnterFrame=function(){
percent = (getTimer()-startTime)/totalTime;
bar._x = max-(percent*total); display_txt.text=Math.floor(howLong+1-(howLong*percent));
if (percent>1) {
this.onEnterFrame=null;
s=new Sound();
s.attachSound("smack");
s.start();
_parent[functionName]();
}
}
}
thank you very much
Call Function In A Class From LoadVars With Relative Path Needed. Please Help
Hi all, i´m new here. I´ve been searching an answer to my problem but haven´t found it yet. If someone can help, i´ll be really grateful!
I need to call a function defined inside a class i´ve created, but the function must be called from an loadVars.onLoad(success) object nested inside another function from the same class.
The problem is i can´t use the absolute path from the _root since i use more than one instance of the class.
Using _parent won´t work even if i try to do this:
loadVarsName._parent = this;
This statement works when the loadVars is not inside a class, but when i put it inside my class it stops working.
here is the code on my example.as file.
class example extends MovieClip {
}
public function callNewFunction() {
trace ("function called");
}
public function loadArds() {
var loadedTxt:LoadVars = new LoadVars();
loadedTxt.load("file.txt");
loadedTxt.onLoad = function(success) {
if (success) {
callNewFunction(); //here is my problem!!! no relative path can get me there.
}
}
}
}
//End Class
please help!!!!!!!!!! Thanks!
Help Needed: StartDrag/stopDrag Function Prevents Closing Popup Window
Hey all,
Summary:
I created a popup window inside my flash movie and it worked fine.
Then I decided that the user should have the ability to drag the window around if needed.
So, I added a startDrag/stopDrag function to it.
Problem:
Because I added the startDrag function, I can't close the popup window.
If I comment the drag function out, then I can close the window.
I can do one or the other, but not both.
I have a vague idea of what's happening.
Theory:
The close window command ( t.removeMovieClip() ) is not able to execute because
the "close button movie clip" is inside the popup window movie clip. Therefore, when I add the startDrag function, it gets dragged along with everything else. I believe that to
sovle this problem the startDrag function has to be cleared some sort of way
so that the "close button movie clip" can perform its function.
Well that's just my theory.
Here is my code:
Code:
//-----------------------This creates an empty movie clip----------------------\
this.createEmptyMovieClip("container_mc",1);
//-----------------------end of movie clip creation----------------------------\
//-------------This attaches movie clip to stage on button release-------------\
button.onRelease = function () {
var t:MovieClip = container_mc.attachMovie("popup","pop_mc",container_mc._level1());
t._x =100;
t._y =100;
t.closer.onRelease = function () {
t.removeMovieClip();
}
//---------------------end attach movie--------------------------------------\
//--------------------drag events--------------------------------------------\
t.onPress = function () {
t.startDrag();
}
t.onRelease = function () {
t.stopDrag();
}
//----------------------------end drag events------------------------------\
}
I have attached the fla file.
--------------------
Thanks in advance.
Hungry Samurai
PLEASE HELP Easing Scrollbar Code Needed To Add Mouse Wheel Function Not Working?
Hi,
I really appreciate some help here is the code below for my scrollbar which works fine but I can't get the mouse wheel code to work (I've taken it out since) How to add a mouselistener and get it to work with my scrollbar? Apparently some simple code but when I put it in nothing works please help if you could add the code in my code that might work.
I think I need to add some code that listens to the mouse wheel? PLEASE HELP! I only know VERY basic action script.
HERE is the code:
//Scrollbar Control//
fscommand("allowscale", "false");
bar.useHandCursor = dragger.useHandCursor=false;
space = 0;
friction = 0.3;
speed = 4;
y = dragger._y;
top = main._y;
bottom = main._y+mask_mc._height-main._height-space;
dragger.onPress = function() {
drag = true;
this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
dragger.scrollEase();
};
dragger.onMouseUp = function() {
this.stopDrag();
drag = false;
};
bar.onPress = function() {
drag = true;
if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
this._parent.dragger._y = this._parent._ymouse;
this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
} else {
this._parent.dragger._y = this._parent._ymouse;
}
dragger.scrollEase();
};
bar.onMouseUp = function() {
drag = false;
};
moveDragger = function (d) {
if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
clearInterval(myInterval);
} else {
dragger._y += d;
dragger.scrollEase();
updateAfterEvent();
}
};
up_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
this.onEnterFrame = function() {
if (Math.abs(dy) == 0 && drag == false) {
delete this.onEnterFrame;
}
r = (this._y-y)/(bar._height-this._height);
dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
main._y += dy;
};
};
Function In A Function In A Function, A Scope Problem
Is this basic or what.. I have a nested functions, and I'm having a hell of a time getting all my variable through.
ActionScript Code:
var canyouseemee;
public function move()
{
for(var i:Number = 0; i < blah; i++)
{
zing, and then zang
if (zing==0)
{
guts
}
if (zang ==0)
{
something else
}
}
}
Now, I had always thought that since var canyouseemee is declared at the topmost layer, that I'd be able to see it from anywhere below it. Well, it turns out that I can only see it from within the move()function, and not anything below it. is this normal? I thought you couldn't see a local variable of a lower (deeper) function, but could see higher (shallower) variables...
Call A Function In A Duplicated Movie Clip Form Another Function : (
i have a movie clip on my root name "pl".
on command, it duplicates with instance name as "y0","y1", etc.
here is the method :
function callPL(transmit,receive,addy,level) {
var newName = "y"+_root.x;
duplicateMovieClip("_root.pl",newName,101);
_root[newName]._x = 400;
_root[newName]._y = 400;
_root.[newName].start(transmit,receive,addy,level); //look here
}
there i attempt to call a function of the newly duplicated clip call "start()".
Start() function is written on the first frame of the movieclip like this :
function start(a,b,address,level) {
a.sendAndLoad(address,b,"Post");
this.path = b;
b.onLoad=function(success) {
gotoAndPlay("start");
}
}
however it seems like the function callPL() could not invoke function start() of the new movieClip.I have no idea how is it so.
Even when i trigger it with a onLoad handler it still doesnt work
pls shed some light.
Calling Constructor In Condition: A Function Call On A Non-function Was Attempted.
Hi guys,
Please help me somebody with this cos I have really no idea. I have made a simply condition calling a constructor of a class. Today I had to add an "else if", what caused the compilator to show me "A function call on a non-function was attempted."...
ActionScript Code:
function loadIt() { if (var1 == "1") { var a:SomeClass = new SomeClass(true); } else if(var2 == "1"){ var a:SomeClass = new SomeClass(false); //<- if this is not here, everything works fine } else { var b:SomeOtherClass = new SomeOtherClass(); b.init(); }}
Any ideas? Thanks for any help!
Poco
Filling Function Arguments With Array Items, Function.call()
HI!
I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7
ActionScript Code:
import com.robertpenner.easing.Cubic;MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) { var t:Number = 0; var mc:MovieClip = this.createEmptyMovieClip(String(new Date().getTime()), this.getNextHighestDepth()); mc.onEnterFrame = function() { if (t == frames) { func.call(this._parent,args); delete this.onEnterFrame; this.removeMovieClip(); } else { t++; } };};MovieClip.prototype.movex = function(x:Number, frames:Number) { trace(x+" "+frames) delete this.movex.onEnterFrame; this.movex.removeMovieClip(); if (!frames) { frames = 20; } var t:Number = 0; var sx:Number = this._x; var ax:Number = x-this._x; var mc:MovieClip = this.createEmptyMovieClip("movex", this.getNextHighestDepth()); mc.onEnterFrame = function() { if (t == frames) { delete this.onEnterFrame; this.removeMovieClip(); } else { t++; this._parent._x = Cubic.easeOut(t, sx, ax, frames); } };};MovieClip.prototype.otherfunction = function(param1, param2, param3, param4){ trace(param1+" "+param2+" "+param3+" "+param4)}mc.framesTimeout(movex, 50, [100, 50]) mc.framesTimeout(otherfunction, 200, ["asd", 1, 2, 55])
Is it possible to call a function and fill in the parameters based on an array and it's lenth?
My Function Isn't Functioning/Actionscript To Call A Function Flash MX 2004
Hello,
Well in theory I know how to create a function but for some reason I am unable to call it.
Can someone take a look at it and tell me what went wrong. Basically when I go to "a certain page" I want to click on a button and have it go to another page known as "pics" it then will load a jpeg there known as jpeg loader. Now I know it works properly without a functin, but because I am lazy I do not want to write more code than I have to, there are like 300 differnt jpegs I have to load. Thus I need to create a function.
here is my AS
ActionScript Code:
//this is on frame one of my root timeline
//I am trying to call the function "display" on release of my button
omnihotelButton.onRelease = display ("J010 Omni Hotel.jpg");
//this is my function that I set up it is also on my root, but on a different frame
//this function is named display and it goes to the "pics" page and stops
where it then loads a jpeg which is et up as my variable.
//the xscale and the yscale are just setting up my size of the jpeg.
function display(jpeg){
_root.gotoAndStop("pics");
jpegLoad_mc.loadMovie(jpeg);
jpegLoad_mc._xscale=90;
jpegLoad_mc._yscale=90;
}
Function Calling From The _root But Call A Function Within A Instance
I have created a new instance 'Check_1' to work as a checkbox with a set of propertys and functions.
All ive done is created the functions in a script in the first frame of the instance-movie these are...
Simple......
================================================== =======
selected = -1;
function select_frame (FrameNum) {
gotoAndPlay (FrameNum);
}
function change_select () {
select_frame(2);
trace (selected);
}
function change_unselect () {
select_frame(1);
selected = -1;
}
================================================== =======
now from the _root i wish to call the above functions to change the instance propertys, it all works fine from within the instance but i also need to use the functions for that instance from the _root...
iv'e tried the follow with no joy...
_level0.Check_1.change_select()
Any light would be greatly appreciated.
Parsing Data To A Function And Altering It Inside The Function
Hi all
I need to parse variables to a function and let the values of the variables be changed inside the function. But in a way that the data are actually changed, not only a reference to the data! It is not possible using primitive data but should be possible with composite data.
But I cant get it right - any suggestions?
code:
test = new Object();
test = false;
aFunction = function(control){
control = true;
trace(test);
other code here...
}
How can I make the trace(test) output true when I call the aFunction(test) with test as parameter?
Hope anyone have the answer!
Ciao ciao
T
Define The OnMouseDown Function To Point To A Member Function
Hi,
I have a class called CField that contains a MovieClip. And I like to be able to call a member function inside my class, when the mouse click on the MovieClip. If I use the callback function onMouseDown = function() from inside the class, the function is overwritten by the last created instance of the class (see the the Main Program). How do I define the onMouseDown function to point to a member function?
// Main Program
.
// Create and draw 10 fields
for (i=0;i<10;i++)
{
var field:CField = new CField(i*50, 50);
field.Draw(i);
}
.
My class is looking more or less like this:
// Field Class
class CField
{
// Properties
var m_nPosX:Number;
var m_nPosY:Number;
var m_mcField;
// Constructor
function CField(nPosX:Number, nPosY:Number)
{
this.m_nPosX = nPosX;
this.m_nPosY = nPosY;
}
public function Draw(nCount:Number)
{
var sInstance:String = new String(nCount.toString(10));
this.m_mcField = _root.createEmptyMovieClip (sInstance, nCount);
with (this.m_mcField)
{
_x = this.m_nPosX;
_y = this.m_nPosY;
loadMovie("Field.swf", nCount);
onMouseDown = function ()
{
trace("Mouse Clicked");
}
}
}
}
Inside XmlOnload Function Can Not Call Other Function Directly
I have a question, why the test function can not be called ?
Thanks.
Code:
class testClass {
public function testClass() {
var XMLData:XML = new XML();
XMLData.load("coonfig.xml");
XMLData.onLoad = this.xmlOnLoad;
}
public function xmlOnLoad(success:Boolean) {
if (success) {
// this.test();
test();
}
}
public function test () {
trace("test success");
}
}
Actionscript Function Similar To PHPs Explode Function?
Hello everyone, first off, I'd like to say hi to everyone as this is my first post and I have joined very recently! So yeah, I'm glad to be here and yeah, hope I find what I need.
Right, well for those of you who know PHP there is a function known as explode(), which basically splits a string apart by a certain character and throws it into an array.
For example, in PHP.
PHP Code:
$string = "lol,text,omfg,wow,hi";
I can explode that string by the , character and it would split up everything and throw each little "section" into an array.
PHP Code:
$bits = explode( ',', $string );
I can now access access the bits by $bits[0], $bits[1], $bits[2], $bits[3], and $bits[4].
Now, is there anyway you can do this in Actionscript? Say I have a string in actionscript and I've datatyped it to a string.
PHP Code:
var myString:String = "text1|text2|text3|text4";
How can I explode, or break apart, the string by the | character and get the "text1", "text2", etc, strings?
|