Code Is Breaking In Flash Player 7
***CODE BY LEE BRIMELOW FROM GoToAndLearn ALSO TheFlashBlog awesome sites. awesome tutorials.***
Hopefully this is something really simple. However when I export my movie in Flash Player 7 my images go away and i have nothing but a blank stage. When I export in Flash Player 8 all is well. I'm not sure what the deal is. However, Is there some what to display Player Requirements without your code? So that I can highlight the code thats FP8 only in bright red maybe????
If anyone sees any red flags in this code or has any idea on how to help please let me know.
Thanks!
>
>
>
Attach Code
////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// THIS IS WHERE I GET EXCITED!! ///
/// ///
///////////////////////////////////////////////////////////////////////////////////////
// importing Delegate class
import mx.utils.Delegate;
// importing Tween class
import mx.transitions.Tween;
// importing easing types
import mx.transitions.easing.*;
// number of items that are rotating; not entering number here, will reference that from the xml file but we still need the variable
var numOfItems:Number;
// the X radius or width of the rotating circle; the Y radius or height of the rotating circle
var radiusX:Number = 150;
var radiusY:Number = 70;
// center the rotating circle on the stage
var centerX:Number = Stage.width/2;
var centerY:Number = Stage.height/2;
// control the speed of the rotation *the lower the slower*
var speed:Number = 0;
// allows me to skew the perspective of the variable in the back of the circle
var perspective:Number = 0;
var home:MovieClip = this;
// make sure the text field is not visible
theText._alpha = 0;
// attaching tooltip mc to the stage; giving a very high depth to make sure it is always above the other items
var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
// setting alpha to zero so that tooltip is not visible until we initiate rollover
tooltip._alpha = 0;
var nodes;
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
// finding all childnodes (icons) in the xml file and assigning it to an array
nodes = this.firstChild.childNodes;
// now setting number of items *see above* to equal number of childNodes in the xml document
numOfItems = nodes.length;
// attaching the items onto the stage with a for loop
for(var i=0;i<numOfItems;i++)
{
var t = home.attachMovie("item","item"+i,i+1);
//var z = home.attachMovie("item2","item2"+i,i+1);
//testing ghostclip
//ghostclip.loadMovie(nodes[i].attributes.image2);
ghostclip._alpha = 50;
// giving each item an angle *divided equally around the circle*
// note: radians are a different way of mesuring degrees in flash *this is a way to acheieve an angle, flash does not work with °, Math.PI*2 = 360, Math.PI = 180, Math.PI/2 = 90
t.angle = i * ((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
// grabbing all the tooltip & content attributes from the xml document
t.toolText = nodes[i].attributes.tooltip;
t.content = nodes[i].attributes.content;
t.image = nodes[i].attributes.image2;
//// loading in the png file
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
// getting the attribute image
z.icon.inner.loadMovie(node[i].attributes.image2);
// creating rollover & rollout for the icons
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
speed = 0;
}
function over()
{
// showing the mc and make it follow the icon as it rotates
// note: reference tooltip on timeline
// note: this = icon mc, this._parent = item mc
home.tooltip.tipText.text = this._parent.toolText;
// setting x & y of the tooltip; note: subtracting (- this._parent._height/2) moves the tool tip above the item about halfway so that it isnt not on tip of the item
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
// make sure we follow the icon; using delagate class which assigns scope to function call, now this refers to the icon we rolled over insteas of this being the tooltip.
home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
home.tooltip._alpha = 100;
getNodes();
}
function getNodes(){
//trace(nodes);
}
function out()
{
// make sure we follow the icon; using delagate class which assigns scope to function call, now this refers to the icon we rolled over insteas of this being the tooltip.
delete home.tooltip.onEnterFrame;
home.tooltip._alpha = 0;
}
function released()
{
button_l._alpha = 0;
button_r._alpha = 0;
button_stop._alpha = 0;
// make sure the tooltip becomes invisible
home.tooltip._alpha = 0;
// creating a for loop to animate all icons at once
for(var i=0;i<numOfItems;i++)
{
// creating a temporary variable so you dont have to keep rewriting code
var t:MovieClip = home["item"+i];
trace("i equals" + i);
trace("t equals" + t);
// when item is clicked each icons x, y position and scale will be captured so that when you return they all start back where they left off
t.xPos = t._x;
t.yPos = t._y;
// note: dont need yscale because we are maintaining proportion
t.theScale = t._xscale;
// delete event handlers that are not needed
delete t.icon.onRollOver;
delete t.icon.onRollOut;
delete t.icon.onRelease;
// stop the circle from rotating while an icon is focused
delete t.onEnterFrame;
// if statement checks to see if icon is the one that was currently clicked; note != means not equal
if(t != this._parent)
{
// tween code for animation. create new instance, strict data typed to Tween
// breakdown: Tween(which item are we animating, "which property to animate", type of easing,start value, end value, time (1 second), true (confirms seconds and not frames))
// fades out any icons that havent been clicked and scales them down to 0
var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,100,0,1,true);
//z.loadMovie(nodes[i].attributes.image2);
}
else
{
// making sure focused icon is scaled to 100, especially the ones in the back
var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
// moving position of focused icon
var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,220,1,true);
var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,187,1,true);
// fade out large icon
var tw5:Tween = new Tween(t,"_alpha",Strong.easeOut,100,100,1,true);
// fade in text
var tw6:Tween = new Tween(theText,"_alpha",Strong.easeOut,0,100,1,true);
// put xml content into text field
theText.text = t.content;
//home.attachMovie("backtomain", "ghostclip2", this.getNextHighestDepth(), {_x:353, _y:267});
//var tw9:Tween = new Tween(backtomain,"_alpha",Strong.easeOut,0,100,1,true);
// loading the image YES!
var tw8:Tween = new Tween(ghostclip,"_alpha",Strong.easeOut,0,100,1,true);
ghostclip.loadMovie(t.image);
// creating a scope variable strict data typed to an object = to this; storing a reference to the current icon that we are inside of
var s:Object = this;
// check to see when the tween is completed, then set onRelease of the new focus item and go back to full circle
tw.onMotionStopped = function()
{
s.onRelease = unReleased;
}
}
}
}
function unReleased()
{
var tw3:Tween = new Tween(button_l,"_alpha",Strong.easeOut,0,100,1,true);
var tw3:Tween = new Tween(button_r,"_alpha",Strong.easeOut,0,100,1,true);
var tw3:Tween = new Tween(button_stop,"_alpha",Strong.easeOut,0,100,1,true);
// delete the onRelease event so you cant click on it twice
delete this.onRelease
// fade out text field
var tw:Tween = new Tween(theText,"_alpha",Strong.easeOut,100,0,0.5,true);
for(var i=0;i<numOfItems;i++)
{
var t:MovieClip = home["item"+i];
if(t != this._parent)
{
// returning everything to its original position
var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,0,t.theScale,1,true);
var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,0,t.theScale,1,true);
var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
}
else
{
var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,100,t.theScale,1,true);
var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,100,t.theScale,1,true);
var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,t.xPos,1,true);
var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,t.yPos,1,true);
var tw5:Tween = new Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
// unloading the image YES!
var tw6:Tween = new Tween(ghostclip,"_alpha",Strong.easeOut,100,0,1,true);
// remove step image
ghostclip.unloadMovie(t.image);
//attach back to main
home.attachMovie("ghostclip2", "ghostclip2", this.getNextHighestDepth(), {_x:0, _y:0});
tw.onMotionStopped = function()
{
for(var i=0;i<numOfItems;i++)
{
// easy reference to the current item
var t:MovieClip = home["item"+i];
// reseting events
t.icon.onRollOver = Delegate.create(t.icon,over);
t.icon.onRollOut = Delegate.create(t.icon,out);
t.icon.onRelease = Delegate.create(t.icon,released);
// start circle moving again
t.onEnterFrame = mover;
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// :) HOVERING TOOLTIPS ARE KINDA COOL!!! ///
/// ///
////////////////////////////////////////////////////////////////////////////////////////////////////
function moveTip()
{
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
}
// loading in the xml file
xml.load("icons.xml");
function mover()
{
// note: passing in an angle gives you the ratio of 2 sides of a right triangle; x = cos & y = sin; this.angle returns a number between 1 & -1 multiplied by the total radius (radiusX) & position it at center
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
// calculate what the scale should be for the item; finding Y position for item and dividing by centerY plus the total radius; this tells me how far my item is away from center Y axis
// plugging in perspective variable to increase/decrease the amount of scale on icon mcs
var s = (this._y - perspective) /(centerY+radiusY-perspective);
// setting X & Y scale
this._xscale = this._yscale = s*100;
// note: increment angle (this.angle) by speed value to create movement
this.angle += this._parent.speed;
this.swapDepths(Math.round(this._xscale) + 100);
}
////////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// ADDING EXTRA FUNCTIONALITY ///
/// ///
////////////////////////////////////////////////////////////////////////////////////////////
this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/5000;
}
button_r.onPress = function() {
speed = (this._xmouse-centerX)/-2500;
trace("pressed r button & speed is " + speed);
}
button_l.onPress = function() {
speed = (this._xmouse-centerX)/2500;
trace("pressed l button & speed is " + speed);
}
button_stop.onPress = function() {
speed = 0;
trace("pressed stop button & speed is " + speed);
}