Using JavaScript API commands in ActionScript file - flash-cs5

I am new to actionscript and jsfl programming. I am using Adobe Flash Professional CS5.5 and windows 7 operating system. I am trying to execute Javascript API commands in my .as file using the MMExecute() function. When publishing the swf file the statements before and after the 'MMExecute' statement are getting executed but the Javascript command string I am using in the MMExecute function doesn't seem to get executed. I am using a basic JSFL command to just trace to the output window in flash. Also, I am publishing the swf file to the WindowsSwf folder present in the Configuration folder. The fla file I have is a blank file with nothing added to it and the code I am using is as follows.
import flash.display.*;
import flash.text.*;
import flash.external.*;
import adobe.utils.MMExecute;
var str:String=new String();
str='fl.trace("Working..");';
MMExecute(str);
Please help me out.
Thanks in advance.

I'm not a real JS programmer, just an artist who got into JSFL, but:
var str:String=new String();
seems odd to me. I don't typically declare var types in JSFL.
(no idea if that's common or I'm just sloppy.)
I would typically just write
var str='fl.trace("Working..");';
it is also possible you may need to escape the first semicolon.

Related

JODIT WYSIWYG editor 3.24.1 - how to call a function and get source filename after a base64 encoded image has been inserted

I've got images inserting into the editor as base64 encoded images (uploader option insertImageAsBase64URI is set to true). However, I'd like to call a function after the image has been inserted and also read the source filename for the inserted image.
I'm new to the JODIT editor, it seems great so far, but I need to tweak it a bit and am not sure how to register an event callback for this, or if there is another/better way. Any help is appreciated!
I think the best solution is to fork JODIT in github and edit the code. For some reason, however, I have been unable to build the code on my mac laptop for at least a couple of reasons (missing file in node module, fixed, and a build error "TypeError: require(...) is not a function" that may indicate circular dependencies in node modules?). Anyway, I found a complete and limited "HACK" for my needs and that is to actually capture the filename when the file is added by attaching an "onchange" handler function to the JODIT instance's file input element. This works roughly as follows (I'm using jQuery):
var selectedFile = null;
function setSelectedFile(){
$('.jodit').find('input[type="file"]').removeProp('multiple');
$('.jodit').find('input[type="file"]').on('change', function(){
var files = $(this).prop('files');
selectedFile = files[0].name;
});
});
$('.jodit').find('button[aria-label="Insert file"]').on('click',
function(){
setSelectedFile();
}
);
I run something like this after the page has loaded. This works only for the "change" event (where you select a file directly) and I could not figure out how to read the filename after a file is "dropped". Dropping a file does not seem to trigger the "change" event in the file input element. If anyone knows how to get the filename of a dropped file for the JODIT editor I'd appreciate sharing. I will update this if I get around to fixing that.

How to copy files as templates, injecting values to them, to a different folder?

I used this library, mem-fs-editor (https://github.com/sboudrias/mem-fs-editor), in a Yeoman generator a few weeks ago. It worked nicely, but now I tried to use it again in a different scope and I couldn't do anything. Obs: I used it because this is the library Yeoman provides to handle the file system.
In Yeoman Generators we can copy files from a template folder, passing values to inject in the code, to a different folder. And that's precisely what I need, but I can't use Yeoman this time.
I tried the same code I used in my Yo Generator, but it don't work. So I'm not sure how mem-fs works. No errors are thrown and even the code provided by the author of the project don't work to me.
I tried this (and some other things with copyTpl) with no success
var memFs = require('mem-fs');
var editor = require('mem-fs-editor');
var store = memFs.create();
var fs = editor.create(store);
console.log(fs.write('./somefile.js', 'var a = 1;'));
Anyone knows how it works or what else I can do to make this happen?
mem-fs-editor author here.
mem-fs stands for memory file-system. All the files you creates are stored in memory and won't get written to disk until you call:
editor.commit(callback);
Yeoman does that automatically for you. It is this way with Yeoman to collide every file changes together and then being able to only prompt for file conflicts once (rather than everytime a single file is being written to).

Can you read the length of an mp3 file in python 3 on windows 10?

I am currently creating a music player in python 3.3 and I have a way of opening the mp3/wav files, namely through using through 'os.startfile()', but, this way of running the files means that if I run more than one, the second cancels the first, and the third cancels the second, and so on and so forth, so I only end up running the last file. So, basically, I would like a way of reading the mp3 file length so that I can use 'time.sleep(SongLength)' between the start of each file.
Thanks in advance.
EDIT:
I forgot to mention, but I would prefer to do this using only pre-installed libraries, as i am hoping to publish this online as a part of a (much) larger program
i've managed to do this Using an external module, as after ages of trying to do it without any, i gave up and used tinytag, as it is easy to install and use.
Nothing you can do without external libraries, as far as I know. Try using pymad.
Use it like this:
import mad
SongFile = mad.MadFile("something.mp3")
SongLength = SongFile.total_time()

ChromeWorker File Not including in the extension package

Hi I am building a Mozilla Extension through CFX tool. I have used ChromeWorker in it. It is working fine while i am running : cfx run command. But while building up a package using cfx xpi the Chrome Worker file is not included in the xpi package.
I am using this to create the worker thread.
var tworker = new ChromeWorker("chrome://addons/content/t_worker.js");
my t_worker.js file is present in addons/lib
I have also put one chrome.manifest file in the package that contains :
content addons ./resources/addons/lib/
Please tell the possible reason for this problem and also how to fix it .
Try moving your file into the data folder then do:
const self = require('sdk/self');
var tworker = new ChromeWorker(self.data.url('t_worker.js')
im totally not sure of this syntax, i just typed off top of my head
I putted that worker file in the lib thats why its not working. I just changed the location of my file to data folder and made changes in my chrome.manifest file : content addons ./resources/addons/data(previously it was lib)/ . Its working fine Thanks to #Noitidart for the suggestion of putting it in data folder

Windows mobile 6.5 - best way to read and write from and to a config file

I have a handheld device running WM6.5 and trying to put together an application that should prompt the user for some information (login, password) and save it to a file for later use.
Have tried app.config files but unfortunately it requires System::Configuration, I can add the DLL but can't get the code to run, it requires CRL or something like that which I can't configure this being a mobile app - the required option is missing from the project/solution configuration section.
I am using Visual Studio 2008 C++
What's the best way to make this happen? Precisely, 1) write a string somewhere and 2) read it back later on.
TIA
Later edit:
I have tried using a binary file, like this
// write to config file
std::string s="helloworldhelloworldhelloworld";
ofstream ofile("test.txt",ios::binary);
ofile.write((char*)s.c_str(),strlen(s.c_str()));
ofile.close();
And then I have tried reading it back like this
// read config file
char read_str[60];
ifstream inf("test.txt",ios::binary);
inf.read(read_str,60);
inf.close();
LPCTSTR application_settings = CA2W(read_str);
What happens is it adds some garbage at the end of the string, if the string is longer less garbage, otherwise more.
Is there a way to sort out this conversion issue?
Turns out, project was using Unicode and had to use wifstream and wofstream to be able to properly read the strings, rather than attempt to convert them from ANSI to unicode.
This should be a reminder for me to stay away from strong typed languages in the future. Too bad there's no other significant choice for Windows Mobile. Spent a bunch of hours on this, I could have used that time for something else.

Resources