Here I have AS3 to for uploading recorded sound file to server. When I test it in Flash it works properly (record sound and upload it and goes to next frame) , but in browser it doesn't work. It seems can't call myUpload but I don't why? Is it should be mouse event? Thanks.
function VOCWordToYourMp3()
{
setTimeout(startRecording,3000);
recorder.addEventListener(RecordingEvent.RECORDING, onRecording);
recorder.addEventListener(Event.COMPLETE, onRecordComplete);
}
function startRecording()
{
if (! recording)
{
recorder.record();
}
else if (recording)
{
recorder.stop();
recording = false;
}
}
function onRecording(e:RecordingEvent)
{
//
}
function onRecordComplete(e:Event):void
{
//
}
function renderWav(src, convertToMp3 = false)
{
//
function handleRenderTimer(e:TimerEvent)
{
//
}
function finishRender()
{
//
}
}
function makeIntoMp3(wav)
{
wav.position = 0;
mp3Encoder = new ShineMP3Encoder(wav);
mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);
mp3Encoder.addEventListener(ProgressEvent.PROGRESS, mp3EncodeProgress);
mp3Encoder.start();
function mp3EncodeProgress(e:ProgressEvent):void
{
//
}
function mp3EncodeComplete(e: Event):void
{
myUpload('sound1',mp3Encoder.mp3Data);
}
}
function myUpload(namefile:String,sba: ByteArray):void
{
//upload code
}
Update:
In Flash Player 10 and Actionscript 3.0, all the calls to URLLoader must be in the same callstack.
http://helpx.adobe.com/flash-player/kb/user-interaction-required-upload-download.html
What is same callstack mean?
I recommend using something like Vizzy: https://code.google.com/p/flash-tracer/ to debug your swf in the browser. You can put trace statements into the onRecordComplete() and myUpload() functions, etc, to see how far the code is getting, and to see if you are getting any new errors. You may have some kind of security sandbox error because you are running in the browser. Being able to see what that error is will help you figure out what to do next.
To use Vizzy, you need to have the debug player running in your browser, and to configure the right path to your log file. This is sometimes a little bit tricky, so I'll give you some tips:
Add a file to your home directory called mm.cfg, and populate it with these settings:
ErrorReportingEnable=1
AS3Verbose=0
TraceOutputFileEnable=1
AS3Trace=0
TraceOutputBuffered=0
AS3StaticProfile=0
Then in Vizzy you have to set up the path to the log. On my windows 7 machine it is here:
C:\Users\MyUserName\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt
It may be different depending on your operating system.
Good luck, and report back if you Vizzy gives you any new information.
Related
I have an interactive flash application Actionscript 3 to be deployed in Android device (thru Adobe Air). There will be a Save button (btnSave) that will save current progress of a user eventhough he closes the app or another will use it. There's also a Load button (btnLoad) to load the progress of the user. This is my code and I can't make it work. Thanks!
var mySharedObject:SharedObject = SharedObject.getLocal(“save”);
btnSave.addEventListener(MouseEvent.CLICK, saveCurrentFrame);
function saveCurrentFrame(event:MouseEvent):void
{
mySharedObject.data.lastframe= this.currentFrame;
mySharedObject.flush();
}
btnLoad.addEventListener(MouseEvent.CLICK, getLastFrame);
function getLastFrame():int
{
return mySharedObject.data.lastframe;
}
You need not only to read the saved last frame, but to move the playhead to it as well.
var mySharedObject:SharedObject = SharedObject.getLocal("save");
btnSave.addEventListener(MouseEvent.CLICK, saveCurrentFrame);
btnLoad.addEventListener(MouseEvent.CLICK, getLastFrame);
function saveCurrentFrame(event:MouseEvent):void
{
mySharedObject.data.lastframe = currentFrame;
mySharedObject.flush();
}
function getLastFrame(event:MouseEvent):void
{
if (mySharedObject.data.lastframe != null)
{
gotoAndStop(mySharedObject.data.lastframe);
}
}
So i been trying to create to create a flash video gallery for my website but im getting an error on it even though the code should be correct
Below is the code i came up with
stop();
one.add Eventlistener(MouseEvent.CLICK,vid1);
two.add Eventlistener(MouseEvent.CLICK,vid2);
three.add Eventlistener(MouseEvent.CLICK,vid3);
four.add Eventlistener(MouseEvent.CLICK,vid4);
five.add Eventlistener(MouseEvent.CLICK,vid5);
function vid1(event:MouseEvent):void
{
vidPlayer.source ="flv/01.flv"
}
function vid2(event:MouseEvent):void
{
vidPlayer.source ="flv/02.flv"
}
function vid3(event:MouseEvent):void
{
vidPlayer.source ="flv/03.flv"
}
`enter code here`function vid4(event:MouseEvent):void
{
vidPlayer.source ="flv/04.flv"
}
function vid5(event:MouseEvent):void
{
vidPlayer.source ="flv/05.flv"
}
vidPlayer.playButton = player
vidPlayer.pauseButton = pauser
Does anyone have any idea on whats wrong with it ?
addEventlistener is a function, which will register an event listener object, and the name of a function should never contain spaces which is your error, so you should write :
one.addEventlistener(MouseEvent.CLICK,vid1);
two.addEventlistener(MouseEvent.CLICK,vid2);
three.addEventlistener(MouseEvent.CLICK,vid3);
four.addEventlistener(MouseEvent.CLICK,vid4);
five.addEventlistener(MouseEvent.CLICK,vid5);
Hope that can help.
I've tried searching stackoverflow to find an answer to this question but so far haven't found anything.
I have a swf file with several movie clips on the stage. When I've managed to create an event where the movie clips swap out to a new movie clip when the user hovers. The problem that I am having is when you click that new movie clip it's supposed to open a URL in a browser window. That happens when I test the movie within Flash CC but when I test it in a browser nothing happens.
Any help for this would be greatly appreciated. I apologize if this question has been asked elsewhere on the site but, as I said, I did a search earlier and didn't find anything.
import flash.events.MouseEvent;
addEventListener(MouseEvent.MOUSE_OUT, gobackAnimation);
function gobackAnimation(event:MouseEvent):void
{
MovieClip(parent).gotoAndStop(1)
}
addEventListener(MouseEvent.CLICK, openURL);
function openURL(event:MouseEvent):void
{
ExternalInterface.call("open", "URL I'm trying to open");
MovieClip(parent).gotoAndStop(1)
}
To open a URL you have to use the navigateToURL function as documented here.
It appears that you are using the following code to trigger a URL to open:
function openURL(event:MouseEvent):void
{
ExternalInterface.call("open", "URL I'm trying to open");
MovieClip(parent).gotoAndStop(1)
}
However, I don't know where or what this ExternalInterface is and how the call function is built.
If you want to open a URL though, you should be doing something along the following lines:
function openURL(event:MouseEvent):void
{
var myURL:String = "http://your.url.goes/here"; // set your url here
var window:String = "_blank"; // you can set this to be whatever you need based on how you want the window opened
var request:URLRequest = new URLRequest(myURL);
request.data = variables;
try {
navigateToURL(request,window);
}
catch (e:Error) {
// handle error here
}
MovieClip(parent).gotoAndStop(1)
}
I have created a swf project with flex and i have some checkboxes on it and whenever the checkbox seleced it will call the checkbox handler:
function checkBoxHandler() {
//call resultHandling
var obj:myObjectType = new myObjectType();
resultHandling(obj)
}
function resultHandling(myObject:myObjectType) {
//implementation code to send a request to server side
}
is it possible to make the "resultHandling(...)" to be a synchronized function? So there will be a que whenever we make a call to that function especially when there are multiple function calls
As Flex is Flash the limitations to Flash apply to Flex too. One of these is (Actually in newer Flash versions this no longer is 100% valid) that Flash has only one thread. This thread does everything from updating/drawing the ui, processing the application logic, handling IO, etc. Therefore a synchronous call would be a blocking call and in Client-Server communication this block can be quite long. Therefore Flash doesn't support blocking calls to a server and you won't be able to find a solution for this ... unfortunately.
But be assured, actually you will start creating more robust applications this way. I have noticed creating more and more asynchronous solutions even in places I could use synchronous calls :-)
you can create an arraycollection and store all your myObjectType objects in it. Then do something like-
var arr:ArrayCollection = new ArrayCollection();
function checkBoxHandler() {
//call resultHandling
var obj:myObjectType = new myObjectType();
arr.addItem(obj);
}
function resultHandling(myObject:myObjectType) {
//implementation code to send a request to server side
}
function webServiceResponseHandler(){
//receive the response from server
sendWSRequest();
}
function sendWSRequest(){
if(arr.length > 0)
{
resultHandling(arr.getItemAt(0));
arr.removeItemAt(0);
}
}
Most Flash I/O is asynchronous and there is no way to change that. Consider using inline nested handlers
function checkBoxHandler() {
var obj:myObjectType = new myObjectType();
var resultHandling:Function = function():void {
//you can just reference obj here
var resultHandling2:Function = function():void {
};
};
//implementation code to send a request to server side
}
or use a task scheduler such as the Parsley Command Framework.
I'm an as3 newbie and I'm trying to send a message through netstream to a function that will handle it.
Here is the line that sends
public function _attachLocalVideoAndAudio(muteCam:Boolean = false, muteMic:Boolean =
false):void
{
...
_outgoingStream.send("flagVideo",true);
...
}
public function flagV():Boolean
{
var client:Object;
client.flagVideo=function(flag:Boolean):void{
check=flag;
}
return check;
}
*check is defined
I'm using Monster Debugger to debug and it seems that there is a problem with the inner function that handles the flag. There isn't much tutorials on the web on netstream.send() but I wrote this code based on something I saw online.