Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3276270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:14:20+00:00 2026-05-17T19:14:20+00:00

I have a Course class which contains collection of CourseItems . Each CourseItem has

  • 0

I have a “Course” class which contains collection of “CourseItems“.
Each CourseItem has a folder associated with it(for its files).
I need to add the CourseItem to a Zip file and after zipping it encrypting.
Using FZip and As3crypto I can do the zip and encrypt the zip file.
Whether to do Encryption or not is upto the user .
Currently my code looks similar to (ignore sytax):

Edit: I will try to add some more info + more description
Basically a Course is a folder(user selectable) with subfolders(courseitems).
mapping subfolder structure to the courseitem object(s).

       //main code
    var encryptCourse:Boolean;
     encryptCourse=true; // read from user..checkbox
    var course:Course = new Course("path_coursefolder");//from user input

     course.createCourseItems();

    //read course folder and create "courseitem" for each subfolder
    //and save in "courseItems" collection
 //after creating pack course - zip and encrypt
   course.Pack(encryptCourse);//encryptCourse bool encrypt course or not



 class Course
     {
               var courseItems:Array; //set when creating
               public function Pack()
               {
                     for each (var item:CourseItem in courseItems)
                        {
                           item.addEventListener("ZIP_COMPLETE",onitemzip);
                           item.zip();                     
                        } 
               }    

         private function onitemzip(e:Event)
          { 
              //if user selected to encrypt..do encryption 
             //now  i want to call the encrypt method :(
             //item.Encrypt() //cant call this,,how to refer to "item"??
          }
      }

            class CourseItem
            {
              var files:Array; //set when creating
              var _courseZipfile;
              public function ZIP()
              {
                var ziputil = new Ziputil()
                 ziputil.createZip("some_name",files);
                 ziputil.addEventListener(Event.Complete,onZipComplete);
              }

               private function onZipComplete(e:Event)
               {
                 dispatchEvent(new ZipEvent("ZIP_COMPLETE"));   
                 //dispatch and update progess
                 //COULD CALL ENCRYPT HERE..but want to avoid.   
               }

              public function Encrypt()
              {
                //encrypt zip file here
                //event of encrypt finish 
              }
            }

Basically in above design I want to call “Encrypt” method of CourseItem in Course after Zipping.

Note : i had earlier changed the courseitem class.
I had tried moving pack inside CourseItem then i cud handle encryption after zip.
But by this i strongly couple Zip and encrypt methods.
After zipping -> encrypt is called compulsarily .
i want refactor my code in such a way that both methods
zip and encrypt are independant of each other?
How can i do the same ..

Thanks all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:14:21+00:00Added an answer on May 17, 2026 at 7:14 pm

    Edit:
    Following your edits , I have edited my code accordingly

    When a user chooses to encrypt, check the value of the Boolean , if true call the encryption method after the zip complete event has been dispatched.

    public class Course
    {
       public function Pack(encryptCourse:Boolean)
       {
          for each (var item:CourseItem in courseItems)
          {
             item.addEventListener("ZIP_COMPLETE", onitemzip);
    
             if(encryptCourse)
               item.encrypt = true;
    
             item.zip();                     
           } 
       } 
    }
    
    public class CourseItem
    {
        private var _encrypt:Boolean;
    
        public function set encrypt(value:Boolean):void
        {
           _encrypt = value;
        }
    
        private function onZipComplete(e:Event)
        {  
          if(_encrypt)
             Encrypt();
    
          //here you can choose to dispatch a complete event according
          //to the value of _encrypt , if true , dispatch the event 
          //after encryption
          dispatchEvent(new ZipEvent("ZIP_COMPLETE")); 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a database of Courses, and it has 6 columns: class Course(models.Model):
I have a very classical class which contains buttons and label, etc... : @interface
I have a Course entity which contains a Set of Keys to my Tag
Basically, I have a class defined in my website which contains a bunch of
I have a class, call it Class1 , which contains an array, call it
I have a file called entities.py, which contains the following code: class EntityClass: entities
assume i have a huge input form, which of course representing classes. i need
I have four models in my models.py which are: models.py class Course(models.Model): course_code =
I have a class called Timestamp. This class contains a static NSDate variable which
I have following situation (simplified, of course): MyDomain.groovy: class MyDomain { MyAnotherDomain anotherDomain //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.