How to use paths:
localPath example - "C:/test1.txt"
ftpPath example - "/public_html/test2.txt"
Methods
SmartFTP(host:String = null, username:String = null, password:String = null, port:int = 21):voidConstructor which gives you ability to make connection immediately
upload(localPath:String, ftpPath:String = ''):void
Upload file from "localPath" to "ftpPath". This method won't work if there is no connection or socket is busy
uploadTask(localPath:String, ftpPath:String = ''):void
Create new upload task. Tasks are triggered soon as possible (when connection is active and non busy) one after another
download(localPath:String, ftpPath:String):void
Download file from "ftpPath" to "localPath". This method won't work if there is no connection or socket is busy
downloadTask(localPath:String, ftpPath:String):void
Create new download task. Tasks are triggered soon as possible (when connection is active and non busy) one after another
dirListMsg(ftpPath:String):void
Read directory list from "ftpPath". You can get result (directory list message) from "msg" property from event listener or stored message list
dirListMsgTask(ftpPath:String):void
Create new "read directory list" task. Tasks are triggered soon as possible (when connection is active and non busy) one after another
open(host:String = null, username:String = null, password:String = null, port:int = 21):void
Opens connection
close():void
Closes connection
closeTask():void
Closes connection task. Tasks are triggered soon as possible (when connection is active and non busy) one after another
closeStream():void
Closes any read/write stream for upload or download. Be aware that it's not recomended to use it because it will not stop processes accompanying to upload/download. For safety it's better to use method "close()" or "closeData()"
closeData(closeDataTasks:Boolean = true):void
Closes everything expect connection and tasks if "closeDataTasks" is set to "false"
clearMessage():void
Clears all stored messages
clearError():void
Clears all stored error messages
Properties
listener:FunctionThis function will be used to detect events. Function passes object with few properties: target (current SmartFTP instance), code (response code number), type (event type), task (name of task - source of event), msg (last original message received from server)
message:String
Read only. Returns all messages as one string
messageVec:Vector.<String>
Read only. Returns all messages as vector array
error:String
Read only. Returns all errors as one string
errorVec:Vector.<String>
Read only. Returns all errors as vector array
taskList:Vector.<Object>
Read only. Returns original task list
fileData:ByteArray
Read only. Returns last used ByteArray data
connected:Boolean
Read only. Returns true if connection is active
connectedData:Boolean
Read only. Returns true if socked for transfer data is active
busy:Boolean
Read only. Return true if connection is busy (new action can not be taken until connection is busy)
host:String
Read only. Returns current host
username:String
Read only. Returns current user name
host:String
Read only. Returns current host
password:String
Read only. Returns current password
port:int
Read only. Returns current port
path:String
Read only. Returns current task name
Event Types
To be able to recognize events you need to use event type names. It could be problematic to remember all those types, and that's why it's better to use static variables which holds them.List of variables (event types): LOGIN_SUCCESS, DOWNLOAD_SUCCESS, UPLOAD_SUCCESS, CONNECTION_CLOSED, CONNECTION_TIMEOUT, LOGIN_FAILD, DIRECTORY_FAILD, UPLOAD_STREAM_SUCCESS, STREAM_CLOSED, ERROR, DIR_LIST_RECEIVED
Simple example:
var mySmartFTP = new SmartFTP(); mySmartFTP.listener = myListenerFunction; function myListenerFunction(e):void {//e:Object if (e.type == SmartFTP.LOGIN_SUCCESS) { trace('You are logged in!'); } }