PDA

View Full Version : [AS2] issue with fscommand


indexSH
10-28-2011, 01:27 PM
Hello,

i am new to this forum and i need desperately a little help with fscommand.
I am building a small swf in Flash CS5(AS2) which consists of a dock menu
(template script from the web) and what it actually does is when you click on
an image, it opens a webpage(via getURL method :P)
What i wanto to mod is instead of getURL, to fscommand("exec", "folder.exe");
so when you click on an image from the Dock, to execute the "folder.exe" which opens a directory.

I am pasting the code. There is also code for the visuals etc, so scroll a bit down.The area where i think i should put the fscommand is

MovieClip.prototype.onClick = function(i) {
this.onPress = function() {
getURL(urls[i], tg[i]); //here i put the fscommand

loadXML = function (success) {
if (success) {
var photos:Array = this.firstChild.childNodes;
total = photos.length-1;
createEmptyMovieClip("thumbs", 4);
for (var i=0;i<=total;i++) {
images.push((_root.folderPath?_root.folderPath:"") + photos[i].attributes.image);
urls.push(photos[i].attributes.url);
info.push(photos[i].attributes.info);
tg.push(photos[i].attributes.target);
thumb = thumbs.createEmptyMovieClip("th"+i, i);
pr = thumb.attachMovie("preload","pr", 1);
pr._x = 3/2*minThumbW; pr._y = 3/2*minThumbH;
holder = thumb.createEmptyMovieClip("holder", 2);
loadBitmapSmoothed(images[i],holder);
r = thumb.attachMovie("item","r", 3);
r._visible = false;
if (useMirror==2) {
if(loadSmoothed) loadBitmapSmoothed(images[i],r.ref.inner);
else r.ref.inner.loadMovie(images[i]);
r._y = 2*thumb._height-1+mirrorDistance;
r._yscale=-100;
}
thumb.onClick(i);
var trans:Transform = new Transform(thumb);
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset= outColor;
trans.colorTransform = colorTrans;
Dock.push(thumb);
thumbs._y = DockYpos;
thumbs._x = DockXpos;
thumb._width = minThumbW;
if (useMirror == 2) thumb._height = 3/2*minThumbH;
else thumb._height = minThumbH;
thumb.holder.onEnterFrame = function () {
if (this.isLoaded) {
if (useMirror == 2) this._parent.r._visible = true;
this._parent.pr._visible = false;
delete this.onEnterFrame;
}
}
}
if (verticalMenu)
onEnterFrame = function () {
mouseOverDock = ((_ymouse >10) && (_ymouse<dockHeight-10) && (_xmouse>10) && (_xmouse<dockWidth-10));
if (thumbs._height > dockHeight) {
if (mouseOverDock) xpos = (dockHeight - thumbs._height-maxThumbH-spacing)*_ymouse/dockHeight;
if ((thumbs._y > xpos) && (Math.abs(thumbs._y - xpos)>(scrollSpeed+5))) thumbs._y -=scrollSpeed;
else if ((thumbs._y < xpos) && (Math.abs(thumbs._y - xpos)>(scrollSpeed+5))) thumbs._y += scrollSpeed;
else thumbs._y = xpos;
dist = maxThumbH/2;
}
else { dist = dockHeight/2 - thumbs._height/2+spacing/2; thumbs._y = 0;}
for (i=0;i<Dock.length;i++) {
H = Dock[i]._height;
W = Dock[i]._width;
if (thumbs._height > dockHeight)
rap = (influence-Math.abs(((thumbs._height+maxThumbH+spacing)/dockHeight)*_ymouse-Dock[i]._y-Dock[i]._height/2))/influence;
else rap = (influence-Math.abs(_ymouse-(Dock[i]._y+Dock[i]._height/2)))/influence;
Dock[i]._width = Math.max(W-((W-minThumbW)/fade), W-((W-(rap*mouseOverDock*maxThumbW))/snap));
Dock[i]._height = Math.max(H-((H-useMirror*minThumbH)/fade), H-((H-(useMirror*rap*mouseOverDock*maxThumbH))/snap));
Dock[i]._x = (maxThumbH-Dock[i]._height)/bigThumbDirection;
Dock[i]._y = dist;
dist += Dock[i]._height+spacing;
}
}
else
onEnterFrame = function () {
mouseOverDock = ((_ymouse >10) && (_ymouse<dockHeight-10) && (_xmouse>10) && (_xmouse<dockWidth-10));
if (thumbs._width > dockWidth) {
if (mouseOverDock) xpos = (dockWidth - thumbs._width-maxThumbW-spacing)*_xmouse/dockWidth;
if ((thumbs._x > xpos) && (Math.abs(thumbs._x - xpos)>(scrollSpeed+5))) thumbs._x -=scrollSpeed;
else if ((thumbs._x < xpos) && (Math.abs(thumbs._x - xpos)>(scrollSpeed+5))) thumbs._x += scrollSpeed;
else thumbs._x = xpos;
dist = maxThumbW/2;
}
else { dist = dockWidth/2 - thumbs._width/2+spacing/2; thumbs._x = 0;xpos=0;}
for (i=0;i<Dock.length;i++) {
H = Dock[i]._height;
W = Dock[i]._width;
if (thumbs._width > dockWidth)
rap = (influence-Math.abs(((thumbs._width+maxThumbW+spacing)/dockWidth)*_xmouse-Dock[i]._x-Dock[i]._width/2))/influence;
else rap = (influence-Math.abs(_xmouse-(Dock[i]._x+Dock[i]._width/2)))/influence;
Dock[i]._width = Math.max(W-((W-minThumbW)/fade), W-((W-(rap*mouseOverDock*maxThumbW))/snap));
Dock[i]._height = Math.max(H-((H-useMirror*minThumbH)/fade), H-((H-(useMirror*rap*mouseOverDock*maxThumbH))/snap));
Dock[i]._y = (maxThumbH-Dock[i]._height)/bigThumbDirection;
Dock[i]._x = dist;
dist += Dock[i]._width+spacing;
}
}
}
}
xml.onLoad = loadXML;
xml.load((_root.folderPath?_root.folderPath:"") + "images.xml" );

MovieClip.prototype.onClick = function(i) {
this.onPress = function() {
getURL(urls[i], tg[i]);

}
this.onRollOver = function() {
if (showDescription) {
if(verticalMenu) {
descript = attachMovie("description", "descript", 8888);
descript._y = Dock[i]._y + xpos+minThumbH/2;
descript.onEnterFrame = function() {
descript._y = Dock[i]._y + xpos+maxThumbH/2;
}
descript._y = descriptionY;
descript._x = descriptionX;
descript.desc_inner.desc.text = info[i];
}
else {
descript = attachMovie("description", "descript", 8888);
descript._x = Dock[i]._x + xpos+minThumbW/2;
descript.onEnterFrame = function() {
descript._x = Dock[i]._x + xpos+maxThumbW/2;
}
descript._y = descriptionY;
descript._x = descriptionX;
descript.desc_inner.desc.text = info[i];
}
}
var trans:Transform = new Transform(this.holder);
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset=0;
this.onEnterFrame = function () {
if (colorTrans.blueOffset < iC) {
colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset+=color ingSpeed;
trans.colorTransform = colorTrans;
}
}
this.onRollOut = function() {
if (showDescription) {
removeMovieClip("descript");
}
var trans:Transform = new Transform(this.holder);
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset= iC;
this.onEnterFrame = function () {
if (colorTrans.blueOffset > 0) {
colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset -= coloringSpeed;
trans.colorTransform = colorTrans;
}
}
}
}
}

function loadBitmapSmoothed(url:String, target:MovieClip) {
var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
var listener:Object = new Object();
listener.tmc = target;
target.isLoaded = false;
listener.onLoadInit = function(mc:MovieClip) {
target.isLoaded = true;
if(loadSmoothed) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
bitmap.draw(mc);
}
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}


PLeasem anyone that has time to read it would help me a lot! Thank you for your time!!!

xxneon
10-28-2011, 01:32 PM
are you publishing this as a flash projector? also is folder.exe inside a sub directory called fscommand?

indexSH
10-28-2011, 01:44 PM
are you publishing this as a flash projector? also is folder.exe inside a sub directory called fscommand?

I am publishing it as a .swf file and yes it it placed in the sub-folder fscommand.

indexSH
10-28-2011, 01:52 PM
OK OK OK OK 100000 sorries for that!!!!

it has to be flash projector in order to work with fscommand!!!

I was using only the swf buit the problem is that i am using SFW studio after the publishing in order to make some mods with the right-click and some other
user interface mods-restrictions......

indexSH
10-28-2011, 02:01 PM
here's the big issue: There are 10 menu items(10photos)
I want to execute a specific file when i click to a specific image
e.g.: if i am clicking image3, i want to execute the folder3.exe(which is in fscommand subfolder, along with the rest folder1...to folder10.exe) so each time a different folder opens.

or is another way, eg to import an xml with the paths that i wanna open
and then somehow open the specific path accordin to what image i am clicking.

I have done something similar in this code attached but that only opens a website from the images.xml(via getURL) i think things are a bit more complicated when trying to open directrories with windows explorer....

sorry if i am asking crazy things :)

xxneon
10-28-2011, 02:14 PM
if your making a projector with swf studio.. can't you do this with swf studios added features..

I just did a quick search and it says that swf studio can open files.

http://www.northcode.com/v3/help/index.html?page=ssCore_Shell_execute.html

northcode
10-28-2011, 02:40 PM
You can do it even easier if you use ssCore.FileSys.explore (http://www.northcode.com/v3/help/index.html?page=ssCore_FileSys_explore.html). That command opens a folder in Explorer (not IE, just Windows Explorer).

So something like this...


// your variable is probably called something else
var imageNumber = 1;

// construct a fully qualified path to the folder
var folderPath = ssGlobals.ssStartDir + "\\folder" + imageNumber;

// open it!
ssCore.FileSys.explore({path:folderPath});


the ssGlobals.ssStartDir will be the same as the path to where your EXE is started from. This lets you create absolute paths without knowing where you will be run from. As long as the folders you want to open are in the same location as your EXE.

If you need more help we can talk here or at http://www.northcode.com/forums.

indexSH
10-28-2011, 09:16 PM
I really appreciate your rapid responses! Thank you!

So, i found a solution. I just wrote a simple function that checks which image
is clicked and it fscommands the appropriate exe.

The problem is that when i compile to the SWF Studio ( :D ), making it
an unbundled + flash application that runs from the auto-extract directory beacuse it is based on media files etc etc etc it makes a silly bug!

Every action is carried out twice. For example, when i click on every item, it opens 2 instances of the webpage and executes twice the fscommand so it opens twice the directories i specified. This does not happen when i run just the flash projector(but it has the title bar and the write click that i do not want at all)

So......any idea of thice dual operation that happens?(anyone that works with SFW Studio)? or else i am going to try the solution you mentioned before, with the ssClasses code from Northcode.

Really really thank you again!!!

northcode
10-29-2011, 01:33 AM
There's a FAQ for that :)

Why doesy my button event fire twice in SWF Studio? (http://www.northcode.com/blog.php/2010/01/09/Why-does-my-button-event-fire-twice-in-SWF-Studio)

indexSH
10-29-2011, 07:46 AM
Good morning and than you again Northcode! :)