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
KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 11-09-2006, 01:44 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[F8] MC Properties - I Am Doing Something Wrong Or What?
Hi,
I am working on an application that will load several external swfs with loadClip. In fact it's a game for kids where you can exchange clothes in a doll. Each piece of cloth (blouse, pants, etc) is a separated swf, then I can have a really huge library of clothes.
In the main timeline of blouse1.swf, I have just one frame where I have placed a mc called "mcBlouse1". In this same frame, I coded:
code:
_root.mcBlouse1._mycolour = "red";
Then, I am loading the blouse1.swf successfully with loadClip.
The problem is that after to load it and try to see the property I set in the external swf, I am getting an undefined:
code:
_root.LoaderBlouse.onLoadInit = function()
{
trace (_root.mcContainerBlouse.mcBlouse1); // the mc name
trace (_root.mcContainerBlouse.mcBlouse1._mycolour); // undefined!
}
Any idea?
Function Properties
From: Bruce Conway
ibconway@home.com
Any help on this would be appreciated.
I shudder to post this being a mere beginner, but I'm currently lacking good books and the online help for Flash is useless on this topic. I'm looking at Moock's code for Multiple Choice Quiz version 2. In short, what is a function property and how do you declare one? Apparently answer.currentAnswer is a function property. It's the very first mention of currentAnswer.
I'm confused about the syntax, i.e. answer.currentAnswer,
which to me means: to declare a function property for the function called 'functionName':
function functionName (parameters) {
functionName.propertyName; //property declared?
}
----------------------------Moock's Code here--------------
// function to register the user's answers
function answer (choice) {
// track the current answer with a function property
answer.currentAnswer++;
// record the user's answer
set ("q"+answer.currentAnswer+"answer", choice);
// go to the next question or the quiz end
if (answer.currentAnswer == numQuestions) {
gotoAndStop ("quizEnd");
} else {
gotoAndStop ("q"+ (answer.currentAnswer + 1));
}
}
Changin Properties In A Function
I want to set up this function where I can change it to scale _height, _widht or _x. But what Sintax do I use... I tried doing... this[myProperty]-whatever but it wasnt' working for me. I was then calling it like this...
this.myFunctionName("._height")
Here is the actual function I have been working on.
MovieClip.prototype.scaler = function(wDest, name) {
deltaX = Math.round(this._height-wDest);
dist = Math.round(Math.sqrt((deltaX*deltaX)));
if (dist>=5) {
if (this._height != wDest) {
this._height += (wDest-this._height)*.4;
}
} else {
//eval("this._parent." add name).go = true;
//myEval = true;
this.go=false
this._parent[name].go=true
this._height = wDest;
}
};
Thanks
Defining Function Properties.
So CS3's help docs say this:
[see Functions as Objects in the Programming Actionscript 3.0 help book]
You can define your own function properties by defining them outside your function body. Function properties can serve as... ...The following code creates a function property outside the function declaration and increments the property each time the function is called:
Code:
someFunction.counter = 0;
function someFunction():void
{
someFunction.counter++;
}
someFunction();
someFunction();
trace(someFunction.counter); // 2
The problem is that I can't see evidence of this working at all. 1119 Errors abound. Anyone else ran into this problem? Is there any other way to reference the function besides pushing it into an Array and calling from it's index?
[AS2|CS3] No Passing Of Properties As Function Arguments?
'Sup, folx.
My question today is whether or not properties, such as the _alpha of a movie clip can be fed to functions. I've put together a primitive function which ping-pongs the value of the given argument from the assigned max to the min in a continuous loop.
PHP Code:
//function declaration
function pingpong(what, max, min) {
flag = false;
_root.onEnterFrame = function() {
if (what>min && flag == true) {
what--;
} else {
flag = false;
}
if (what<max && flag == false) {
what++;
} else {
flag = true;
}
};
}
//function call
pingpong(skeletor._alpha,100,0);
If I replace the what in the function body with what._alpha and substitute the skeletor._alpha in the function call with skeletor it works; however, the way I presented it above, it does not work.
What's the correct syntax, if any?
Thanks...
Object Not Taking Properties In Function
I have the following code:
Code:
makeTextField = function(myTextField, xpos, ypos, wide, high) {
_root.createTextField(myTextField, getNextHighestDepth(), xpos, ypos, wide, high);
myTextField.multiline = true;
myTextField.wordWrap = true;
myTextField.html = true;
// makeScrollbar(myTextField);
};
makeTextField("main_txt", 210, 260, 590, 250);
If I remove everything from the function format, this works just fine, including the properties 'multiline', 'wordWrap', and 'html'. However, the above code utterly fails. The variable myTextField is treated like a string rather than a reference to an object. This is clear when trying to use with() to set the properties.
Eventually, I want to load the function into a target movie clip so I can do some animation, so this will also go into yet another function. I'm sure there's something simple I am missing. I've tried using the evaluation format with square brackets, and I've tried various ways of typing the variable name. Can anyone see what I'm not?
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;
}
}
}
Getting Properties From Object Named Passed In Function
Hi,
i am trying to get the _x and _y properties of an object passed through a function.
example
code:
trace("button="+[me]);// output _level0.displayPane.addNew.btColor
trace("button_y="+[me]._y);// Output empty, should output 32
trace("button_y="+_level0.displayPane.addNew.btCol or._y);// output 32
Why cant i used the var assinged in the function?
Thanks
paul
Getting Properties From Object Named Passed In Function
trace("button="+[me]);//Output : _level0.displayPane.addNew.btColor
trace("button="+[me].y);//Output : empty
trace("button_y="+_level0.displayPane.addNew.btCol or._y);// Output :32
Why cant [me].y return an output?
Thanks
paul
LoadVars .onload Function & Class Properties
I am using a LoadVars() object inside a class. It's loading an external text file, and all is working in that regard. Here's part of the code that checks when the text file has been loaded; I named the loadvars object "load_info":
- - - - - - - - - - - - - - - - - - - - - - - - - - -
load_info.onLoad = function(true) {
if (true) {
...bunch of statements...
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
But within the above function literal I need to be able to reference and set some of the properties of the class, and my first mistake was assuming using 'this' would do so, but it would be referencing the function object, and not the class object, as I soon found out.
I have looked at other ways of doing the onLoad-true-checking function, but I'm still at a loss.
(I also tried the dumb solution of creating new _root variables as means to transfer back and forth the class property values--it doesn't seem to work for what I'm doing... the problem being that there are many instances of the class object setting the same _root variable)
Thanks.
Watch Object Properties And Get Calling Function?
I want to watch a property of an object to see when it changes, like so:
ActionScript Code:
var myObject:Object = new Object();myObject.xDirection = -1;function objectWatcher(prop, oldVal, newVal) { trace ("xDirection is being changed from " + oldVal + " to " + newVal); return newVal;}myObject.watch("xDirection", objectWatcher);myObject.xDirection = 22;
This works as expected.
But if the value of the property being watched, is changed within a function, is there a way to tell which function that was?
EG:
ActionScript Code:
var myObject:Object = new Object();myObject.xDirection = -1;function objectWatcher(prop, oldVal, newVal) { trace ("xDirection is being changed from " + oldVal + " to " + newVal); //I want to be able to output something like this: trace("It was changed by " + NAME_OF_CALLING_FUNCTION); return newVal;}function changeTheValue():Void { myObject.xDirection = 22; }myObject.watch("xDirection", objectWatcher);changeTheValue();
Any help would be appreciated. Thanks.
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
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);
}
}
}
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();
}
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);
}
}
}
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);
}
}
}
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...
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...
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....
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);
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?
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
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!
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
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...
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
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
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?
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
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]
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).
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
How Do I Trace The Properties Of An Object's Properties?
I forgot to put it in the title so I'll just place it here; I am using AS 2.0. I know that there are other ways to accomplish the goal that am after, but I was wondering if anyone knows of a way to access the properties of an object's properties?
Here is the code that I thought of, even though it doesn't work
var a:Object = new Object();
a.bproperty = 0; //lowerlevel properties
a.cproperty = 1; // lowerlevel properties
var d:Object = new Object();
d.e = a; // upper level properties
for(var i in d){
for(var j in d.i){
trace(i + " = higher level lower level= " +j);
}
}
I know that you can enter the following code to view the 'lower level' properties of d.e:
for(var i in d.e)
This really just boils down to how I am organizing the code(I have ideas on what do next, and i am 99% sure that I can get them to work), and if there is a way to dynamically access the properties of the objects properties, It will save me from creating yet another large block of code for my project. If you want to see the unfinished project, go to http://www.garrettchristopherson.com
Is My Whole Layout Just Wrong, Wrong, Wrong
I have uploaded my layout, I am starting to think that this is not how its done, I will explain.
I have one main swf where I have 5 diffrent section where I want to load 5 different swf into, but I also need one of the swf's which would be a button based one to be able to comunicate with the other 4. I totally think now tehre is an easier way of doing this than the way I'm doing it, can someone help me out here cos as you guy's know, the roots of a good page is in the layout at the begining.
I have uploaded my swfs so you know what I'm talking about.
Please, please comment...
Actins:wrong Syntax=correct, Right Syntax=wrong
Has any body made a similar observation:
when I want to load a pic into mc and write
_root.loadMovie("pic.jpg","mc");
I get a little window just the size of my pic but not my stage. But when I write:
_root.mc.loadMovie("pic.jpg");
everything is fine. I have a Mac, OS9.1. Is this related to the flashplayer in mac or what?
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...
Properties Of .swf?
What is the naming convention used for grabbing properties from the .swf file!?
ex. I'm trying to find the height of the .swf or the x, y co-ords...just not sure what name to use for the .swf
Take Off All The Properties In A .swf?
I've been doing flash for over a year now, but I've never found out how to take off all the properties in a .swf. I've seen the allowscale = "false" or what not, but I know there's more. How do I make it so that when they right click on the stage, that it will only show "settings, about macromedia flash 6".
Thanks for all your help,
-Kac
Help~ Getting Properties
Hi there,
I need in getting the name of an movie-clip with in an movie-clip and put it into a variable name....
this is what i have...
(1) an movie-clip; call Cricle
(2) within the movie-clip, i have another 3 objects; Blue_color, Red_color, Yellow_color...
And by clicking on a button beside, i can change the color....
After changing the color how can i get the name of the movie-clip???
thankz in adv....
-----------
J3ff
X-Y Properties
I am trying to build one of them slidey square thingies, yanno the kind? The ones where you slide the little squares around in an erm larger square trying to reassemble the picture..
There is one blank square of course and I am using this blank square's x and y to determine if and how the clicked picture square can slide.
ie.
If this._y = blanksquare._y(-100)
then set property this._y to blanksquare._y
and set the blanksquare._y to blanksquare._y(-100)
And I can't get it to happen.. anyone built one these things before or can point me to some help it would be appreciated...muchly..urghh.. This is gonna keep me awake I know it..
Properties Help
in mx actionscript, how can i change the properties of a 'movie clip' to a 'button' and vice versa?
Help.. Properties...
i am doing this school yearbook using flash. i have a main movie, and all the rest are sub swfs. the main movie is 800 * 600. and the sub movies are smaller than that. the problem is that i used actionscript in one of my movies that makes snow fall randomly in the movie, with respect to the sub movies' width and height or something else that i dont know. the problem is that when i load that sub movie into the main movie, the whole snow actionscript doesnt work anymore because of the different dimensions or something. is there any way i can make the submovie follow its own properties when loaded into the main movie? i am kinda new to this. hope i can get help asap coz deadline is this week. thanks..
Properties...
i am doing this school yearbook using flash. i have a main movie, and all the rest are sub swfs. the main movie is 800 * 600. and the sub movies are smaller than that. the problem is that i used actionscript in one of my movies that makes snow fall randomly in the movie, with respect to the sub movies' width and height or something else that i dont know. the problem is that when i load that sub movie into the main movie, the whole snow actionscript doesnt work anymore because of the different dimensions or something. is there any way i can make the submovie follow its own properties when loaded into the main movie? i am kinda new to this. hope i can get help asap coz deadline is this week. thanks..
Doc Properties
I have a document which is 350px by 350px. then I have an image which get smaller and larger depending on what value it is sent.
left._height = hgt;
left._width = wdt;
when it get larger then 350, the sides get cut off. is there any way to make the document properties get larger as the image gets larger?
i've tried something this, but i can't get it:
document._xscale = hgt;
Properties
hi,
I asked this question before but I think it was too confusing. I will try again:
I have a movie clip playing in a main timeline. I am controling the frame it plays with a slider (in the main timeline). What would cause the properties of the movie clip to reset without being told (visibility).
Perhaps this is still not worded well (?)...Any suggestions would be appreciated. Thanks
Thanks
ID Properties
Setting Flash ID in the HTML
I'm following a tutorial it which it says
"you must set both the name and ID properties of the Flash movie on you html page to "shootthemup"
I've managed to set the name of the file to shootthemup, but how tdo I set the ID properties in HTML?
Any help would be greatfully received.
Leroy
Set Properties To All Mc Except One
Hello,
I want to know how can I make that a button sets the visibiliy 0 to all the mc on the frame except one called "mc5". By the way what I have is this:
on (release) {
setProperty("mc5", _visible, "100");
}
Thanks in advance
_x & _y Properties
Hey,
same calendar as in
http://www.actionscript.org/forums/s...6&goto=newpost
But another issue.
I need the tooltip to move away from my stage's boundries, for this purpose I am giving it this "frame" action after defining xStageL and xStageR in the root:
_x = this._x;
this.onEnterFrame = function() {
if ((_parent._x - this._width / 2) <= _root.xStageL){
_x = (_x + this._width / 2);
}
if ((_parent._x + this._width / 2) >= _root.xStageR){
_x = (_x - this._width / 2);
}
}
But what I'm getting is the tooltip going in the new x direction indefinetely, not staying in the new x coord...
see attached files (and let me know if you have any answers for the other thread's questions)
thxhttp://www.actionscript.org/forums/s...6&goto=newpost
|