AS 3 breaks AS2 -- nothing is ever easy. {resolved}

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Don't you hate when you fix something and get it to work just like you want it to, it breaks something else?

OK, so for the last few weeks I've been trying to get KML and KMZ files to work in Flash - reference this post if you weren't already following it.
flash-forum/add-mime-type-geturl-t89893.html

Obviously to do it, I had to use AS3. OK, that's resolved and works perfectly, however, when applying it to the Flash file I need it to work in, it breaks AS2 code designed for a scroll.

Situation:
1. My company site uses multiple swf's for various services and parts of the site that are loaded into the main swf. This particular swf is for the map & directions page.
2. The site was originally designed for Flash 6 using AS2
3. After changing the publish settings to Flash 9 AS3, the AS2 scroll code breaks and produces the following warning:
Quote:
WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.

and the following compile error on the movieClip newsText:
Quote:
1152: A conflict exists with inherited definition flash.display:DisplayObject.mask in namespace public.

4. The instance of newsText on the stage has an instance name of scrollArea
5. The action script for scrollArea follows:
Code: [ Select ]
scrollArea.content.mainNewsBox.html = true;
scrollArea.content.mainNewsBox.condenseWhite = true;
scrollArea.content.mainNewsBox.autoSize = true;
  1. scrollArea.content.mainNewsBox.html = true;
  2. scrollArea.content.mainNewsBox.condenseWhite = true;
  3. scrollArea.content.mainNewsBox.autoSize = true;

6. The action script for the newsText instance follows (basically the code makes the scroll work) If I'm understanding the error correctly, this is where the problem is. :
Code: [ Select ]
//set easing speed for scrollbar
var scrollSpeed = 5;
//choose whether or not to have a handcursor show over scrollbar
dragBar.useHandCursor = false;
//actions to make scrollbar draggable within the height of the mask
dragBar.onPress = function() {
    this.startDrag(false, this._x, 0, this._x, mask._height-this._height);
};
//stop dragging scrollbar when released
dragBar.onRelease = dragBar.onReleaseOutside=stopDrag;
//actions to scroll content clip
dragBar.onEnterFrame = function() {
    //get appropriate scrollbar draggable area height
    var bH = mask._height-this._height;
    //get appropriate viewable content height
    var cH = content._height-mask._height;
    //ratio of scrollbar position to content position
    var ratio = Math.round(this._y*cH/bH);
    //position content clip where it should be according to the ratio variable
    content._y += Math.round((-ratio-content._y)/scrollSpeed);
};
stop();
  1. //set easing speed for scrollbar
  2. var scrollSpeed = 5;
  3. //choose whether or not to have a handcursor show over scrollbar
  4. dragBar.useHandCursor = false;
  5. //actions to make scrollbar draggable within the height of the mask
  6. dragBar.onPress = function() {
  7.     this.startDrag(false, this._x, 0, this._x, mask._height-this._height);
  8. };
  9. //stop dragging scrollbar when released
  10. dragBar.onRelease = dragBar.onReleaseOutside=stopDrag;
  11. //actions to scroll content clip
  12. dragBar.onEnterFrame = function() {
  13.     //get appropriate scrollbar draggable area height
  14.     var bH = mask._height-this._height;
  15.     //get appropriate viewable content height
  16.     var cH = content._height-mask._height;
  17.     //ratio of scrollbar position to content position
  18.     var ratio = Math.round(this._y*cH/bH);
  19.     //position content clip where it should be according to the ratio variable
  20.     content._y += Math.round((-ratio-content._y)/scrollSpeed);
  21. };
  22. stop();


Putting it all together, this is what the finished product is supposed to look like and do.
http://www.alaron-nuclear.com/devsite/S ... onMap.html
(obviously I had to publish that as AS2 to get it to work, which breaks the "Take me to Alaron" link which is the KMZ file which requires I use AS3).

Where I'm at:
1. I have to publish this using AS3 to get the KMZ link to work.
2. I know that the reason the AS2 won't work on the scroll when published in AS3 is because scripts can't be used on objects in AS3 and have to be applied to the timeline.
3. I just got CS3 and haven't even begun to start to study AS3. I learned what I know and understand of AS2 primarily on my own, and will eventually learn AS3 as well, however, I can't wait as long as it will take to get me to that point. My boss wants this working and I have to do it.
4. I didn't write the original code, or do the original design. However, I'm now the one that modifies everything now. I understand most of what the existing code does, however... I haven't the first clue what I have to alter in the scroll code to get it to work in AS3.

Here's a zip with the FLA file if you'd like a bird's eye view. The fonts are FFF Business and FFF Business bold and are licensed fonts, so unless you have them yourself just pick any substitute.
Attachments:
alaronMap.zip

(202.3 KiB) Downloaded 270 times

alaronMap.fla

  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Still could use some help with this.
I have the same question in at actionscript.org where I did get some advice and posted additional information. Easier just to read and follow it there.

http://www.actionscript.org/forums/show ... 3?t=179083
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

This is resolved.

I didn't know enough to complete the action script myself, but I found this AS3 scroller at Adobe Exchange and got it to work. In fact it works better than the scroll I used to have. It was one of the few I found for free and easy enough for even an AS3 noob like me to understand.

http://www.flashscaper.com/lab.html


Here's the working scroll in action
http://www.alaron-nuclear.com/devsite/S ... ap3-e.html

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.