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




Working With Objects



So this time I have a few more questions:So I need to make this chess game in AS3, it's a pretty big project since it's the first thing I've ever coded in AS3, and I was never over familiar with AS2 - defiantly in need of some help.1) Is it possible to assign custom attributes / properties to objects, for example, all my tiles are individual objects that have been added and positioned with a loop, can they have properties like "hasPiece" or whatever that I can assign to them and they will hold their values. Don't know if that question makes sense..2) I have my pieces divided into classes, and I am just starting to figure those out (classes). So I think my issue deals with the Display Object Container... Right now I have my Stage > Main Timeline > Chess Tile > Piece... and I want to be able to move the piece to other chess tiles, but I'm not sure I can because I used addChild on a specific tile movie clip. Is it possible to move that Piece to a new Chess Tile (having the code in the pieces class), and if so, any ideas as to how I could do it?3) How do I work with depth with as3? Before I could just say depth++. I need to make it so when they click on a specific piece it's depth is brought to the highest.Any help with these questions would be great. Thanks a ton!!



Actionscript 3.0
Posted on: Mon Jun 30, 2008 5:15 am


View Complete Forum Thread with Replies

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

Working With Objects
Hi guys i am trying to get in heavy with action script obects and i have a question

i have the following code in frame one

------code--------
var VarObj = new LoadVars();
strObj = new String(VarObj.textVar);
spltStr = strObj.split("
");
str = spltStr.shift();

function createVariables(loadtext) {
VarObj.load(loadtext);
VarObj.onLoad = function(success) {
if (!success) {
trace("it didnt load");
} else {
gotoAndStop(2);
}
};
}
createVariables("introText");
-----end---------

in frame 2

i have
trace("this is a new string array: "+spltStr);
trace("this is first element in array: "+str);

but i dont get any output for the spltStr and str var

However in debuggin i see

Variable _level0.strObj = [object #6, class 'String'] {}
Variable _level0.spltStr = [object #7, class 'Array'] []
Variable _level0.str =

Now i am trying to understand what this means
do i then need to strObj.spltStr? to access the string?

what does the above debug log mean?

Working With Display Objects
I'm having an issue with finding the correct components in my program to refresh on a canvas and it seems the entire component is being considered a display object. So, I come here after reading tutorials and having no luck.

Example of my code:

Something.as

ActionScript Code:
initComponent()
{

//initialize an image
this.addChild(img);

//initialize a second image
this.addChild(img2);

//initialize a label
this.addChild(label);

}

This object is then displayed on a canvas, and I'm trying to access one of the images to toggle the visibility of the image to on and off. However, I've been unsuccessful thus far.

From the file I'm working with I can create an array of children of Display Objects in such a format:

var arr:Array = thing.getChildren();

and I can assign each child to a variable, and when I get the name of each of the objects, they are the class Something + a number, but I can't access anything within the display object. Obviously, I'm doing something wrong, but how do you access each of the three components that I added after the object has been created?

Thanks for the help.

Sound Objects Not Working In Loaded SWF
here is the code... all on one timeline

initialize...

loop12=new Sound();
loop12.attachSound("loop1");

play...

loop12.start(0,999);

FLA files
Master Container Movie
Sound Object Player

The audio plays fine when "audio.fla" is tested, but when I test "folioContainer", it doesn't work.

The targetting all seems to be fine, since I kept all the variables on the same level.

Help would be appreciated...
thx in advance

[F8] Shared Objects Half Working... Please Help
Hey, if you could please look at the below code... I am trying to use 3 shared objects, each holding 5 pieces of info each.

"five5" works perfectly, but "five6" and "five7" do not work at all... is there something wrong with my shared object coding?

am I going about this all wrong?

code:
five5 = SharedObject.getLocal("five5");
five6 = SharedObject.getLocal("five6");
five7 = SharedObject.getLocal("five7");

/////////////////////// START EDIT BUTTONS //////////////////////////////


_root.edit_five5.onRelease = function(){
save_buttons.gotoAndStop("five5");
rope1 = five5.data.rope1;
rope2 = five5.data.rope2;
rope3 = five5.data.rope3;
rope4 = five5.data.rope4;
rope5 = five5.data.rope5;
}

_root.edit_five6.onRelease = function(){
save_buttons.gotoAndStop("five6");
rope1 = five6.data.rope1;
rope2 = five6.data.rope2;
rope3 = five6.data.rope3;
rope4 = five6.data.rope4;
rope5 = five6.data.rope5;
}

edit_five7.onRelease = function(){
save_buttons.gotoAndStop("five7");
rope1 = five7.data.rope1;
rope2 = five7.data.rope2;
rope3 = five7.data.rope3;
rope4 = five7.data.rope4;
rope5 = five7.data.rope5;
}



//////////////////////////// END EDIT BUTTONS ///////////////////////////////



/////////////////////////// START SAVE BUTTONS //////////////////////
_root.save_buttons.save_five5.onRelease = function(){
five5.data.rope1 = rope1
five5.data.rope2 = rope2
five5.data.rope3 = rope3
five5.data.rope4 = rope4
five5.data.rope5 = rope5
five5.flush();
}

_root.save_buttons.save_five6.onRelease = function(){
five6.data.rope1 = rope1
five6.data.rope2 = rope2
five6.data.rope3 = rope3
five6.data.rope4 = rope4
five6.data.rope5 = rope5
five6.flush();
}

_root.save_buttons.save_five7.onRelease = function(){
five7.data.rope1 = rope1
five7.data.rope2 = rope2
five7.data.rope3 = rope3
five7.data.rope4 = rope4
five7.data.rope5 = rope5
five7.flush();
}



/////////////////////////// END SAVE BUTTONS ///////////////////////

[F8] Shared Objects And Variables Not Working Together
I am trying to make an easier, cleaner way to develop my website, but my idea isn't working. Here is what I have


videodata.data.DVDSLATETITLE = "VariableTitle"
titled = videodata.data.DVDSLATETITLE;
videodata.data.titled = "Yes";

Of course these codes are spread out on the site, along with other different codes that set different values to the DVDSLATETITLE.

Bottom line is that these actions put together don't set VariableTitle to Yes, but titled to Yes. I need to tell flash that the "titled" in videodata.data.titled is a variable. How can I do this?

New Org.papervision3d.objects.Cube Not Working
Hi. just checking if this is actually the case. I can't specify the full package of class when I want to define or instantiate the class (because that would be just stupid)? So the following results in a syntax error?

Code:
mycube = new org.papervision3d.objects.Cube( null );
Please say I'm wrong...

Sound Objects Not Working Properly
I've looked over this and had other people do the same but for some reason my sounds aren't playing. the first two sounds are playing but not the rest and if you delete the first two the third will work. This makes no sense!
The function is working because the clips are changing it's just that the sound doesn't work.

I'm using a track expansion module to split the sound objects into two tracks but this seems to be working for the others so I don't think it is the problem.

Here is the function that should control the sounds (and does for the forst two)

function setUpKey(clip, sObject, kb) {

clip.myKeyNum = kb;
clip.mySound = sObject;
clip.onPress = function() {
if (_root.holdIt == false) {
clip.gotoAndStop(2);
sObject.setLevel(100);
}
};
clip.onRelease = clip.onReleaseOutside=function () {
if (clip._currentframe == 2 && _root.holdIt == false) {
clip.gotoAndStop(1);
sObject.setLevel(0);
}
if (clip._currentframe == 1 && _root.holdIt == true) {
clip.gotoAndStop(2);
sObject.setLevel(100);
} else {
if (clip._currentframe == 2 && _root.holdIt == true) {
clip.gotoAndStop(1);
sObject.setLevel(0);
}
}
};
}
setUpKey(c, _root.cnatural, 81);
setUpKey(csharp, _root.csharp, 87);
setUpKey(d, _root.dnatural, 69);
setUpKey(eflat, _root.eflat, 82);
setUpKey(e, _root.enatural, 84);
setUpKey(f, _root.fnatural, 89);
setUpKey(fsharp, _root.fsharp, 85);
setUpKey(g, _root.gnatural, 73);
setUpKey(aflat, _root.aflat, 79);
setUpKey(a, _root.anatural, 80);
setUpKey(bflat, _root.bflat, 219);
setUpKey(b, _root.bnatural, 221);

allClips = new Array(c, csharp, d, eflat, e, f, fsharp, g, aflat, a, bflat, b);

watchKeyboard = new Object();

watchKeyBoard.onKeyDown = function() {
checkKeyDown(Key.getCode());
};
watchKeyBoard.onKeyUp = function() {
checkKeyUp(Key.getCode());
};
Key.addListener(watchKeyBoard);
function checkKeyDown(theKey) {
for (i=0; i<allClips.length; i++) {
targ = allCLips[i];
if (targ.myKeyNum == theKey) {
if (_root.holdIt == false) {
targ.gotoAndStop(2);
targ.mySound.setLevel(100);
}
}
}
}
function checkKeyUp(theKey) {
for (i=0; i<allClips.length; i++) {
targ = allCLips[i];
if (targ.myKeyNum == theKey) {
if (targ._currentframe == 2 && _root.holdIt == false) {
targ.gotoAndStop(1);
targ.mySound.setLevel(0);
}
if (targ._currentframe == 1 && _root.holdIt == true) {
targ.gotoAndStop(2);
targ.mySound.setLevel(100);
} else {
if (targ._currentframe == 2 && _root.holdIt == true) {
targ.gotoAndStop(1);
targ.mySound.setLevel(0);
}
}
}
}
}




and this is what sets up the sound objects and tracks (in the _root)
stop();
//audio controls
#include "track_expansion_module.as"
//New sounds
_root.createEmptyMovieClip('holder1', 1);
_root.createEmptyMovieClip('holder2', 2);
_root.createEmptyMovieClip('holder3', 3);
_root.createEmptyMovieClip('holder4', 4);
_root.createEmptyMovieClip('holder5', 5);
_root.createEmptyMovieClip('holder6', 6);
_root.createEmptyMovieClip('holder7', 7);

//define custom tracks and start all except for the teacher
candcsharp = new Sound(holder1);
candcsharp.attachSound("first");
cnatural = new Track("left", candcsharp);
csharp = new Track("right", candcsharp);
candcsharp.start(0,999);
candcsharp.onSoundComplete = function() {
this.start(0,999);
};

welcome = new Sound(holder2);
welcome.attachSound("both");
welc = new Track("right", welcome);
welcsilent = new Track("left", welcome);

dandeflat = new Sound(holder3);
dandeflat.attachSound("second");
dnatural = new Track("left", dandeflat);
eflat = new Track("right", dandeflat);
dandeflat.start(0,999);
dandeflat.onSoundComplete = function() {
this.start(0,999);
};

eandf = new Sound(holder4);
eandf.attachSound("third");
enatural = new Track("left", eandf);
fnatural = new Track("right", eandf);
eandf.start(0,999);
eandf.onSoundComplete = function() {
this.start(0,999);
};
fsharpandg = new Sound(holder5);
fsharpandg.attachSound("fourth");
fsharp = new Track("left", fsharpandg);
gnatural = new Track("right", fsharpandg);
fsharpandg.start(0,999);
fsharpandg.onSoundComplete = function() {
this.start(0,999);
};
aflatanda = new Sound(holder6);
aflatanda.attachSound("fifth");
aflat = new Track("left", aflatanda);
anatural = new Track("right", aflatanda);
aflatanda.start(0,999);
aflatanda.onSoundComplete = function() {
this.start(0,999);
};
bflatandb = new Sound(holder7);
bflatandb.attachSound("sixth");
bflat = new Track("left", bflatandb);
bnatural = new Track("right", bflatandb);
bflatandb.start(0,999);
bflatandb.onSoundComplete = function() {
this.start(0,999);
};

If you want to look at the .fla or .as they are at http://opax.swin.edu.au/~408421/brief1/

I'm a Uni student and this is due at the end of the week, so any help would be greatly appriciated.

Why Are Counter Created New XML Objects Not Working?
I'm sure this is simple and stupid of me. Why does this work...

textForContent = ["1.xml","2.xml","3.xml","4.xml","5.xml","6.xml","7 .xml"]

counter = textForContent.length-1;

while (counter>=0){
xmlData = new XML();
xmlToLoad = textForContent[counter];
xmlData.load(xmlToLoad);

xmlData.onLoad = function(success)
{
if(success)
{
trace(xmlData)
}
}
counter--;
}
stop();


And this does not work? All I've done is try to create 7 new XML objects using the counter...

textForContent = ["1.xml","2.xml","3.xml","4.xml","5.xml","6.xml","7 .xml"]

counter = textForContent.length-1;

while (counter>=0){
xmlData[counter] = new XML();
xmlToLoad = textForContent[counter];
xmlData[counter].load(xmlToLoad);
xmlData[counter].onLoad = function(success)
{
if(success)
{
trace(xmlData[counter])
}
}
counter--;
}
stop();

Thanks

Removing Objects From An Array Not Working
I can't use shift() or splice() and it's driving me insane:


ActionScript Code:
var glength:int = gatActivePool.length;for (var a:int = 0; a < glength; a+=1) {    var gatling:PBulletGat = gatActivePool[a];    if (gatling.dead) {    // If it's not already in the InactivePool, push it in        if (gatInactivePool.indexOf(gatling) < 0) gatInactivePool.push(gatling);        // Remove it from the ActivePool...        // CAUSES NULL OBJECT ERROR:        //gatActivePool.shift();        // SAME:        gatActivePool.splice(gatActivePool.indexOf(gatling), 1); // doesn't work with splice(a, 1) either                } else {         gatling.update();    }}

As you probably guessed, this is for a game. Elsewhere, in a shoot() method I have this:


ActionScript Code:
var gat:Gat1 = gatInactivePool.shift();gatActivePool.push(gat);gat.spawn();

So while the player is shooting (adding to the active pool), the game will add the bullet back to the inactive pool if it leaves the screen. So there's a lot of shifting going on, which is why I figured I was getting a null return when I used splice() (hard to get an index position if the index keeps changing), so I tried shift instead to blindly remove the first element, but that didn't work either.

So does anyone have any idea why I can't remove anything from the gatActivePool array at all? Is there a better way to recycle particles?

Dynamically Working With Library Objects
I need to take 10 instances of a library button and place them on different locations of the stage. I need to give each of them a unique name, URL, and position them on the stage according to database information. Any help would be great!.

Trouble Getting Sound Objects Working In An External SWF
I have tried targetting the root, and just keeping the targetting within the external swf, neither system works. As of now I have all the objects activated on the root level.

Does anyone know a way around this. Here's the Fla's for reference
(only the intro page is active)


parent movie:
http://www.spfstudios.com/temp_fla/spf_index.fla
Child:
http://www.spfstudios.com/temp_fla/spf_intro_sc.fla

Thanks in advance...

Sahred Objects.. Cant Get Them Working Within Movie Clip
Hi guys. I asked this question last year here and didnt get any help with it so I went in another direction. This time I cant work around it. Here is my problem... I am making a program that keeps track of a stores inventory. I want it so when you click the button it saves the variables with shared objects. Works fine in the movie i put it together in but when I put it inside a Movie clip... nothing happens. here is the code I am using on the button



on (release){

local_data.data.product1name = product1name

}


and here is the load action on the frame.

local_data = SharedObject.GetLocal("user_data");
product1name=local_data.data.product1name;



any ideas what I have to do to make this work within a movie clip? I do not understand why it wouldnt work!! Any help from you pros if you arent too busy would be great. Thanks alot in advance!

Flash Shared Objects Not Working Locally.
Has anyone had problems with shared objects not working when running a program on a local computer. Before I did my most recent Windows update they worked locally, now they only work if I upload it and look online.

Just wondering?!

thanks in advance, g

Moving Dynamic Objects In Scrollpane Scrollbar Not Working Properly
i am adding button movieclip in a scrollpane and moving dynamically while doing so
the scrollbar is not working properly can any body help me

Store And Retrieve Array Of Custom Class Objects From Shared Objects.
Hi,

I am stuck up with a problem in ActionScript 2. I am using Flash MX 2004 on windows XP.

I have created 3 custom classes say Parent, Child, and GrandChild. Parent class contains in it an array of its Child objects. Similarly each Child object contains in it an array of GrandChild objects. Also I do have one global array of all the Parent objects.

I want to store this array to the shared objects on specific events(say exiting the session) and then reload them from the shared object(on next session startup). I am able to store the global array to the shared object but when I try to retrieve the same array from shared object, I could not do it. The retrieved array is not of my custom class type [Parent].

Help needed to solve this problem urgently. Does anybody have idea how to do it??

Thanks in advance.



Cheers,
Naishadh Sevalia

Objects Talking To Objects, Parent/child Communication, Scope
I've been using AS3 at an intermediate level, and am getting deeper
into classes. I'm loving classes! I'm just cloudy on a few general
concepts.

It's easy for me to create a child object from a parent object, like a
ship in space for example (not working with ships right now but seems
fun to talk about). I can then navigate the ship from the parent
object.

What happens if the ship's engine temperature reaches critical? Is it
wise to dispatch a ship event that tells space that my ship is nearly
scrap? Or do I periodically query the temperature amount of the ship
from space? To me an event sounds like the solution, but I remember
hearing somewhere that parent objects should only talk to child
objects, not the other way around. Is this true?

Could I trouble someone for a basic example of how you would make this
communication work best?

Thanks for the assist. I'll post if I find anything interesting in
the meantime.

How Do I Reference Objects Inside Of Exported Library Objects ?
Hi,

I am having trouble figuring out what seems to be a simple fix? I have created a movieClip in Flash that contains 3 button clips. I want all to be accessible to actionscript, so I gave the movieClip and the 3 buttons a Linkage Identifier. I deleted them from the stage.

In actionscript, I have instantiated the movieClip and, thankfully, the buttons inside went along.

The trouble I'm having is figuring out how to target those buttons. Since they're on the stage already, I shouldn't have to create a new instance right? When I trace the buttons I get an undefined return in the out put.

Anybody know this one??

Thanks for the help!

Brian

Depth And Dynamic Objects/Attaching Scripts To Objects
I am having some problems with my Flash MMORPG created in Actionscript 3.0 that I am working on, not really errors, but more how to do something, in theory. I have 2 problems. First, my game is at a 45 degree angle, so it requires some depth handling(like one object is over another object when it should be behind that object). I am not sure how to go about this. I was thinking that each object's depth should be it's y position if it's origin was at it's feet. But that idea didn't go well, because the depth is limited by the number of children. What is the average way to do this? Next, I am trying to make dynamic objects, so that all I would do is copy and paste an object, or create a new class of it and it would work. What I mean is, the character checks a collision for each object, but if I copy the object with the same name, it doesn't work. In AS3 you can't attach scripts to objects anymore, so I am running into a lot of problems with that. How would I go about fixing this? Thank you in advance.

Aligning Variable Sized Objects And Objects Inside Them
Hi,

How do I align a movieclip, which width and height is user-defined, inside another object (this one is static, though). Top-left alignment is easy, x=0 and y=0, but what about center, center left, bottom left, etc? Math(.round) i suppose, but how?

and

I want an object (static) inside the movieclip (user-defined) to stay aligned to, for instance, the top right corner, similiar to the minimize, maximize and close buttons at the top right of your browser..

The height and width data is pre-defined by the user in another file... But that does probably not make any difference...



If anyone could help me with this, I'd appreciate it alot!

Thanks!,
Peter

Best Way To Hide On Stage Objects When Other Objects Need To Be Shown?
A typical nubee question..What is the best way to hide objects on sage when a button from navigation is clicked and in response other information or objects need to be shown instead of the one previously on stage?

How To Output Both AS Objects And Drawn Objects On Pages?
Using Flash 8;

Hello,

I am building a site entirely in actionscript and the "shell" of the site, the pages, text, static images, come up and work fine, no problems.

However, I'm having troubles trying to implement Kirupa's "XML_Flash Photo Gallery", for one of my pages, link here:

http://www.kirupa.com/developer/mx20...otogallery.htm.

I'm running into troubles because my pages are entirely actionscript and this tutorial uses objects which were drawn by the drawing tool.

I have been trying to get both actionscript and drawn objects to work together and cannot get it right!!

Questions:

1) In terms of layering or frames, What is the best way to output on your pages both "objects drawn by the Flash drawing tools" and "actionscript objects"?

Is this better handled using frames or layers? Should I place my actionscript on the first few frames, then my "drawn objects" on the later frames? Or use layers and have my AS code above or below the manually drawn objects?

For example:

I have my actionscript on layer 1. Then use drawing tools to draw a box on layer 2.

When published, I want the "manually drawn box" and "the actionscript drawn objects" to both be viewable on the pages. Do I place the "drawn" layer above or below the

actionscript layer? Or should this be handled by frames?

I have tried both and neither seem to work for me. When I do one or the other, it works, meaning, all drawn objects, obviously things are viewable, then if

I use all actionscript, things are viewable, but when I try to combine both, the manually drawn objects do not show up.

The actionscript objects show up correctly, but I cannot see the objects I have directly drawn on-stage.

In my actionscript, I use, "_root.getNextHighestLevel()", for each of the objects, this works fine for all the actionscript objects. However, I did nothing

for the objects drawn using the tools, should I attach the same "_root.getNextHighestLevel()" to those objects drawn on-stage?


Or,


2) Should I try to draw Kirupa's objects on my pages using actionscript?

Thanks, any help is great!!

Dave.

Help: Stage Objects Get In Front Of Script Objects?
This is getting me mad...

addChild(my_script_object);

I can't see it...

If I try trace(numChildren) I get 10, so then I try addChildAt(my_script_object,9) and still cant' see it.

If I delete all the objects in stage then I finally see it.... If I delete one by one I find my_script_objects gets beneath a bitmap placed by hand by the designer.

Any ideas?

TIA

Best Way To Hide On Stage Objects When Other Objects Need To Be Shown?
A typical nubee question..What is the best way to hide objects on sage when a button from navigation is clicked and in response other information or objects need to be shown instead of the one previously on stage?

About Referencing Objects And Copying Objects
This is for AS1

hi,

i should know this but i got lost for a bit, can someone make this clear:

i have the following:

code: myobject=new Object()
myobject.var="hello"
getvar=myobject.var

In this case, get var has a reference for myobject.var, or it has just copied de value? mean if i update myobject.var to "good bye" get vatr will be that, too, or will stay as "hello".

If it's just a reference, how can make it a different variable, i mean, assign the value of myobject.var to getvar and loose any relationship between myobject.var and getvar, so if i update one, the other doesn't.

Anyone?

Problem With Class Objects Within Objects
Hi There,
I am having trouble creating an oop grid.
My initial object is "world" shown below which will contain an array of "Row" objects, which in turn contains an array of tile objects.
As i build up the rows and assign the tiles everything seems fine but when i try to retrieve the values the tiles in each row returns the same values from each tile..


class world{

//declare class members
private var goalScore
private var mapPreview
private var title
private var editor
private var createdBy
private var movieBorder
private var instructions
private var rows = new Array()

//Constructor
public function world(Param_goalScore, Param_mapPreview, Param_title, Param_editor, Param_createdBy, Param_movieBorder, Param_instructions){
this.goalScore = Param_goalScore
this.mapPreview = Param_mapPreview
this.title = Param_title
this.editor= Param_editor
this.createdBy= Param_createdBy
this.movieBorder= Param_movieBorder
this.instructions= Param_instructions
}

//Methods
public function createRow(){
if (rows==null){
this.rows[0] = new row()
}else{
this.rows[rows.length] = new row()
}
return this.rows[rows.length-1]
}

}
class row{

//declare class members
public var tiles = new Array()


//Constructor
public function row(){

}

//Methods
function createTile(Param_tileType, Param_completionScore, Param_objectType){
if (tiles==null){
trace("created first tile")
this.tiles[0] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}else{
trace("created tile " + tiles.length +" tiles="+tiles)
this.tiles[this.tiles.length] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}
return this.tiles[this.tiles.length-1]
}

}

class tile{

// declare class members
public var tileType;
public var completionScore;
public var objectType;
public var character;


// Constructor
public function tile(Param_tileType, Param_completionScore, Param_objectType){

tileType = Param_tileType;
completionScore = Param_completionScore;
objectType = Param_objectType;

//movementPreset = Param_movementPreset

//error = Param_error
//errorImage = Param_errorImage

}

// Methods

}

Any advice will be greatly received.

Jason

Mask Objects And Masked Objects
Well.. I don't know if there is already a thread on this subject, but I have this doubt, and I would really like some support.

Been trying to use one mask object to mask several movies, but it doesn't seems to work. Has anyone ever managed to do this?

For example:

Let's say I have three MC - man, woman and baby are their names - and I want to use setMask to mask then so they walk behind the walls of a house, but just show up through the window. I create, then, a mask object - one object with the shape of the window inside it - named it windowMask, put it in _root and added to my actions layer the following lines:

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask);
baby.setMask(_root.windowMask);
Unfortunately, only the last of them - baby in this case - is masked.

Can't I use one mask object to mask multiple MCs?

Everything works fine if I duplicate the mask MC and set each copy as a mask for each of them.

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask1);
baby.setMask(_root.windowMask2);
The thing is, what I wrote above is just an example. The real movie has 30 to 40 MC which should be masked by the same mask object and I don't want to have 30 to 40 mask objects dangling around my movie...

Mask Objects And Masked Objects
Well.. I don't know if there is already a thread on this subject, but I have this doubt, and I would really like some support.

Been trying to use one mask object to mask several movies, but it doesn't seems to work. Has anyone ever managed to do this?

For example:

Let's say I have three MC - man, woman and baby are their names - and I want to use setMask to mask then so they walk behind the walls of a house, but just show up through the window. I create, then, a mask object - one object with the shape of the window inside it - named it windowMask, put it in _root and added to my actions layer the following lines:

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask);
baby.setMask(_root.windowMask);
Unfortunately, only the last of them - baby in this case - is masked.

Can't I use one mask object to mask multiple MCs?

Everything works fine if I duplicate the mask MC and set each copy as a mask for each of them.

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask1);
baby.setMask(_root.windowMask2);
The thing is, what I wrote above is just an example. The real movie has 30 to 40 MC which should be masked by the same mask object and I don't want to have 30 to 40 mask objects dangling around my movie...

Making Objects Go Behind And In Front Other Objects
Say I wanted to tween something so that it like rotates around it.
IE: a moon rotating around a planet, an electron orbiting a nucleus

How would I make the orbiting object go in front and behind the stationary object?

AS3: XObject Class - Treat Objects Like XML (E4X4O - "E4X For Objects")
I just finished this a few minutes ago (coincidentally while at a SilverLight camp ). Its an AS3 Object that allows you to add "elements" in the form of objects much like you would with XML using E4X. By assigning values to an XObject, you are adding that value into its "node" structure as one of its children with the given name. Retrieving a property, instead of returning a value, returns an instance of XObjectList which is essentially a list of objects (like XMLList) that are defined to that property. As with XML, there is a separation of elements and attributes using the @ character to precede references. Without @ you access a child, with, you are accessing a property or attribute of that particular XObject or whatever object defined inside it. Setting an attribute of an XObjectList, assigns the value to that property of all the objects in the list.

Its a little hard to explain. Its better to just see some examples.


ActionScript Code:
var rootNode:XObject = new XObject();rootNode.one = new Object();rootNode.two = new Array();rootNode.two = 20;rootNode.two[1].deep = "Hello XObject";rootNode.@three = "attribute";trace(rootNode);/* output:<XObject three="attribute">    <Object:one />    <Array:two />    <int:two>        20        <String:deep>            Hello XObject        </String:deep>    </int:two></XObject>*/



ActionScript Code:
var rootNode:XObject = new XObject();rootNode.a = 1;rootNode.a = 2;rootNode.a = 3;delete rootNode.a[1];trace(rootNode);/* output:<XObject>    <int:a>        1    </int:a>    <int:a>        3    </int:a></XObject>*/



ActionScript Code:
var myMcs:XObject = new XObject();myMcs.badGuys = enemy1_mc; // movie clips on the screen...myMcs.badGuys = enemy2_mc;myMcs.badGuys = enemy3_mc;myMcs.badGuys.@x = 100; // all enemy mc's move to x = 100  


It's pretty much done, but there might still be some problems, so if anyone finds any, just say so. I'm not sure how many more methods I might want to add in addition to what's there now (to match XML) though I think I want to keep it as simple as possible, so probably not much more, if any, than what's already there. To see what's there now, you'd just have to check out the classes - its not much.

Treating Objects Like Objects....
Hey, I need a primer on how objects should be worked with in actionscript. I'm trying to pass along objects between functions like variables, which isn't working at all. Do I need to make a prototype function for each part of the object I want to manipulate? Do I need a reference movie clip in the library for any of it to work at all?

Basically, I'm trying to make do dynamic movie clip creation (each individually with special parameters) which will basically make different sized squares, then reference them later, by id, and still be able to get those parameters out of the mc. Anyone know what I'm getting at? Yea, it's for a game.

Basically, I'm need to have movie clips with information attached, and I need to be able to dynamically create them.

I feel like I've advanced from actionscript n00b to merely inept. Some help plz.... thanks in advance

GF

Objects Affecting Other Objects
I'm using flash MX, and i'm wondering how to make a Circle affect another one when it grows...

for example...

Lets say I have 2 circles next to each other... When I rollover a circle... I want it to grow... and when I roll off it... I want it to go back to normal size...

However, I want the Circle right next to it to move up or down... so when the circle grows... it doesn't cover the other circle...

I'm all outta idea on how to make this work right... Actionscript confuses me... but whenever I see it explained in a tutorial... I understand it...

If someone can point me in the direction of a tutorial... or is really good at explaining how to do things... I would appreciate the help

thanks

- Mikey

Blurring Objects OVER Objects
Hi
Ive seen animations where people actually have BLURRED frames IN ANIMATION ontop of other pictures [or other animations].. WITHOUT getting the white borders that your burdened with from the BITMAPS.

is there any program that you can do this with?
I dont want a reply that simply says "PHOTOSHOP" id like to know HOW in the program you do this.. I know there is the "soften edges" tool built right into flash. But this tool vastly slows down the animation PLUS: you cant "soften edges" with the pencil tool..

Thanks
-Lindsay

Accessing Objects Within Objects
Hey there,

What I'm trying to do is somehow assign the same class to a large number of movieclips within another movieclip. The nested mcs are already on stage in the positions that they need to be in. I need to go through all of the 200+ nested mcs and apply the same actions to them.

In AS2.0, I would loop through and do something like this...


Code:
for(var i in someObject){
if(typeof someObject[i] == "movieclip"){
someObject[i] = new objectClass();
}
}

What's an equivalent way of going about this? Any ideas?

Pushing Objects With Objects
I was wondering, how would I go about utilizing the drag script to cause the object I am currently dragging to push other objects. I know it has to do something with boundary lines, but I'm not sure. If you know how, or know where I can learn how, please do not hesitate.

(This thread was re-created (and the old one was deleted), since I hate double posting.)

Using XML Objects As References To Other XML Objects
Hello,

I'm trying to modify XML nodes in a XML list by reference,
in AS3, but for some reason Flash seems to be copying the node
value to it.

I need to change the reference so as to mimic a C/C++ pointer like behaviour.

This works with most flash objects I have tested, but not with the XML object.

Here's some code:

The below works:

var nodeList:XMLList= xmlObject.children();
nodeList[0] = <change>test</change>

Tracing the xmlObject, the value in nodeList[0] appropriately changes in the xmlObject variable


But what I want to do is this:

var nodeList:XMLList= xmlObject.children();
var myXMLNode:XML = nodeList[0];

myXMLNode = <change>test</change>

Tracing xmlObject, there seems to be no change to the object, however, the change is applied to the local variable myXMLNode

This works with other objects in flash like TextField, but does not work with the XML object.
Is there any known workaround or am I doing something wrong?

Thanks in advance

PHPObject, Objects Within Objects?
Hi guys,

I've built a php site already, but would like to add a flash component to it using the already established (or maybe slightly altered) php classes. The problem I'm finding is when I try to initialize an object that has another object within it. Example:

PHP Code:



class Test0 {

 function Test0() {
  //code
 }

}

class Test1 {

 function Test1() {
  $this->obj= new Test0();
 }






Now, when I try to create the object using PHPObject in flash, it results in a Connection Failure error. Everything up to an equivalent "$this->obj= new Test0();" line in my classes works fine. So I know its this object within an object idea. It seems like its trying to connect to the Gatway.php file again once it hits the nested Object. Does anyone know if this is possible in PHPObject? Any suggestions about how to work around it?

Thanks.

Selecting Objects Behind Objects
hey, in my movie i have MC1 on the root timeline and MC2 loads on top of MC1 however, i am able to mouse over buttons behind MC2? how can i stop this happening?

Sound Objects - How-to Preload Multiple Sound Objects
Im basically making a site for a sound engineer friend of mine, and like Im trying to make a music interface for his site, thats able to preload tracks, and play & load those multiple mp3 tracks dynamically (mp3s are in the same folder). Or the setup could be like multiple sound objects that have their own progress bar etc for loading kinda like the will-musser example. Im up for any suggestions as the MM docs dont help in this area very much

A good example of this would be @t http://www.willmusser.com. I under-stand how-to create and use 1 sound object for example, but when i try and use 2 sound objects etc, for 1 dynamic textfield named "progress", heres the coding to call-upon a sound object, which is basically 1 mp3 thats getting loaded, and shows progress in percentage via that dyamic textfield. What Im wondering, is if anyone knows of the AS for the btns to load tracks ie: on (release), load mp3"blaghla.mp3" ? if anyone knows the coding to load mp3s, feel free to leave a reply ;p And any good ways of calling upon multiple sound objects at once seperate dynamic textifelds or progress bars for loading etc.


PHP Code:




sound_1 = new Sound();
sound_1.loadSound("http://themakers.com/sounds/atmospheres_1.mp3", true);
function checkLoad(){
    var percentLoaded = (sound_1.getBytesLoaded()/sound_1.getBytesTotal())*100;
    progress.text = Math.round(percentLoaded)
    message.text = "MEK - Far From Home";
    
}
checkProgress = setInterval(checkLoad, 1000);

Flash MX TabIndex Only Working With Text Fields, Movies And Buttons Not Working :(
hey, has anyone heard of this, is it a known bug, or am i doing something wrong?

im using the following code to tab index a page, with text fields, buttons and movies that i would like to highlight to the visitor.

arrTabIndex = new Array("butAddress", "movEmail", "txtCC", "txtTelephoneNumber", "txtMobileNumber", "txtSubject", "txtSubject", "txtRealName", "txtBody");

for (var Count = 0; Count < arrTabIndex.length; Count++) {
eval(arrTabIndex[Count]).tabIndex = Count;
//eval(arrTabIndex[Count]).tabEnabled = 1;
//eval(arrTabIndex[Count])._focusrect = 1;
}

my problem is, that if i include movie clips or buttons, the first in the series does focus and show the colored square but the tab key does not move the focus to the next object.
if i only include text fields, the tab key works as normal
is this a bug, or am i doing something wrong?

many thanks, in advance
clive

LoadMovie - Working In Debug Mode, Not Working Otherwise
Hello,

I have a main swf, which must load other 2 swfs (PHP data involved).
I made it work in debug mode, but in normal mode, a movie is not loading at all. What should I check to find the problem?
(the paths are OK)

I would be really thankfull if someone could help soon.

Thanks

Site Working Perfectly In A Server, Not Working In Other
Hi
I have a strange problem with a site I've done recently. It works perfectly in one server, but the same files don't work properly in some other server(both servers are Linux). The site loads correctly and all, and it runs fine for a while, but after you have clicked the buttons of the menu for 5 o 6 times the buttons doesn't load anything anymore. The rest of the movie runs fine, it's only the buttons that are supposed to load the sections (external swfs) that just do nothing.
See it for yourself:

Here the site works as it should:
http://www.avanzasoluciones.es/celeste

Here the buttons stop working after a while:
http://www.limpiezasceleste.com

I'll be glad to answer any question you may have regarding the coding of the site or anything that may lead to a solution.
Thanks for your time

Contact Form Not Working In IE But Working In Mozilla
got a problem that I just can't figure out.
I have a feedback that was working fine. Key word "was".
I added a frame in the form MC to include a Thank You screen. But then it stopped sending in IE, but works in Mozilla.
I tried taking the extra frame out but still doesn't work in IE anymore.

any suggestions?
button

Code:
on (release) {
form.loadVariables("email.php", "POST");
}
script on the php page

Code:
<?php
$sendTo = "alvin@diggy.com.au";
$subject = "Gisler contact";
$headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">
";
$headers .= "Reply-To: " . $_POST["email"] . "
";
$headers .= "Return-path: " . $_POST["email"];
$message = "Phone:" . $_POST["phone"] ."
Country: " . $_POST["country"] ."
Message: ".$_POST["message"]." ";
mail($sendTo, $subject, $message, $headers);
?>

Fading Text Only Half-working (so It's Not Working At All)
Here's one for ya...I'm making some fading text. I made a movie clip of the text and did the alpha tweening and all that, and when I play the clip on-stage, it works perfectily. However, when I run a movie test, the text does not fade in but rather just suddenly appears. This is also the condition when the graphic is loaded onto a webpage. Has anyone else seen this happen before and can tell me why this is happening? Thanks.

Full Screen Tiling Working, But Not Working Right?
am using bitmapdata to make me a nice lil' background image, and it works great...until it's resized. Whats happening is it's creating a new bgHolder clip on the resize, NOT resizing the current empty clip "bgHolder"

Here's the code(taken from various posts)


import flash.display.BitmapData;
#include "mc_tween2.as"
Stage.align = "TL";
Stage.scaleMode = "noScale";
var myListener:Object = new Object();
myListener.onResize = function() {
createBG();
};
Stage.addListener(myListener);
var bgHolder:MovieClip = _root.createEmptyMovieClip("bgHolder", _root.getNextHighestDepth());
var BG_LINKAGE:String = "bg";
function createBG():Void {
var tile:BitmapData = BitmapData.loadBitmap(BG_LINKAGE);
with (bgHolder) {
beginBitmapFill(tile);
moveTo(0,0);
lineTo(Stage.width,0);
lineTo(Stage.width,Stage.height);
lineTo(0,Stage.height);
lineTo(0,0);
endFill();
}
}
createBG();

Objects That "snap To" Other Objects
Hey y'all,

Anyone know of the best way to script a symbol to "snap to" another symbol, within the published swf? (similar to the way you can set objects to snap to the grid in the Flash UI)

It's for a puzzle game.

Thx

Flash Objects Calling Other Flash Objects?
Hello everyone,

I have an issue with my flashplayer object being hosted on another server. The flashplayer is viewed from the home page of many websites. The backstory is that I have problems sending certain variables/events to the player when it is not local, and everything works fine when the player is hosted locally. My concern is that hosting the player locally will result in exceeding the bandwidth cap.

So the question is, is there a way to have a local flash object (player) call a non-local flash object with javascript commands and variables? Thanks.

I apologize if this is not the appropriate forum for this question.

Working Locally - Not Working Online
Having a nightmare with this.

On my project I have made use of both named anchors and frame labels for the navigation - both of which work fine when testing locally, in all browsers.

Problem is, soon as I upload, the frame labels stop working in FireFox, and they only working on 2nd load in IE. Im publishing Player 6, using AS2. The named anchors work great, across the board.

Any ideas?

AS 2 Button Not Working Not Working Properly
I've got a problem with a button dynamically attached to an mc within an as 2 class script. This is the button code:


ActionScript Code:
this.mc.butt.onRelease = function(){          
            current=true;
            this._parent.checkFocus();
        }

this code is inside the class constructor while current is declared at the start of the class and set to false previously in the constructor. The mc is the movieclip attached to the class and butt is the button attached to that. checkFocus is called ok but i'm confused how cos the "this._parent" should reference the "mc" movieclip but this has not got a checkFocus method on it. If i use "this._parent._parent" however, which should be correct, it does not work. I don't know what's up there. Anyway, checkFocus is here:

ActionScript Code:
public function  checkFocus(){
       
        for(var mcname:String in _root){
           
            if(_root[mcname] instanceof Layer){
               
                if(_root[mcname].focus==true){
                    //_root[mcname].gainFocus(20);
                    _root[mcname].loseFocus(20);
                } else {
                   
                    if(_root[mcname].current==true){
                        trace("waaahhhhh");
                        _root[mcname].gainFocus(20);
                    }      
                }
            }   
        }
    }


the aim of this code is to unfocus the Layer object (this is the name of the class) currently in focus, denoted by its focus attribute being true, and focus the new Layer object that has been clicked on - denoted by its current attribute being true. The currently focused layer is unfocused ok, but the new layer is not focused because, it seems, the change in the current attribute has not happened - there is no waaaaaahhhh coming up! I think this is because i am not reference it properly from within the button event. How can i reference properly from within the button? I've tried using _target and targetPath() but i'm not getting anywhere. I'm pretty sure this is the problem cos things work fine when i declare button events from outside the class, inside the fla. But i'd much rather do things dynamically within the calss if possible. Anyone got any ideas? I've been staring tooooo long at this.

Rollover Working But Rollout Not Working?
i have attached my small fla...

basically i have 5 buttons, each with a rollover and a rollout statement.

when the buttons are rolled over, they tween in scale.

when the buttons are rolled out they are supposed to tween return to normal scale - but for some reason they do not tween, they just pop straigh back into normal size....

any ideas???

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