Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-14-2012, 07:53 PM   #1
carterkay
Registered User
 
Join Date: Mar 2012
Posts: 6
Default extending the cell class

Hi,

I have built an online magazine and its being hosted by Ceros, an online publishing platform.

The issue is I cannot use their zoom function, according to Ceros support I am extending the Cell class, because I am adding objects to the stage manually, when I should be creating content dynamically.

I have looked around but I cannot find a simple tutorial to do what I want, because I have already designed the website without creating the content/movie clips dynamically, I need to create an object dynamically and put all my existing content inside it, Ceros
support said this will work!

Does anyone know how I do this?

Thanks
carterkay is offline   Reply With Quote
Old 04-15-2012, 12:49 AM   #2
svenjoypro
DontJustEnjoyIt,SvEnjoyIt
 
svenjoypro's Avatar
 
Join Date: Sep 2005
Location: California
Posts: 1,389
Default

I'm not totally positive I understand, but I'm guessing you need to take everything you have on stage and put it into a new movieclip (convert it to a symbol, F8). While the Convert to Symbol dialogue box is open expand the advanced options, then check the "Export for Actionscript" box. Give it a class name (or use the default of what it puts in), then click ok. It will probably pop up saying a definition for the class couldn't be found, just hit ok. Now in the library panel find your new movieclip, right-click on it->Edit Class. This will open a new file, you'll want to save this with the same name as the class. So if your class is named Magazine, the file should be Magazine.as. You'll notice near the top it says 'public class Magazine extends MovieClip {', you'll want to change 'MovieClip' to 'Cell'. You should also import Cell.as (if that's in a folder you need to reference the location as well, ie import com.Ceros.Cell or something along those lines).
You should end up with something that looks like this:
ActionScript Code:
package  {         import flash.display.MovieClip;     import com.Ceros.Cell;         public class Magazine extends Cell {                         public function Magazine() {             // constructor code         }     }     }

Now all of the code you use to act on your symbol will go in this class. If you're unfamiliar with classes, I'd look up some tutorials. But know that Magazine() gets called when the symbol is created; which you'll need to do from either the main stage or your document class (if you have a doc class). You create a new instance like this:
ActionScript Code:
var mag:Magazine = new Magazine(); //Create a new instance of Magazine addChild(mag); // Add it to the stage

This is known as creating content dynamically. Creating a new instance of something via actionscript.
Now every function and variable that Cell has, your Magazine instance will also have. So if Cell has a zoom() function, you can now use that like this:
ActionScript Code:
mag.zoom(); // This is from the stage or doc class //OR this.zoom(); // This is from within the Magazine class we created

Again, I'm not positive this is the answer you're looking for, and without knowing what Cell.as looks like, I can't be sure. But hopefully that helps point you in the right direction.
svenjoypro is offline   Reply With Quote
Old 04-15-2012, 06:13 PM   #3
carterkay
Registered User
 
Join Date: Mar 2012
Posts: 6
Default

Hi,

Thanks for the info, I followed what you said but it
didn't work out for me, do I add the addChild code to
the document class or the class of the movie clip?

The code
addChild(mag);
creates an instance of the movie clip but isn't that
an empty movie clip? I don't understand how it can
if its an instance?
carterkay is offline   Reply With Quote
Old 04-15-2012, 06:18 PM   #4
carterkay
Registered User
 
Join Date: Mar 2012
Posts: 6
Default

THIS IS AN EMAIL FROM CEROS SUPPORT!


but I'd say that dynamically created content would not be controlled by the cell class if it wasn't created in the constructor function. Therefore it would not exhibit the properties associated by it.
Most clients have the image in the background as you do. However they use the show(); function to place individual movie clips on the stage, rather than moving to a different point in the timeline, and having them placed in bulk. Using that method you can invoke a function which controls the background and means that it does not need to be extended by the Cell class.
Essentially, only the animations are controlled by Cell class, and the background isn't.
carterkay is offline   Reply With Quote
Old 04-15-2012, 06:18 PM   #5
carterkay
Registered User
 
Join Date: Mar 2012
Posts: 6
Default

AND THIS IS AN EXPLANATION FROM THEIR WEBSITE



If you find that the event listener for Ceros' zoom functionality is being overridden. Have a check to make sure nothing in your lowermost layer is being extended by the cell class. For example, if you're using a background image in your SWF and it is extended by Cell it will inherit the event listeners of that class (MouseEvent.Click != cerosZoom), and will therefore inhibit Ceros' zoom. To remedy this, stop it extending the cell class, or move it into another object which isn't extended by cell.
carterkay is offline   Reply With Quote
Old 04-16-2012, 12:34 AM   #6
svenjoypro
DontJustEnjoyIt,SvEnjoyIt
 
svenjoypro's Avatar
 
Join Date: Sep 2005
Location: California
Posts: 1,389
Default

Quote:
Originally Posted by carterkay View Post
do I add the addChild code to
the document class or the class of the movie clip?
You would put that in the document class.

What exactly didn't work for you? The on click event shouldn't be a problem, unless you added an on click event listener in your Magazine class.
svenjoypro is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:16 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.