PDA

View Full Version : loadMovie Questions


ydragon
12-14-2004, 07:20 PM
Hi all,

I'm beginning an architechural design tool in Flash MX. I am experimenting with some of my concepts at this point. I had hoped to be able to load an swf that contains movie clips of vector graphics (walls, doors, and other architectural elements) in the library but not on the stage. the only thing on the stage is at layer 1, frame 1 the following action script (example):

//************* begin snippet
_global.PL_WallDoor_objarr = new Array();
PL_WallDoor_objarr[0]="object_singledoor";
PL_WallDoor_objarr[1]="object_slidingdoor";
PL_WallDoor_objarr[2]="object_plainwall";
PL_WallDoor_objarr[3]="object_doubledoor";
PL_WallDoor_objarr[4]="object_doorway";
PL_WallDoor_objarr[5]="object_curvedwall";
PL_WallDoor_objarr[5]="object_angledwall";
// ************* end snippet

...

where each is the name of a movie clip in the .swf's library

The main movie loads the .swf as follows:

//************* begin snippet
_level0.createEmptyMovieClip("objClip", 0);
_level0.objClip.loadMovie("http://www.obscuredforthispost.com/PLobj.swf");
// ************* end snippet

(I changed the URL above)

The main movie has a group of buttons that when clicked will use the variable info to prefill a tool bar with the movie clips that when selected in the tool bar create unique instances of the clip in a scrollpane where they can be positioned... (the following code is a first draft, and likely wrong)

//************* begin snippet
on (press) {
toolType="Walls & Doors";
_level0.Tools.refresh();

// Do Tools fill

var looplimit;
var x_current = 53;
var y_current = 100;
var x_offset = 50;
var y_offset = 50;

_global.scrollContent = _level0.DesignGridScrollPane.getScrollContent();

trace("The length is:"+_level0.objClip.PL_WallDoor_objarr.length);
trace("or...The length is:"+_global.PL_WallDoor_objarr.length);
trace("or...:"+_global.PL_WallDoor_objarr[2]);

_global.PL_WallDoor_objarr
if(PL_WallDoor_objarr.length >10){
looplimit = 10;
}else{
looplimit=_level0.PL_WallDoor_objarr.length;
}

for(i=0; i<looplimit; i++) {
// create a new tool object in the Tools clip
_global.NewTool[_level0.PL_WallDoor_objarr[i]]=_level0.Tools.attachMovie(_level0.PL_WallDoor_obj arr[i], _level0.PL_WallDoor_objarr[i], 1);
// position the new object in the Tools clip

NewToolSize = NewTool[_level0.PL_WallDoor_objarr[i]].getSize;

if(i%2 == 0){
// subtract x offset and add y offset
x_current = x_current - x_offset;
y_current = y_current + y_offset;

x_temp = x_current - ((50 - NewToolSize.width)/2);
y_temp = y_current - ((50 - NewToolSize.height)/2);
}else{
// add x offset
x_current = x_current + x_offset;

x_temp = x_current - ((50 - NewToolSize.width)/2);
y_temp = y_current - ((50 - NewToolSize.height)/2);
}
NewTool[_level0.PL_WallDoor_objarr[i]]._x = x_temp;
NewTool[_level0.PL_WallDoor_objarr[i]]._y = y_temp;

// now define the actions for this new object when it is clicked
// ************************************************** *****************************
Mouse.addListener(NewTool[_level0.PL_WallDoor_objarr[i]]);
NewTool[_level0.PL_WallDoor_objarr[i]].onMouseDown=function(){
if(NewTool[_level0.PL_WallDoor_objarr[i]].hitTest(_root._xmouse, _root._ymouse, false) == true) {

// set the number of instances for this object
_global.NewObjInstance[_level0.PL_WallDoor_objarr[i]] = NewObjInstance[_level0.PL_WallDoor_objarr[i]] + 1;

_global.NewObj[_level0.PL_WallDoor_objarr[i]]=scrollContent.attachMovie(_level0.PL_WallDoor_obj arr[i], _level0.PL_WallDoor_objarr[i]+"_"+NewObjInstance[_level0.PL_WallDoor_objarr[i]], 1);

// center the object in the center of the visiblr scroll pane
NewObj[_level0.PL_WallDoor_objarr[i]]._x = 300;
NewObj[_level0.PL_WallDoor_objarr[i]]._y = 200;

_level0.DesignGridScrollPane.refreshPane();

Mouse.addListener(NewObj[_level0.PL_WallDoor_objarr[i]]);
NewObj[_level0.PL_WallDoor_objarr[i]].onMouseDown=function(){
if(NewObj[_level0.PL_WallDoor_objarr[i]].hitTest(_root._xmouse, _root._ymouse, false) == true) {
startDrag(NewObj[_level0.PL_WallDoor_objarr[i]],true,0,0,765,578);
_level0.DesignGridScrollPane.refreshPane();
}
}
NewObj[_level0.PL_WallDoor_objarr[i]].onMouseUp=function(){
NewObj[_level0.PL_WallDoor_objarr[i]].stopDrag();
if (_level0.DesignGrid.hitTest(_root._xmouse, _root._ymouse, false) == true) {
}
}
// end press for this object
} }
// ************************************************** *****************************
// end for loop
}
// end press for overall fill
}
// ****************** end snippet

The whole point is that by putting the objects and data in an .swf on-line, I can then update it and allow anyone with the Flash software and internet access to have the updated set of objects.

Here are my questions:

1) As you can see from the three trace attempts in the final snippet I cannot get the values of the global PL_WallDoor_objarr... When I run the debugger I can see that that values are under _global...but i cannot figure out how to access them...The .swf is really small, and I have tried waiting for it to load then pressing the button... However it is obvious that it is loading as I can see the global values in the debugger.

2) When researching Flash MX's capabilities I read one reference that seemed to indicate I may not be able to use atachMovie with the movie clips in the loaded .swf...is this true?

I did look through the posts for any solutions, but found none.

I know this may be a bit complex for some, but hopefully there are others that have tried to make complete applications with Flash. I wanted to experiment with Flash as an alternative to my developing this in Java, or C++...

I am gratefull for any assistance.

Be well,

JZ