Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Slider puzzle (imaging lingo)
Custom Check and Radio Buttons
Graphic Puzzle Dragger
Set FrameRate of a Animated Gif Cast Member
New bitmap from existing member
Composite Images with Alpha
Open MIAW
Change ShapeType of a Shape cast member
Sprite Group Movement behavior
Flash Movie Controls
MediaMacros Xtras Mall
 

 

 

Behavior RTF files using free FileIOXtra

Added on 4/26/2003

 

Compatibilities:

Required Xtras:
FileXtra

This item has not yet been rated

Author: Mdkt

Import and export RTF files without having to pay for extras. Basically use the exact same demo as that which comes with the FileIOXtra but change a few things.

--   Saving out to a file.
on saveText (whichmember)
  -- create the FileIO instance
  fileObj = new(xtra "FileIO")
  -- set the filter mask to text files
  if the platform contains "mac" then
    setFilterMask(fileObj,"TEXT")
  else
    setFilterMask(fileObj,"Text Files,*.txt,All Files,*.*")
  end if
  -- save dialog box
  filename = displaySave(fileObj,"","")
  -- check to see if cancel was hit
  if filename = "" then return FALSE
  -- delete existing file, if any
  openFile (fileObj,filename,2)
  delete(fileObj)
  -- create and open the file
  createFile(fileObj,filename)
  openFile(fileObj,filename,2)
  -- check to see if file opened ok
  if status(fileObj) <> 0 then
    err = error(fileObj,status(fileObj))
    alert "Error:"&&err
    return FALSE
  end if
  
  -- write the file
  
  TextToSave=member(whichmember).rtf -- .rtf indicates the rich text format of the cast member.
  writeString(fileObj, TextToSave)
  -- so the text file will contain the rtf data. A regular text editor will open it with junk
  -- but any application that supports .rtf files will understand the formatting.
  
  -- set the file type
  if the platform contains "Mac" then
    --instead of the following, setFinderInfo should contain
    --the necessary information for an rtf file. I am a PC person and
    --do not know what the Mac Finder info is for rtf files.
    
    --setFinderInfo(fileObj, "TEXT ttxt")
  end if
  -- close the file
  closeFile(fileObj)
  return TRUE
end


-- Loading from a file into member(whichmembertosaveto)

on LoadText (whichmembertosaveto)
  -- create the FileIO instance
  fileObj = new(xtra "FileIO")
  -- set the filter mask to text files
  if the platform contains "mac" then
    --  setFilterMask(fileObj,"RTF")
    --the mac FilterMask should be set to whatever "RTF" Files are. Again, I am a PC person.
  else
    setFilterMask(fileObj,"RTF Files,*.RTF,All Files,*.*")
  end if
  -- open dialog box
  filename = displayOpen(fileObj)
  -- check to see if cancel was hit
  if filename = "" then return ""
  -- open the file
  openFile(fileObj,filename,1)
  -- check to see if file opened ok
  if status(fileObj) <> 0 then
    err = error(fileObj,status(fileObj))
    alert "Error:"&&err
    return ""
  end if
  -- read the file
  text = readFile(fileObj)
  -- close the file
  closeFile(fileObj)
  
  --put the rtf data into a member
  member(whichmembertosaveto).rtf=text
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail