all groups > flash actionscript > november 2004 >
You're in the

flash actionscript

group:

Problem with datatypes


Re: Problem with datatypes David Stiller
11/29/2004 2:54:38 PM
flash actionscript:
antewik,

I'm trying to follow your question. You're sending an array that has a
value of "this" -- but I don't see how that's possible.

[quoted text, click to view]

An array is going to have a number of possibilities: either no items,
one item, or many items. Each of its items could have its own datatype.
For example, this array has three datatypes:

var kitchenSink = new Array("water", 3, froggies);

Item 1 (kitchenSink[0]) is a String; item 2 (kitchenSink[1]) is a
Number; item 3 (kitchenSink[2]) is a variable named froggies, which may be
an Object, a String, a Number, perhaps even another Array!

Can you show the code you wrote relevant to the "this" statement?


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Problem with datatypes David Stiller
11/29/2004 4:35:40 PM
antewik,

What is this line intended to do?

[quoted text, click to view]

From the standpoint of a and b (which are buttons?), "this" would refer
to the main timeline (_root) or possibly to a movie clip in which a and b
are housed. In either cases, "this" would be a MovieClip datatype, since
movie clips and the main time line inherit the MovieClip class.

This means that the variable array_symbol, even though it has the word
"array" in it, is being set to a movie clip instance, which means it will
not have access to any of the Array class's methods and properties.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Problem with datatypes David Stiller
11/29/2004 4:54:13 PM
Look up the Array class in the ActionScript dictionary. You'll find a
method called Array.pop() ... that's what you use to add items to an
existing array (may help!). :)

At this point, I recommend that you start a new document altogether and
practice a bit with the Array class. Forget all the other code just for a
minute and create an array, add items to it via the constructor, via the
..pop() method, and so on. When you feel comfortable with it, step back into
your main project and you may see something you didn't see before.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Problem with datatypes antewik
11/29/2004 7:07:16 PM
Hi. I have made a program where I need to send some information between two
swf-files, and I am using LocalConnection to do that. The problem I ran into
was when I tried to send an array that had the value of 'this'. The other
swf-file couldn't recognice that so when I traced it, it said 'undefined'. I
thought it was something that didn't work with LocalConnection, but the same
problem happend when I tried to give the value to another variable. What am I
doing wrong?
Re: Problem with datatypes antewik
11/29/2004 9:25:03 PM
Thanks for answering me David. Here is part of the code that is relevant.
a.onPress = b.onPress = function() { mc = this.duplicateMovieClip('mc'+i, i);
--------> array_symbol = this; // HERE IS THE ARRAY I AM TALKING ABOUT }
b.onReleaseOutside = b.onRelease = a.onReleaseOutside = a.onRelease =
function() { i = i+i } ....... var lc = new LocalConnection();
lc.send('copy', 'symbol', array_symbol, count) If I send a other array that
has values for exampel 'Hello', it works fine. //The other swf-file
aLocalConnection.symbol = function(bString, count) { for(var i=0; i<h;
i++) { mc = bString.duplicateMovieClip('mc'+i, i); } }

Re: Problem with datatypes antewik
11/29/2004 9:49:14 PM
What I want to do is putting every MC (which are named a and b) into the array
so i know which MC i have duplicated. The array gets values somthing like this.
array_symbol[_level0.a, _level0.b, _level0.b, _level0.a] This values, I want
to send to another swf-file which also have MovieClips in the root, named a and
b. I want them to duplicate and get the same position and siza as the ones in
the first swf-file.
Re: Problem with datatypes NSurveyor
11/29/2004 9:50:15 PM
And by the way, please don't use the variable i. I don't have anything against
it. But, in many cases, people use myArray and such. And in the web-based
forums, [i makes text italic. Same goes with using [b],,, and [L]. Or, if you
use the web-based forums, when replying hit 'Attach Code' and paste in your
code there, to save it's formatting, without the code being change.
Re: Problem with datatypes antewik
11/29/2004 9:59:30 PM
Re: Problem with datatypes NSurveyor
11/29/2004 10:04:21 PM
Re: Problem with datatypes antewik
11/29/2004 10:15:36 PM
I just made it possible to send the array when i wrote array_symbol = String(this);
Re: Problem with datatypes antewik
11/29/2004 10:21:40 PM
I hope you understand someting

//First swf-File
var symbolUp;
var symbolDown;
var symbolLeft;
var symbolRight;

ekimhand._visible = 0;
markering._visible = 0;

//------------------------------------------------------------------------------
---------------
// Funktion som g?r att den bl? markeringsrutan och symbolkontrollen f?ljer
med symbolen d? den
// flyttas, samt att den ser till att markeringsrutan f?r samma storlek som
symbolen.

function moveF(tagAlongMC, draggedMC)
{
tagAlongMC._x = draggedMC._x + draggedMC._width;
tagAlongMC._y = draggedMC._y + draggedMC._height;
markering._width = draggedMC._width
markering._height = draggedMC._height
markering._x = draggedMC._x;
markering._y = draggedMC._y;
updateAfterEvent();
}

//------------------------------------------------------------------------------
---------------
// Funktion som ?ndrar storleken p? aktiv symbol och dess markering n?r
symbolkontrollen flyttas.
// Storleken ?kar/minskar d? med samma antal pixlar som kontrollen flyttas i
x- och y-led.

function resizeF()
{
activeMC._width = startWidth+(ekimhand._x)-startx;
activeMC._height = startHeight+(ekimhand._y)-starty;
markering._width = startWidth+(ekimhand._x)-startx;
markering._height = startHeight+(ekimhand._y)-starty;
updateAfterEvent();
}

//------------------------------------------------------------------------------
---------------
// N?r man klickar p? en symbol i rullgardin21 s? dupliceras det MovieClippet.
?ven ett filter
// skapas f?r just det MCet f?r att det ska vara synligt endast inom ramen f?r
bakgrundsbilden.
// Kopian som skapats blir drag bar och kan sl?ppas n?gonstans p? bakgrunden
genom hitTest.
// Sl?pper man den utanf?r s? tas MC bort. MC kan sedan flyttas runt igen inom
ramen f?r bakgrunden
// och symbolkontrollen f?r h?r den kod som g?r att den h?ller reda p? vilken
inst?llning varje
// kopia har vad g?ller genomskinlighet.

a.onPress = b.onPress = function()
{
mc[h] = this.duplicateMovieClip("mc"+h, l);
array_symboltyp[h] = String(this);

filter[g] = _root.filter.duplicateMovieClip("filter"+g, m);
activeMC = mc[h];
activeMC._alpha = 100;
startDrag(activeMC);

mc[h].onPress = function()
{
symbolUp = (filter._y)-(filter._height/2)-(this._height/2)
symbolDown = (filter._y)+(filter._height/2)-(this._height/2)
symbolLeft = (filter._x)-(filter._width/2)-(this._width/2)
symbolRight = (filter._x)+(filter._width/2)-(this._width/2)

startDrag(this, false, symbolLeft, symbolUp, symbolRight, symbolDown);
this.swapDepths(activeMC);
ekimhand.swapDepths(14000);
markering.swapDepths(14100);
activeMC = this;

var skala = 1+(1/10);
var alpha = (this._alpha / 100)
var skala = ((skala + alpha) * 30); // sliderns _x intervall ligger mellan
33-63
ekimhand.slider._x = skala;

markering.setMask(_root.filter);
ekimhand._visible = true;
ekimhand._x = activeMC._x + activeMC._width;
ekimhand._y = activeMC._y + activeMC._height;
markering._visible = true;
markering._width = activeMC._width
markering._height = activeMC._height
markering._x = activeMC._x;
markering._y = activeMC._y;
bgram._visible = false;
_root.moveI = setInterval(_root.moveF, 0.1, ekimhand, activeMC);
}
mc[h].onRelease = mc[h].onReleaseOutside = function()
{
stopDrag();
clearInterval(_root.moveI);
}
}

//------------------------------------------------------------------------------
---------------
// N?r man sl?pper den duplicerade symbolen som skapats genom att klicka i
rullgardinsmenyn s?
// kopplas alla symboler till ett eget filter, samt st?ller markeringsrutan
och symbolkontrollen
// p? aktiv symbol.

b.onReleaseOutside = b.onRelease = a.onReleaseOutside = a.onRelease =
function()
{
stopDrag();
markering.setMask(_root.filter);

if (mc[h].hitTest(traff))
{
for(var j=0; j<=h; j++)
{
filterMC = filter[j];
mc[j].setMask(filterMC);
}

ekimhand._visible = true;
markering._visible = true;
bgram._visible = false;
ekimhand._x = activeMC._x+activeMC._width;
ekimhand._y = activeMC._y+activeMC._height;
markering._width = activeMC._width;
markering._height = activeMC._height;
markering._x = activeMC._x;
markering._y = activeMC._y;

g = g+1;
h = h+1;
l = l+1;
m = m+1;
}
else
{
activeMC.removeMovieClip();
activeMC = null;
}
}

//------------------------------------------------------------------------------
---------------
// G?r symbolkontrollen dragbar, anger dess startposition i x- och y-led och
skickar sedan dessa
// v?rden till funktionen resizeF() som ?ndrar p? symbolens storlek allt
eftersom kontrollen flyttas.

ekimhand.drag.onPress = function()
{
startDrag(ekimhand);
startWidth = activeMC._width;
startHeight = activeMC._height;
startx = ekimhand._x;
starty = ekimhand._y;
resizeI = setInterval(resizeF, 1);
}

ekimhand.drag.onRelease = ekimhand.drag.onReleaseOutside = function ()
{
stopDrag();
clearInterval(resizeI);

if((activeMC._x + (activeMC._width)) < (traff._x - (traff._width/2)))
{
activeMC.removeMovieClip();
activeMC = null;
ekimhand._visible = false;
markering._visible = false;
//activeMC._x = activeMC._x + (activeMC._width/2);
//markering._x = activeMC._x;
}
if((activeMC._y + (activeMC._height)) < (traff._y - (traff._height/2)))
{
activeMC.removeMovieClip();
activeMC = null;
ekimhand._visible = false;
markering._visible = false;
//activeMC._y = activeMC._y + (activeMC._height/2);
//markering._y = activeMC._y;
}
}

//------------------------------------------------------------------------------
---------------
// G?r att aktiv symbol avmarkeras d? man trycker utanf?r symbolen.
_root.filter.onPress = function()
{
ekimhand._visible = false;
markering._visible = false;
//ekimhand._y = 1000;
//markering._y = 1000;
}

//------------------------------------------------------------------------------
---------------
//Skriv f?rklaring h?r.
var test = -30;
intervallID5 = setInterval(
function()
{
ekimhand.slider.onPress = function()
{
startDrag(this, false, 33, (4,5), 63, (4,5));

ekimhand.slider.onMouseMove = function()
{
var test = test +(ekimhand.slider._x-3); // 33-63
setProperty(activeMC, _alpha, ((test/30)*100))
}
}

ekimhand.slider.onRelease = ekimhand.slider.onReleaseOutside = function()
{
stopDrag();
}
}, 100)

_global.global_array_bg_copy = new Array();

var array_filnamn_copy = new Array();

var adress_copy;
var bglank_copy

uppdateraknapp.onPress = function()
{

var lc = new LocalConnection();
Re: Problem with datatypes NSurveyor
11/29/2004 10:30:59 PM
I believe this should work. When the other swf recieves the array_symbol. Add
this line of script:
array_symbol = makeValue(array_symbol);
function makeValue(var){
varLevels = new Array();
varLevels = var.split(".");
previousLevel = this;
for(count = 0;count<varLevels.length;count++){
previousLevel = previousLevel[varLevels[count]]
}
return(previousLevel);
}
Re: Problem with datatypes antewik
11/29/2004 10:51:54 PM
Sorry, but I didn't get the code working.
I have to try a bit more so that I understand what the code you gave me is doing.

Re: Problem with datatypes antewik
11/29/2004 10:52:05 PM
Sorry, but I didn't get the code working.
I have to try a bit more so that I understand what the code you gave me is doing.

Re: Problem with datatypes NSurveyor
11/29/2004 10:58:04 PM
Sorry, just an issue with using a variable called var. Use this:
array_symbol = makeValue(array_symbol);
function makeValue(myvar){
varLevels = new Array();
varLevels = myvar.split(".");
previousLevel = this;
for(count = 0;count<varLevels.length;count++){
previousLevel = previousLevel[varLevels[count]]
}
return(previousLevel);
}
Re: Problem with datatypes antewik
11/29/2004 11:05:16 PM
Re: Problem with datatypes NSurveyor
11/29/2004 11:31:52 PM
Re: Problem with datatypes Jeckyl
11/30/2004 9:19:47 AM
AFAIK you cannot access objects in one movie from another, unless they are
playing in the same player (eg loaded into different levels).
--
All the best,
Jeckyl

Re: Problem with datatypes antewik
11/30/2004 9:36:44 AM
I have tried to use the code that you gave me NSurveyor, but I couldn't make it work.
Is there anyone who can comment that code?

Re: Problem with datatypes Jeckyl
11/30/2004 9:57:03 AM
[quoted text, click to view]

Bad coding there ... 'var' is a reserved word and should NOT be used as a
variable name .. it may get you into trouble !! (and won't compile
correctly)

Even if it happens to work in some case (it fails for me in AS1 and AS2), it
may well fail in next flash etc.
--
All the best,
Jeckyl

AddThis Social Bookmark Button