So where to begin, I have been having trouble with this for a very long time and was about to give up on the whole idea. Just to give you a rundown on what I wanted to do.
1. I have a video player that has several clips on the same time line.
2. When the video reaches the next clip, a flash animation plays before the next video starts.
3. Each clip has its own colour.
What I wanted to do was set the colour of the flash animation to the colour of the clip. The animation was a simple swipe across the screen, like a curtain being drawn.
To embed the animation in the player, I am using the loadPlugin function. I tried several ways to pass the colour to flash. Setting in in the JSON calls and as a query string. I had no luck with the JSON calls as i had no way of knowing how the loadPlugin embeds the flash of where it was located. Normally you can look at the source file and see the embed content but there was no reference to the flash animation I was loading.
So I decided to look at getting the value from the query string.
The call to the loadPlugin flash contents looks like this:
myflow.loadPlugin("swipe" + current, playerPath + "plugins/swipe/swipe.swf?" + colours[current % colours.length]
colours is an array of colours.
To get this value in flash, I used the actionscript code:
1. Get the url that called the flash content: var url = this._url;
2. Then get the parameter, in this case the hex value:
var paramPosition = url.lastIndexOf("?");
3. Then we take that parameter and store it in a variable:
var param = url.substring(paramPosition + 2, url.length).toLowerCase();
I add 2 in order to remove the ? and # from the parameter. Flash uses the 0xffffff format.
4. Because I was using this variable in several places in the flash time line, I set it as a global variable:
_global.colourHexValue = param;
5. Now I had to set the colour of the flash elements. To do this I had to make each element a moveclip and set an instance name for eack movieclip. I then use the folowing code to set the colour:
var setSwipeColor = new Color(swipe);
setSwipeColor.setRGB("0x" + colourHexValue);
I hope this helps someone.
1. I have a video player that has several clips on the same time line.
2. When the video reaches the next clip, a flash animation plays before the next video starts.
3. Each clip has its own colour.
What I wanted to do was set the colour of the flash animation to the colour of the clip. The animation was a simple swipe across the screen, like a curtain being drawn.
To embed the animation in the player, I am using the loadPlugin function. I tried several ways to pass the colour to flash. Setting in in the JSON calls and as a query string. I had no luck with the JSON calls as i had no way of knowing how the loadPlugin embeds the flash of where it was located. Normally you can look at the source file and see the embed content but there was no reference to the flash animation I was loading.
So I decided to look at getting the value from the query string.
The call to the loadPlugin flash contents looks like this:
myflow.loadPlugin("swipe" + current, playerPath + "plugins/swipe/swipe.swf?" + colours[current % colours.length]
colours is an array of colours.
To get this value in flash, I used the actionscript code:
1. Get the url that called the flash content: var url = this._url;
2. Then get the parameter, in this case the hex value:
var paramPosition = url.lastIndexOf("?");
3. Then we take that parameter and store it in a variable:
var param = url.substring(paramPosition + 2, url.length).toLowerCase();
I add 2 in order to remove the ? and # from the parameter. Flash uses the 0xffffff format.
4. Because I was using this variable in several places in the flash time line, I set it as a global variable:
_global.colourHexValue = param;
5. Now I had to set the colour of the flash elements. To do this I had to make each element a moveclip and set an instance name for eack movieclip. I then use the folowing code to set the colour:
var setSwipeColor = new Color(swipe);
setSwipeColor.setRGB("0x" + colourHexValue);
I hope this helps someone.